mirror of
https://github.com/GeorgeSG/sarah.git
synced 2026-09-07 10:18:44 +00:00
Implement switches as automations
This commit is contained in:
@@ -8,12 +8,6 @@ input_number:
|
||||
icon: mdi:speaker
|
||||
|
||||
sensor:
|
||||
- platform: mqtt
|
||||
name: "Bathroom switch click"
|
||||
state_topic: "z2m_deconz/bathroom_switch"
|
||||
availability_topic: "z2m_deconz/bridge/state"
|
||||
icon: "mdi:toggle-switch"
|
||||
value_template: "{{ value_json.click }}"
|
||||
- platform: mqtt
|
||||
name: "Bathroom switch battery"
|
||||
state_topic: "z2m_deconz/bathroom_switch"
|
||||
@@ -21,12 +15,6 @@ sensor:
|
||||
unit_of_measurement: "%"
|
||||
device_class: "battery"
|
||||
value_template: "{{ value_json.battery }}"
|
||||
- platform: mqtt
|
||||
name: "Bathroom switch action"
|
||||
state_topic: "z2m_deconz/bathroom_switch"
|
||||
availability_topic: "z2m_deconz/bridge/state"
|
||||
icon: "mdi:gesture-double-tap"
|
||||
value_template: "{{ value_json.action }}"
|
||||
- platform: mqtt
|
||||
name: "Bathroom switch LQI"
|
||||
state_topic: "z2m_deconz/bathroom_switch"
|
||||
@@ -36,37 +24,26 @@ sensor:
|
||||
value_template: "{{ value_json.linkquality }}"
|
||||
|
||||
automation:
|
||||
- alias: Media · Sonos · Volume up on bathroom switch click
|
||||
trigger:
|
||||
platform: mqtt
|
||||
topic: "z2m_deconz/bathroom_switch"
|
||||
condition:
|
||||
- condition: state
|
||||
entity_id: sensor.bathroom_switch_click
|
||||
state: 'single'
|
||||
action:
|
||||
- service: media_player.volume_set
|
||||
entity_id: media_player.bathroom
|
||||
data_template:
|
||||
volume_level: >-
|
||||
- alias: Bathroom · Switch
|
||||
use_blueprint:
|
||||
path: aqara_switch.yaml
|
||||
input:
|
||||
z2m_topic: "z2m_deconz/bathroom_switch"
|
||||
click:
|
||||
- service: media_player.volume_set
|
||||
entity_id: media_player.bathroom
|
||||
data_template:
|
||||
volume_level: >-
|
||||
|
||||
{% if state_attr('media_player.bathroom', 'volume_level')|float > (states('input_number.bathroom_high_volume')|float - 0.05) %}
|
||||
0.25
|
||||
{% else %}
|
||||
{{ states('input_number.bathroom_high_volume')|float }}
|
||||
{% endif %}
|
||||
{% if state_attr('media_player.bathroom', 'volume_level')|float > (states('input_number.bathroom_high_volume')|float - 0.05) %}
|
||||
0.25
|
||||
{% else %}
|
||||
{{ states('input_number.bathroom_high_volume')|float }}
|
||||
{% endif %}
|
||||
|
||||
- alias: Youtube · play latest pds on bathroom switch dobule click
|
||||
trigger:
|
||||
platform: mqtt
|
||||
topic: "z2m_deconz/bathroom_switch"
|
||||
condition:
|
||||
- condition: state
|
||||
entity_id: sensor.bathroom_switch_click
|
||||
state: 'double'
|
||||
action:
|
||||
- service: media_player.volume_set
|
||||
entity_id: media_player.bathroom
|
||||
data_template:
|
||||
volume_level: "{{ states('input_number.bathroom_high_volume')|float }}"
|
||||
- service: script.youtube_play_latest_pds
|
||||
double_click:
|
||||
- service: media_player.volume_set
|
||||
entity_id: media_player.bathroom
|
||||
data_template:
|
||||
volume_level: "{{ states('input_number.bathroom_high_volume')|float }}"
|
||||
- service: script.youtube_play_latest_pds
|
||||
|
||||
Reference in New Issue
Block a user