hello,
to control my shelly with a pysical button works good. now
i ve a Aqara Opple and want also switch my shelly with it.
but i ve no idea, how i must configurate HA. need help. thx
hello,
to control my shelly with a pysical button works good. now
i ve a Aqara Opple and want also switch my shelly with it.
but i ve no idea, how i must configurate HA. need help. thx
need help!!!
perhaps with node red and a IF function?
IF AQARA IS PRESSED AND SHELLY = ON THEN SHELLY = OFF
IF AQARA IS PRESSED AND SHELLY = OFF THEN SHELLY = ON
Possible to make this with NodeRed?
What integration are you using? ZHA?
I don’t have any knowledge regarding Aqara Opple with Zigbee2Mqtt, but I think you use device trigger for your automation (modify the trigger below)-
trigger:
- device_id: ad44cabee4c646f493814306aa6446e1
discovery_id: 0x000b57fffecb472d action_arrow_left_click
domain: mqtt
platform: device
subtype: arrow_left_click
type: action
condition: []
action:
- service: >-
light.turn_{{'on' if is_state('light.your_light', 'off') else 'off' }}
target:
entity_id: light.your_light
like this?
trigger:
- platform: device
device_id: ''
domain: 'mqtt'
entity_id: 'sensor.scheune_schalter_action'
condition: []
action:
- service: >-
light.turn_{{'on' if is_state('light.shelly_shsw_1_e8db84acb1b1', 'off') else 'off' }}
target:
entity_id: light.shelly_shsw_1_e8db84acb1b1
and, where can i add which buttons was pressed (1 or 2)?
I think the trigger is incorrect. As I don’t have any idea about Z2M button click trigger, you can read more about it here-
Install MQTT-explorer, connect it to your broker and press your buttons. Post what you received here.
Your trigger will need to be something like
- platform: mqtt
topic: zigbee2mqtt/opple/action
condition:
condition: template
value_template: '{{ trigger.payload_json[''TRIG''] == ''SINGLE'' }}'
this?
this will also not work:
- alias: Scheune Licht Innen
trigger:
platform: mqtt
topic: 'zigbee2mqtt/Scheune Schalter/action'
condition:
condition: template
value_template: '{{ trigger.payload_json[''TRIG''] == ''button_1_single'' }}'
action:
entity_id: light.shelly_shsw_1_e8db84acb1b1
service: light.turn_{{'on' if is_state('light.shelly_shsw_1_e8db84acb1b1', 'off') else 'off' }}
try
- alias: Scheune Licht Innen
trigger:
platform: mqtt
topic: 'zigbee2mqtt/Scheune Schalter/action'
payload: 'button_1_single'
action:
entity_id: light.shelly_shsw_1_e8db84acb1b1
service: light.turn_{{'on' if is_state('light.shelly_shsw_1_e8db84acb1b1', 'off') else 'off' }}
- alias: Scheune Licht Innen
trigger:
platform: mqtt
topic: 'zigbee2mqtt/Scheune Schalter/action'
payload: 'button_1_single'
action:
entity_id: light.shelly_shsw_1_e8db84acb1b1
service: >-
light.turn_{{'on' if is_state('light.shelly_shsw_1_e8db84acb1b1', 'off') else 'off' }}
If the template is single line, you will need to add quotes. If it multi lines, then you don’t need.
works.
thx
second wish
i ve another AQARA OPPLE (6 buttons). Try this both code here, to control the volume of my media player. but both dont work
- alias: Volume Minus
trigger:
platform: mqtt
topic: 'zigbee2mqtt/Partyraum Schalter/action'
payload: 'button_5_single'
action:
delay:
seconds: 0.1
entity_id: media_player.denon_partyraum
service: '{{ states.media_player.denon_partyraum.attributes.volume_level - 5 }}'
- alias: Volume Plus
trigger:
platform: mqtt
topic: 'zigbee2mqtt/Partyraum Schalter/action'
payload: 'button_6_single'
action:
delay:
seconds: 0.1
entity_id: media_player.denon_partyraum
data_template:
volume_level: '{{ states.media_player.denon_partyraum.attributes.volume_level + 5 }}'
action:
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: media_player.volume_set
target:
entity_id: media_player.denon_partyraum
data:
volume_level: >-
{{ state_attr('media_player.denon_partyraum', 'volume_level') - 0.1 }}
If the above YAML doesn’t work, try-
data:
volume_level: >-
{{ '%.1f' | format(state_attr('media_player.2f_bedroom_tv', 'volume_level') - 0.1) }}
Lastly, just a suggestion, you should add a condition to only allow automation proceed if media_player.denon_partyraum
is ON as otherwise you will get an error as usually media_player
does not have volume_level
attribute when they are OFF-
condition:
- condition: state
entity_id: media_player.denon_partyraum
state: 'on'