Automation issues [SLOVED]

Hi,

I have an automation to turn on the lights when motion detected by my PIR sensor

and it looks like this:

- alias: Motion Light 
  initial_state: 'on'
  hide_entity: True
  trigger:
    platform: state
    entity_id: sensor.study_room_motion_sensor
    to: 'on'
  condition:
    - condition: state
      entity_id: group.g_shai_tracker
      state: home
    - condition: state
      entity_id: group.g_alina_tracker
      state: home
  action:
    service: switch.turn_on
    entity_id: switch.study_room_light

It seems that the automation works properly the real issue is that the light does not turn on (well…sometimes is turns on sometimes not)

I can see the switch turns yellow in the HASS frontend but the light doesn’t turns on, if i click it manually the light turns on

I dont see any errors in my log

Any idea why ?

Thanks.

What kind of switch is it? Is it 100% reliable when triggered manually?

It’s Broadlink TC2, Manually it works fine also from the HASS interface it truns on and off without any issues, the issue only happens with this automation

Can you see that the automation is triggering in your logbook?

Your condition statement is an and so group.g_shai_tracker and group.g_alina_tracker have to be home for it to fire. If any one of the devices within those groups has switched to not_home the entire group will be not home and the automation will not execute.

I know, the condition is met, i also tried removing the condition but still the same sometimes it works and sometimes not and i can see it in the logbook, I did several tests i turnd on twice when it tdetected motion the third time it didn’t no pattern…

What else is in your group.g_alina_tracker & group.g_shai_tracker?

I also don’t see quotes around your state. ‘home’

Not sure if that’s supposed to be an AND or an OR condition, but either way it doesn’t look formatted correctly.

Thanks, I added the quotes, but still the same i just walked around the pir detector 3 time the light didn’t turn on just at the fourth time, maybe it’s a network latency issue :confused:

I think it is equivalent to AND, the automation works, it turns the switch in the interface but not physically

Weird, because an AND condition is supposed to be formatted like this:

condition:
  condition: and
  conditions:
    - condition: state
      entity_id: 'group.g_shai_tracker'
      state: 'home'
    - condition: state
      entity_id: 'group.g_alina_tracker'
      state: 'home'

Review your logbook. You should see the PIR sensor turn on 4 times and the automation trigger 4 times. If the PIR sensor isn’t triggering each time you have a seperate issue and not an automation issue. If your PIR is triggering 4 times but the automation didn’t trigger 4 times there is something holding it up.

The logbook is very helpful when diagnosing automation issues, however, if not trimmed down it can be a lot to sift through to get the data you want.

The automation triggers every time, for some strange reason it seems to be working better and more stable now

Thanks for helping!

A single condition can be formatted like this.

  condition:
    - condition: state
      entity_id: group.g_shai_tracker
      state: 'home'

Maybe its working if that first condition is met.

I would try the proper and format.

2 Likes

Sorry, my mistake, It’s Equivalent to OR it’s met if one of the groups state is ‘home’

Damn, It’s not working again, Same issue, the automation trigger i see it in the HASS interface, when triggering it manually the light turns on :confused:

I still don’t see how you can format it the way you have and not get an error in the logs about it. If you are using a current build, it should be:

condition:
  condition: or
  conditions:
    - condition: state
      entity_id: 'group.g_shai_tracker'
      state: 'home'
    - condition: state
      entity_id: 'group.g_alina_tracker'
      state: 'home'

I can try it but it is not the problem, i see the trigger was executed, it’s like it doesn’t call the service

But it should generate an error without the proper formatting and I don’t understand why it isn’t. If it isn’t something is wrong as that formatting error should be excepted and caught. So that’s a bug for sure.

Remember there are three parts to this - the trigger, the conditions and the service. You can trigger it manually all day long, but if the conditions aren’t being met properly it won’t pass on to the trigger. So I think this could still be a contributing cause. Just sayin.

Again, I am personally more interested in why your formatting doesn’t generate an error. It should. And that is cause for a bug report IMO.

I tried your suggestion it works exactly the same as the syntax i used, the trigger triggers but it look like it doesn’t call the service the weird thing is when i manually click the automation trigger it executes and the light turns on

Just a thought - Check your sensor in dev states. Is it “on” or “On”? Case matters and I missed this once myself.

(I’m not giving up until you do. LOL Committed to helping you.)