I have a configuration split into separate files and this is my scenes.yaml file:
name: Movies
entities:
switch.mbr_aircon: on
switch.mbr_fan: off
switch.mbr_light: off
switch.mbr_tv: on
name: Sleep
entities:
switch.mbr_aircon: on
switch.mbr_fan: off
switch.mbr_light: off
switch.mbr_tv: off
(sorry for the lack of formatting if messed up but the file does process correctly).
All the items are controlled by a Broadlink RM Pro with fan using 433MHz and IR for the rest.
The problem is that 3 of the 4 items - all except the fan - use the same button to turn the device on OR off.
So, if I am in Movie mode and then want to go to sleep, just the TV should turn off.
However, the aircon and light also toggle from their existing state!
HA appears to know the state of the switches so I am a bit confused as to why it would toggle them - is it because it doesn’t look at the state but if the scene says to turn the light off it will trigger the off action even if it is already off? Or do I have to add some more configuration?
Yeah - you’ll need to either use automations or scripts and implement conditions. In a script, you can use conditions along the way to halt processing of any service that follows that condition. You don’t get if/else, but you can usually work something out.
Thanks but I don’t see how it would be implemented.
Example: if the A/C is on, then stop the script because we don’t want to turn it on 2 times… the script would then stop and not check for other devices.
The way I do it is have each device in a separate script with it’s own condition and then just call the scripts in a scene. I have one device in my away scene but you can more with the same state condition in their respective scripts and reference them in the scene. Example below:
script:
ecobee_away_mode:
sequence:
- condition: state
entity_id: "input_boolean.away_mode_ecobee"
state: "on"
- service: climate.set_hold_mode
data:
entity_id: climate.ecobee
hold_mode: 'away'
scene:
- name: away
entities:
remote.bedroom: off
remote.living_room: off
media_player.bedroom: off
media_player.living_room_2: off
script.ecobee_away_mode: on
I agree - it could be helpful if you set the state of a switch to “on”, to have it know that and not resend. But there are situations where the opposite is helpful, too. So you have to put some logic into how you handle things.
I’m going to code up some changes in the command-line switches, at least for my usage for now. Could you tell me in which case you would see useful turning on a device that is already on?
If you had a switch that was turned off locally, but hadn’t been polled by HASS yet (so HASS didn’t know it’s state), you’d want an ON to dependably turn a light ON.