#Hey everyone, having a bit of an issue

1 messages · Page 1 of 1 (latest)

vital lake
#
alias: Hallway_LightsOff_Relay_01
description: >-
  Turns off the hallway ceiling lights when adjoining rooms have their lights
  turned off.
trigger:
  - platform: state
    entity_id: 
      - light.bedroom_lightgroup_room_01
      - light.office_lightgroup_room_01
      - light.hobbyroom_lightgroup_room_01
      - light.guestbathroom_lightgroup_room_01
    to: "off"
condition:
  - condition: state
    entity_id: 
      - light.bedroom_lightgroup_room_01
      - light.office_lightgroup_room_01
      - light.hobbyroom_lightgroup_room_01
      - light.guestbathroom_lightgroup_room_01
    state: "off"
action:
  - service: light.turn_off
    target:
      entity_id: light.hallway_lightgroup_ceiling_01
mode: single
#

That'll trigger when any of the lights is turned off, and then if all lights are off turn off the hallway one

near totem
#

Ok, that's what I thought should happen but for some reason, even if I manually turn off everything in those 4 rooms the hallway ceiling like still doesn't turn off and HA says the automation wasn't allowed to run even though the time pattern trigger works fine

summer hullBOT
#

To test an automation there's three stages you can follow. Testing the action, the condition and action, and the whole automation:

  1. Use Configuration -> Automations to find the automation and then select Run in the three dots menu. If this fails your problem is in the action: section, and details should be found in your log file
  2. Use Developer tools -> Services and call automation.trigger on the automation with skip_condition: false. If the first passes but this fails then the problem is in your condition: block
  3. Use Developer tools -> States to find the trigger entity, click the name, then change the state (at the top) to something that'll trigger the automation before pushing Set State. If this fails then the problem is with your trigger: section, or the automation is turned off (you can check that in Automations, automations that are turned off will show Disabled)

You can also see this section in the docs about testing and automation traces.

vital lake
#

Check the trace

near totem
#

Ahhh, never meesed with traces before

vital lake
#

They're awesome for debugging automations

near totem
#

Yea, this is the first one that's really had me need to go full debugging for

#

So I guess this means it's an issue with the conditions specifically

" Stopped because a condition failed at January 25, 2024 at 4:18:30 PM (runtime: 0.00 seconds) "

#

But I'll let your changes run for a little bit and make sure it's working and update here in a few moments

vital lake
#

That says that one of the lights wasn't off

#

Either on or unavailable

near totem
#

I figured it out, the automation was just fine, it was one of my helpers, specifically "light.guestbathroom_lightgroup_room_01" which is the only one that isn't just smart led light bulbs, it's actually a smart wall switch that I used a helper to make look like a light device to HA for automations since that's the only thing the switch controls. Well when that switch turns on it gives the "on" state and when it turns off it does not give the "off" state but instead gives the "unavailable" state and since the automation is looking specifically for the "off" state the condition is not met and the automation is stopped from triggering which leaves the light turned on even though all other lights are off.

vital lake
#
    state: 
      - "off"
      - "unavailable"
near totem
#

Changes made to solve:
change condition state for guestbathroom_lightgroup_room_01 from "off" to "unavailable"

#

Yup

#

Started working right away, thank you very much

vital lake
#

You want to do much the same for the trigger

near totem
#

Well the trigger is just a 30 second timer, entities are in the conditions

#

Unless you mean the motion trigger

vital lake
#

Yes, the trigger I wrote is more efficient

#
trigger:
  - platform: state
    entity_id: 
      - light.bedroom_lightgroup_room_01
      - light.office_lightgroup_room_01
      - light.hobbyroom_lightgroup_room_01
      - light.guestbathroom_lightgroup_room_01
    to:
      - "off"
      - "unavailable"
condition:
  - condition: state
    entity_id: 
      - light.bedroom_lightgroup_room_01
      - light.office_lightgroup_room_01
      - light.hobbyroom_lightgroup_room_01
      - light.guestbathroom_lightgroup_room_01
    state:
      - "off"
      - "unavailable"
near totem
#

Ahhhh, if you don't mind me asking what makes it more efficient, that it only triggers when those state change events happen compared to checking conditions every 30 seconds in mine?

vital lake
#

Yes

#

Time pattern triggers are sledgehammers

#

Sometimes they're the best solution, but they're often used to brute force stuff