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
71.93k stars 30.15k forks source link

Building block in automation broken after 2024.4.0 update #114927

Closed sippe2 closed 2 months ago

sippe2 commented 6 months ago

The problem

I don't know if it's just me...

I have an automation rule that has been working for years but after the last update it stopped working. It would seem that the buildin block seems to be working incorrectly despite the fact that the rules go through and they have worked completely flawlessly in the past. Is the automation yaml handling changed or is this some kind bug?

automation_trace

What version of Home Assistant Core has the issue?

2024.4.0

What was the last working version of Home Assistant Core?

2024.3.3

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

alias: Nordpool --- boiler (Off to On rules)
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.modebot_boiler
    from: "0"
    to: "1"
  - platform: state
    entity_id:
      - input_boolean.np_automation_boiler
    from: "off"
    to: "on"
  - platform: event
    event_type: timer.started
    event_data:
      entity_id: timer.np_override_counter
    context: {}
  - platform: state
    entity_id:
      - input_boolean.np_override_boiler
    from: "off"
    to: "on"
  - platform: state
    entity_id:
      - input_boolean.heating_at_home
    from: "off"
    to: "on"
condition:
  - condition: or
    conditions:
      - condition: and
        conditions:
          - condition: state
            entity_id: input_boolean.np_override_enable_schedule
            state: "off"
          - condition: state
            entity_id: input_boolean.np_override_boiler
            state: "on"
          - condition: state
            entity_id: input_boolean.np_override_activate
            state: "on"
          - condition: state
            entity_id: timer.np_override_counter
            state: active
        enabled: true
      - condition: and
        conditions:
          - condition: state
            entity_id: input_boolean.heating_at_home
            state: "on"
          - condition: state
            state: "1"
            entity_id: sensor.modebot_boiler
          - condition: state
            entity_id: input_boolean.np_automation_boiler
            state: "on"
        enabled: true
      - condition: and
        conditions:
          - condition: state
            entity_id: input_boolean.np_override_enable_schedule
            state: "on"
          - condition: state
            entity_id: input_boolean.np_override_boiler
            state: "on"
          - condition: state
            entity_id: input_boolean.np_override_activate
            state: "on"
          - condition: state
            entity_id: timer.np_override_counter
            state: active
        enabled: true
    enabled: true
action:
  - delay:
      milliseconds: "{{ range(0, 3000)|random|int }}"
    enabled: true
  - service: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: switch.smart_plug_piilonsuo_socket_1
mode: single

Anything in the logs that might be useful for us?

Executed: April 5, 2024 at 11:40:17
Result:
result: false
conditions/0
Executed: April 5, 2024 at 11:40:17
Result:
result: false
conditions/0/conditions/0
Executed: April 5, 2024 at 11:40:17
Result:
result: true
conditions/0/conditions/0/entity_id/0
Executed: April 5, 2024 at 11:40:17
Result:
result: true
state: 'off'
wanted_state: 'off'
conditions/0/conditions/1
Executed: April 5, 2024 at 11:40:17
Result:
result: true
conditions/0/conditions/1/entity_id/0
Executed: April 5, 2024 at 11:40:17
Result:
result: true
state: 'on'
wanted_state: 'on'
conditions/0/conditions/2
Executed: April 5, 2024 at 11:40:17
Result:
result: true
conditions/0/conditions/2/entity_id/0
Executed: April 5, 2024 at 11:40:17
Result:
result: true
state: 'on'
wanted_state: 'on'
conditions/0/conditions/3
Executed: April 5, 2024 at 11:40:17
Result:
result: false
conditions/0/conditions/3/entity_id/0
Executed: April 5, 2024 at 11:40:17
Result:
result: false
state: idle
wanted_state: active
conditions/1
Executed: April 5, 2024 at 11:40:17
Result:
result: false
conditions/1/conditions/0
Executed: April 5, 2024 at 11:40:17
Result:
result: true
conditions/1/conditions/0/entity_id/0
Executed: April 5, 2024 at 11:40:17
Result:
result: true
state: 'on'
wanted_state: 'on'
conditions/1/conditions/1
Executed: April 5, 2024 at 11:40:17
Result:
result: false
conditions/1/conditions/1/entity_id/0
Executed: April 5, 2024 at 11:40:17
Result:
result: false
state: '0'
wanted_state: '1'
conditions/2
Executed: April 5, 2024 at 11:40:17
Result:
result: false
conditions/2/conditions/0
Executed: April 5, 2024 at 11:40:17
Result:
result: false
conditions/2/conditions/0/entity_id/0
Executed: April 5, 2024 at 11:40:17
Result:
result: false
state: 'off'
wanted_state: 'on'

Additional information

This worked years before update.

joostlek commented 6 months ago

Can we boil this down to a small reproducable automation?

sippe2 commented 6 months ago

Actually I found the possible reason. (Work around was to change sensor type to binary_sensor and use on/off states.)

reason

So... This is my guess. If I try something against a numeric value, the building block apparently breaks into it.

sippe2 commented 6 months ago

Mkay. Here is is what I found more

As we can see the condition block passes:

timer_pass

The yaml looks ok for me:

timer_code

But when the trigger event happens the condition block fails:

timer_traces

And here is the reason:

after activate trigger timer state

I suppose the reason is timing. When event is triggered timer is still idle and that is the major problem to solve somehow.

issue-triage-workflows[bot] commented 3 months 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.