I have a simple automation setup which alerts me when the washing machine is finished based on power use - it sets the light above the washing machine to a different colour - there’s a door sensor on the machine so it knows when its been emptied and at the moment simply turns that light off.
Instead of turning off the light how easy Is it to grab the status of another light and set that light to match?
This took me more time than I’d like to admit. If I get bored later in the week I may come back to it, but for now I’m just gonna leave you with what I have and you can tinker with it.
I tested this to work with color_mode: xy, but should work with rgb and hs as well (but will not work with color_temp without further editing). It passes json data (so it can dynamically use xy/rgb/hs in one service) to set the color and brightness in your laundry room to match those in your bedroom.
Obviously, change the light entities to the names of your lights.
Thank you did give this a go - at the moment it’s not seeming to do anything - have pasted the full automation - it should be setting light.unit_left_bottom to the same as light.unit_right_bottom
I will keep tinkering with it too - thank you again!
alias: "Helper: Set Washing Machine Status to Off"
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.washing_machine_door_sensor_contact
from: "off"
to: "on"
condition:
- condition: state
entity_id: input_select.washing_machine_status
state: Unemptied
action:
- service: notify.mobile_app_marcs_iphone
data:
message: Washing machine was emptied 🧺
enabled: false
- service: input_select.select_option
data:
option: "Off"
target:
entity_id: input_select.washing_machine_status
- service: light.turn_on
data: |
{
"entity_id" : "light.unit_left_bottom",
"{{states['light.unit_right_bottom_bottom'].attributes.color_mode}}_color" : {{state_attr('light.unit_right_bottom',states['light.unit_right_bottom'].attributes.color_mode+'_color')}},
"brightness" : {{state_attr('light.unit_right_bottom','brightness')}}
}
mode: single
If the other light happens to be off, it won’t have a brightness attribute or any color-related attribute. The template should be designed to gracefully handle that possibility (otherwise it will fail with an error when it references a non-existent attribute).
This did it thank you - Its not a huge issue that it won’t do anything if the other light is off for me - would it crash out the automation and stop it doing other things to should it be OK in that respect?
It will generate an error message in the Log and terminate the automation at the failed action. It will also report an error if the target light’s state is unavailable.
Generally speaking, after you have created an automation that achieves your goal, you should consider all of the failure situations it may encounter and then enhance the automation to mitigate them. It’s the difference between what works well ‘all of the time’ versus ‘only under ideal conditions’.