Garage Door Hue Notification Light

Hi,
I am trying to update my hue light flashing red color while garage door is open but rules are not working. Any help appreciated.

I am using Opengarage for my garage door and Hue bridge with Hue color spot light at garage entry inside the house. Below is YAML code:

#Entry in configuration.yaml
input_boolean:
  awaymode:
    name: AwayMode
    initial: off
    icon: mdi:airplane-takeoff
  ha_node_primary_state:
    name: Master Status
    initial: on
    icon: mdi:crown
  hue_color_spot_1_state:
    name: GarageEntryHueState

#Rules in automation.yaml	
#Garage door open
- id: Alert_garage_door_open
  alias: Alert Garage Door Open
  trigger:
  - platform: state
    entity_id: sensor.garage_status
    from: 'Closed'
    to: 'Open'
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: input_boolean.awaymode
        state: 'off'
      - condition: state
        entity_id: input_boolean.ha_node_primary_state
        state: 'on'
  action:
  - service_template: '{% if states.light.hue_color_spot_1.state == "on" %}input_boolean.turn_on{% else %}input_boolean.turn_off{% endif %}'
    entity_id: input_boolean.hue_color_spot_1_state
  - service: light.turn_on
    entity_id: light.hue_color_spot_1
    data:
      brightness: 250
      rgb_color: [254,1,1]
      flash: long

#Disable Alerting when Garage door is Closed
- id: Disable_Alert_Garage_Door_Closed
  alias: Disable Alert Garage Door Closed
  trigger:
  - platform: state
    entity_id: sensor.garage_status
    from: 'Open'
    to: 'Closed'
    for:
      seconds: 30
  action:
  - service_template: '{% if states.input_boolean.hue_color_spot_1_state.state == "on" %}light.turn_on{% else %}light.turn_off{% endif %}'
    entity_id: light.hue_color_spot_1
    data:
      rgb_color: [255,241,224]

Are you sure the states of sensor.garage_status start with capital letters or are they really all lower case?

Also, this won’t work:

  action:
  - service_template: '{% if states.input_boolean.hue_color_spot_1_state.state == "on" %}light.turn_on{% else %}light.turn_off{% endif %}'
    entity_id: light.hue_color_spot_1
    data:
      rgb_color: [255,241,224]

because the light.turn_off service does not accept rgb_color.

You might be interested in a python_script I wrote that saves the state & attributes of lights and/or switches and will then later restore the them to the saved state. See:

If you think you’d like to use it, and if you have any questions, let me know.

Yes, sensor.garage_status is ‘Closed’ with capital C. I will give your Python script a try, my understanding of Python is very limited. My automaton script is not giving any error message because of rgb_color and should it at least turn on the Hue light?

Thank you for sharing your Python script.

If the light was on originally, then yes, it looks like both automations should turn it on (to the different brightness/color.) Have you tried turning the light on, then manually triggering the automations to see if at least the action parts do what you expect?

How do I trigger the automation manually? Rule status is already “on”.

I tried the above code by removing “data:” clause with no brightness and color but still doesn’t work.

Then I tried with your python file and the code now looks as below but still no luck:

#configuration.yaml ---------------------------
input_boolean:
  awaymode:
    name: AwayMode
    initial: off
    icon: mdi:airplane-takeoff
  ha_node_primary_state:
    name: Master Status
    initial: on
    icon: mdi:crown

#automations.yaml ----------------------
#Garage door open
- id: Alert_garage_door_open
  alias: Alert Garage Door Open
  trigger:
  - platform: state
    entity_id: sensor.garage_status
    from: 'Closed'
    to: 'Open'
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: input_boolean.awaymode
        state: 'off'
      - condition: state
        entity_id: input_boolean.ha_node_primary_state
        state: 'on'
  action:
  - service: script.turn_on
    entity_id: script.lights_on

#Disable Alerting when Garage door Closed
- id: Disable_Alert_Garage_Door_Closed
  alias: Disable Alert Garage Door Closed
  trigger:
  - platform: state
    entity_id: sensor.garage_status
    from: 'Open'
    to: 'Closed'
    for:
      seconds: 30
  action:
  - service: script.turn_on 
    entity_id: script.restore_lights

