I’m stumbling my way though setting up some automated lights, I managed to build a set of Automations that do what I need them to, but then I realized I’m going to be making duplicates of all of those automations for each of my different rooms, so I started looking into scripts, and I’m trying to pass in the relevant switch as a parameter (basically the light.light_name device).
I figured out how to check the basic state using the value template and my field:
- if:
- condition: template
value_template: "{{ is_state(var_lightswitch, 'on') }}"
alias: If var_lightswitch is ON
However now I’m struggling to figure out how to set a condition so that it will only run if the light (represented by the var_lightswitch parameter) has been on for over 2 seconds. I have this YAML from the working Automation, but I can’t figure out how I would turn it into a condition in my script that can take a field as a parameter
- condition: device
type: is_on
device_id: 8b0a28328acd1f1369c8b77b7aaed69f
entity_id: afa23799d89afd7723fc19b85ceae1ba
domain: light
for:
hours: 0
minutes: 0
seconds: 2
If it makes any difference, these are Inovelli Red switches… I’m also curious if there’s some sort of console somewhere that I can use for quickly testing out all of the “state_attr” commands and the like with intellisense, because I have no idea what these objects look like under the hood. I found the Developer Tools > States screen, which is helpful, but nothing there seems to tell me when the light was last turned on… I’m guessing because it’s stored elsewhere, but I have zero idea how to even begin tracking that down.
3 posts - 3 participants