Lux value wait_template in script

Hi,

I’ve tried various attempts to get the wait_template working in this script that turns all my house lights on a various light reading levels but no luck.

Could anyone advise on how i accomplish this please ?

house_lights_on:
  alias: Script House Lights On
  sequence:
  - data:
      brightness: 255
      color_temp: 370
      transition: 60
    entity_id: light.hall_table
    service_template: light.turn_on
  - wait_template: '{{ states.sensor.family_room_sensor_light_level.value|int < 115 }}'
  - data:
      brightness: 128
      color_temp: 370
      transition: 60
    entity_id: light.tv_table
    service_template: light.turn_on
  - wait_template: '{{ states.sensor.family_room_sensor_light_level.value|int < 65 }}'
  - data:
      brightness: 255
      color_temp: 370
      transition: 60
    entity_id: light.piano, light.desk, light.play_room_tv, light.breakfast_bar
    service_template: light.turn_on
  - data:
      brightness: 255
      color_temp: 370
      transition: 60
    entity_id: light.office
    service_template: light.turn_on
  - wait_template: '{{ states.sun.sun.attributes.elevation < -2 }}'
  - data:
      brightness: 255
      color_temp: 370
      transition: 30
    entity_id: light.front_door
    service_template: light.turn_on
  - condition: state
    entity_id: sensor.movie_lights_on_off
    state: 'off'
  - entity_id: switch.07371450840d8e42ead6_2
    service_template: switch.turn_on

I’m not sure I would do it this way, but I think maybe your main problem is .value should be .state.

thanks, will try that - what’s my best way to do this - happy to read up on things if you can offer some pointers at all ?

thanks a lot

In general, at least in my opinion, a long running script with a lot of waits is problematic. If HA restarts, or something tries to restart the script, etc., it won’t work as you expect.

Based on what you have, I’d just have four automations that trigger on the various events, with each running the action(s) for that event.

thanks, suppose that does simplify things somewhat and i know how to achieve that too !
thanks for the advise

1 Like