#scripts.yaml ----------------------------------------------------
  lights_on:
    alias: "Turn on a given selection of lights, saving current state"
    sequence:
      - service: python_script.light_store
        data:
          store_name: flash_store
          entity_id: light.hue_color_spot_1
      - service: homeassistant.turn_on
        data:
          entity_id: light.hue_color_spot_1
          brightness: 250
          rgb_color: [254,1,1]
          flash: long
  restore_lights:
    alias: "Restore saved lights to the way they were"
    sequence:
      - service: python_script.light_store
        data:
          store_name: flash_store
          operation: restore

If you click on the name of the automation a window like the following should pop up. Just click on the word TRIGGER.

image

You can also trigger a script if it’s shown in the frontend. You don’t even have to click on the name - it should either have a toggle (if the script contains any waits or delays) or an EXECUTE “button.” I’d try running the scripts manually, too, to see if they work.

After copying my light_store.py file into your <config>/python_scripts folder did you restart HA? Or, at least, did you invoke the python_script.reload service from the Services page?

Finally, I have been able to make it working with below code:

#Entry in configuration.yaml
input_boolean:
  awaymode:
    name: AwayMode
    initial: off
    icon: mdi:airplane-takeoff
  ha_node_primary_state:
    name: Master Status
    initial: on
    icon: mdi:crown
  hue_color_spot_1_state:
    name: GarageEntryHueState

#Rules in automation.yaml
#Garage door open
- id: Alert_garage_door_open
  alias: Alert Garage Door Open
  trigger:
  - platform: state
    entity_id: sensor.garage_door
    to: open
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: input_boolean.awaymode
        state: 'off'
      - condition: state
        entity_id: input_boolean.ha_node_primary_state
        state: 'on'
  action:
  - service_template: '{% if states.light.hue_color_spot_1.state == "on" %}input_boolean.turn_on{% else %}input_boolean.turn_off{% endif %}'
    entity_id: input_boolean.hue_color_spot_1_state
  - service: light.turn_on
    entity_id: light.hue_color_spot_1
    data:
      brightness: 250
      rgb_color: [255,77,136]

#Disable Alerting when Garage door is Closed
- id: Disable_Alert_Garage_Door_Closed
  alias: Disable Alert Garage Door Closed
  initial_state: 'on'
  trigger:
  - platform: state
    entity_id: sensor.garage_door
    to: closed
  action:
  - service: light.turn_on
    entity_id: light.hue_color_spot_1
    data:
      brightness: 255
      rgb_color: [228,195,129]
  - service_template: '{% if states.input_boolean.hue_color_spot_1_state.state == "on" %}light.turn_on{% else %}light.turn_off{% endif %}'
    entity_id: light.hue_color_spot_1
  - service: automation.turn_on
    entity_id: automation.garage_entry_motion_detected
  - service: persistent_notification.create
    data:
      message: 'Garage door is closed now!'
      notification_id: '0107'
      title: Alert
  - service: automation.turn_on
    entity_id: automation.garage_entry_motion_detected
  - service: automation.turn_on
    entity_id: automation.post_garage_entry_motion_turn_off_light

Please note input_boolean.hue_color_spot_1_state is ‘on’ when no one at home certain set of automation rules takes control and input_boolean.ha_node_primary_state is ‘on’ on primary node. Considering the instability in hassio, I am setting up two nodes one in primary and other one in standby mode and standby is expected to take control of environment when heart beat monitoring fails on primary node. So the flag input_boolean.ha_node_primary_state decides whether the automation rules condition will be true on primary or standby node and when set to ‘off’, none of the automation rule satisfies condition to ‘true’ and all automation rules remain disabled on the node.

input_boolean.hue_color_spot_1_state keeps track of previous state of light (on/off), I tried Phil’s script once was unsuccessful and would try it again as I need to retain other attributes of light.

Motion detection rules are turned off by weekly garbage schedule which uses the same garage entry light to turn to green or blue color based on the garbage collection type due on the specific day of week and light remains with the color until garage door is opened & closed for garbage disposal. Once door closes it enables those motion detection rules to normal state.

Special thanks to Phil who guided me to use manual trigger testing which was a functionality in HA but I did not know.