home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.43k stars 30.66k forks source link

Can't trigger 2 automations with same trigger #93856

Closed shlosi closed 1 year ago

shlosi commented 1 year ago

The problem

I have 2 automations starting with same trigger. Only one of them works and the other is not. When disabling the first automation, the second one which was not executed before, now works fine.

What version of Home Assistant Core has the issue?

2023.5.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

frenck commented 1 year ago

Can you share the triggers/automations so we can try to reproduce the issue?

Thanks! 👍

../Frenck

home-assistant[bot] commented 1 year ago

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (automation) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `automation` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign automation` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


automation documentation automation source (message by IssueLinks)

shlosi commented 1 year ago

Of course.

This is the automation that works without issues:

alias: Kitchen Led
description: ""
trigger:
  - platform: state
    entity_id:
      - light.light_kitchen
    to: "on"
    id: Kitchen Light turned on
  - platform: state
    entity_id:
      - light.light_kitchen
    to: "off"
    id: Kitchen Light turned off
condition:
  - condition: time
    before: "20:00:00"
action:
  - choose:
      - conditions:
          - condition: trigger
            id: Kitchen Light turned on
        sequence:
          - type: turn_on
            device_id: 9a049735eba2e87cd4c4683656d126ec
            entity_id: switch.power_plug_kitchen_led_left_2
            domain: switch
          - type: turn_on
            device_id: 7a5b1614417436ea42a4ca6884584f2a
            entity_id: switch.power_plug_kitchen_led_right_2
            domain: switch
  - choose:
      - conditions:
          - condition: trigger
            id: Kitchen Light turned off
        sequence:
          - type: turn_off
            device_id: 9a049735eba2e87cd4c4683656d126ec
            entity_id: switch.power_plug_kitchen_led_left_2
            domain: switch
          - type: turn_off
            device_id: 7a5b1614417436ea42a4ca6884584f2a
            entity_id: switch.power_plug_kitchen_led_right_2
            domain: switch
mode: single

This is the one that does not work:

alias: Mosquitoes Lamp
description: ""
trigger:
  - platform: device
    type: turned_off
    device_id: 6ca7aafeabb587bbcaffb12eb53a02fd
    entity_id: switch.double_switch_2_2
    domain: switch
    id: Kitchen light turned off
  - platform: time
    at: "05:00:00"
    id: Time is 5:00
  - platform: device
    type: turned_on
    device_id: 6ca7aafeabb587bbcaffb12eb53a02fd
    entity_id: switch.double_switch_2_2
    domain: switch
    id: Kitchen light turned on
  - platform: time
    at: "19:00:00"
    id: Time is 19:00
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: Kitchen light turned off
        sequence:
          - if:
              - condition: time
                after: "20:00:00"
                before: "06:00:00"
            then:
              - type: turn_on
                device_id: a66bdeb16a94b9f3f8604c1951ac24f7
                entity_id: switch.power_plug_kitchen_2
                domain: switch
  - choose:
      - conditions:
          - condition: trigger
            id: Time is 5:00
        sequence:
          - type: turn_off
            device_id: a66bdeb16a94b9f3f8604c1951ac24f7
            entity_id: switch.power_plug_kitchen_2
            domain: switch
  - choose:
      - conditions:
          - condition: trigger
            id: Kitchen light turned on
        sequence:
          - if:
              - condition: time
                after: "20:00:00"
                before: "06:00:00"
            then:
              - type: turn_off
                device_id: a66bdeb16a94b9f3f8604c1951ac24f7
                entity_id: switch.power_plug_kitchen_2
                domain: switch
  - choose:
      - conditions:
          - condition: trigger
            id: Time is 19:00
        sequence:
          - if:
              - condition: state
                entity_id: switch.double_switch_2_2
                state: "off"
            then:
              - type: turn_on
                device_id: a66bdeb16a94b9f3f8604c1951ac24f7
                entity_id: switch.power_plug_kitchen_2
                domain: switch
mode: single
freeDom- commented 1 year ago

I have 2 automations starting with same trigger.

They do use different triggers.

The first uses state -> light on / off as trigger The second one uses device -> on / off as trigger

Not even the entity ids match.

First has light.light_kitchen Second one has switch.power_plug_kitchen_2

So I did not completely analyze the rest of your automation, but do not expect it to behave the same when it is actually different.

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.