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

Automation entity state does not match actual state #121073

Open labatt opened 3 months ago

labatt commented 3 months ago

The problem

I have an automation that triggers when my phone goes to wireless charging. I just upgraded from 2023.12.2 to 2024.6.1 (and then 2024.6.4).

sensor.sm_g973u_charger_type changes to wireless when I'm using Developer Tools > State and view the state. It also shows correctly when I look in the mobile app settings.

However, within the automation, the same sensor shows as blank/none. The automation does correctly pick up the transition from discharging to charging and starts but the criteria that it needs to be set to wireless fails. This worked prior to the upgrade.

Not sure if it's a mobile app or core issue. I originally reported it as a mobile app issue, but since the mobile app reports the correct state (and the state info shows correct in the developer tools) I'm thinking it's something on the automation side instead.

This was the issue I opened up on the mobile app side: https://github.com/home-assistant/core/issues/119711

What version of Home Assistant Core has the issue?

core-2024.6.4

What was the last working version of Home Assistant Core?

core-2023-12.2

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Automation

Link to integration documentation on our website

https://www.home-assistant.io/integrations/device_automation/

Diagnostics information

None

Example YAML snippet

condition:
  - condition: and
    conditions:
      - condition: state
        state: wireless
        entity_id: sensor.sm_g973u_charger_type
        for:
          hours: 0
          minutes: 0
          seconds: 0
      - condition: state
        entity_id: switch.bedroom_fan
        state: 'off'
      - condition: time
        after: '23:00:00'
        before: '03:30:00'
        weekday:
          - sat
          - fri
          - thu
          - wed
          - tue
          - mon
          - sun

Anything in the logs that might be useful for us?

Chris Phone Charger Type changed to none
2:45:27 PM - 8 minutes ago
Chris Phone Is Charging was unplugged
2:45:27 PM - 8 minutes ago
Chris Phone Battery State changed to discharging
2:45:27 PM - 8 minutes ago
Chris Phone Charger Type changed to wireless
2:45:19 PM - 9 minutes ago
Chris Phone Is Charging was plugged in
2:45:19 PM - 9 minutes ago
Chris Phone Battery State changed to charging

Debug log:
2024-06-14 15:06:34.501 DEBUG (MainThread) [homeassistant.components.mobile_app.webhook] Received webhook payload from SM-G973U for type update_sensor_states: [{'unique_id': 'sleep_segment', 'state': 25920000.0, 'type': 'sensor', 'icon': 'mdi:sleep', 'attributes': {'end': 1718370223652, 'start': 1718344303652, 'status': 'successful'}}, {'unique_id': 'battery_level', 'state': 38, 'type': 'sensor', 'icon': 'mdi:battery-charging-30', 'attributes': {}}, {'unique_id': 'battery_state', 'state': 'charging', 'type': 'sensor', 'icon': 'mdi:battery-plus', 'attributes': {'options': ['charging', 'discharging', 'full', 'not_charging']}}, {'unique_id': 'is_charging', 'state': True, 'type': 'binary_sensor', 'icon': 'mdi:power-plug', 'attributes': {}}, {'unique_id': 'charger_type', 'state': 'wireless', 'type': 'sensor', 'icon': 'mdi:power-plug', 'attributes': {'options': ['ac', 'usb', 'wireless', 'dock', 'none']}}, {'unique_id': 'battery_temperature', 'state': 22.5, 'type': 'sensor', 'icon': 'mdi:battery', 'attributes': {}}, {'unique_id': 'battery_power', 'state': 0.0, 'type': 'sensor', 'icon': 'mdi:battery-minus', 'attributes': {'current': -0.000752,

Additional information

This is from the trace:

Executed: June 14, 2024 at 2:45:19 PM Result: result: false conditions/0 Executed: June 14, 2024 at 2:45:19 PM Result: result: false conditions/0/entity_id/0 Executed: June 14, 2024 at 2:45:19 PM Result: result: false state: none wanted_state: wireless

home-assistant[bot] commented 3 months ago

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

Code owner commands Code owners of `device_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 device_automation` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


device_automation documentation device_automation source (message by IssueLinks)

labatt commented 1 month ago

This has been open for over a month with nobody checking in. Is anyone maintaining this portion of the codebase?