So up until now I have been doing bits in HA (hassio) including setting up hue lights, a couple of graphs, some data displays for speedtest.net and my synology nas and most recently the skyq custom component.
Until now it has all been UI and Lovelace type stuff really.
Next step, I have a friends of hue switch (sensor.friends_of_hue_switch_1) which has 4 buttons and changes the state to things like “left_upper_release”
I would like to write automation? (or script not entirely sure which) so that when “left_lower_release” is set it plays my sonos.
I am not entirely sure where to start with this, should I use the entity as a sensor? If I set it to play when “left_lower_release” what happens if “left_upper_release” is then pressed? does the state of the sensor mean sonos stopped, which would be unwanted, or can I write it so that each press of the lower left button starts or stops sonos.
Feel like this is really basic, but on the basis I am not sure whether I need automation or script and how to treat a sensor like a switch I need some pointers on where to start.
I have a Samsung button which is similar, here’s the code I use to turn on a light (short push), have it do disco lights (double push) or turn off (held).
Here’s some info on how you can specifically use the triggers on the hue dimmer switch which you would substitute in where i have the mqtt triggers.
So looking in the yaml fille for Hue I can see there are actually press and release states, its just the press barely shows up in the history as its so quick but hopefully I can use the press states so I can use:
left_lower_press
and the code you have provided and linked too. Thanks!
So I thought this might work but config check is not happy
- alias: Turn_Sonos_Pause_bedroom_switch
description: ''
trigger:
- entity_id: sensor.friends_of_hue_switch_1
platform: state
to: left_lower_press
condition:
- condition: state
entity_id: media_player.bedroom
state: playing
action:
- alias: ''
data: {}
service: media_player.media_pause
gives an error saying I have nothing in the data / action bit which is true. I used the automation wizard and not sure what to put in here in terms of data.
Sorry for the delay, didn’t get a message that you had replied.
If you go to Developer Tools -> Services you can type in the media_player and it will show you the options that the service wants. For media_player.media_pause you just need the entity_id. Try this: