sillyfrog / Automate-Pulse-v2

Rollease Acmeda Automate Pulse Hub v2 integration for Home Assistant
Apache License 2.0
37 stars 8 forks source link

2024.5.0 has partially broken integration - Detected that custom integration 'automate' calls async_write_ha_state from a thread #28

Closed lionslair closed 6 months ago

lionslair commented 7 months ago

It appears the latest release of home assistant has partially broken the integration.

Issues

Notes

Reloading the integration does allow the state to be re-detected and one action performed by groups.

Logs

Logger: homeassistant.helpers.frame
Source: helpers/frame.py:190
First occurred: 7:33:56 AM (104 occurrences)
Last logged: 7:39:56 AM

Detected that custom integration 'automate' calls async_write_ha_state from a thread at custom_components/automate/base.py, line 83: self.async_write_ha_state(), please report it to the author of the 'automate' custom integration
Logger: homeassistant
Source: helpers/frame.py:203
First occurred: 7:33:56 AM (104 occurrences)
Last logged: 7:39:56 AM

Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/automate/base.py", line 83, in notify_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1008, in async_write_ha_state
    self.hass.verify_event_loop_thread("async_write_ha_state")
  File "/usr/src/homeassistant/homeassistant/core.py", line 440, in verify_event_loop_thread
    frame.report(
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 162, in report
    _report_integration(what, integration_frame, level, error_if_integration)
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 203, in _report_integration
    raise RuntimeError(
RuntimeError: Detected that custom integration 'automate' calls async_write_ha_state from a thread at custom_components/automate/base.py, line 83: self.async_write_ha_state(). Please report it to the author of the 'automate' custom integration.

I have got around the issue until a fig with an automation to reload the entities on change

alias: TEMP reload blinds after change
description: blinds integration is stuck after change so auto reload
trigger:
  - platform: state
    entity_id:
      - cover.my_shade_9
      - cover.my_shade_8
      - cover.my_shade_13
      - cover.my_shade_10
      - cover.my_shade_11
      - cover.my_shade_12
      - cover.my_shade
      - cover.my_shade_2
      - cover.my_shade_3
      - cover.my_shade_4
      - cover.my_shade_5
      - cover.my_shade_6
    attribute: current_position
condition: []
action:
  - delay:
      hours: 0
      minutes: 0
      seconds: 30
      milliseconds: 0
  - service: homeassistant.reload_config_entry
    data: {}
    target:
      entity_id:
        - cover.my_shade_9
        - cover.my_shade_8
        - cover.my_shade_13
        - cover.my_shade_10
        - cover.my_shade_11
        - cover.my_shade_12
        - cover.my_shade
        - cover.my_shade_2
        - cover.my_shade_3
        - cover.my_shade_4
        - cover.my_shade_5
        - cover.my_shade_6
mode: single
axlback commented 7 months ago

I have the same issue

tpcarman commented 7 months ago

I'm brand new to the Pulse system, having had automated blinds installed yesterday, and I also have this issue.

I do not have a button to close blinds. The reading of the blind position is also inaccurate. My blinds are currently open, yet the HA device shows as closed.

lionslair commented 7 months ago

Found this. https://community.home-assistant.io/t/how-to-fix-custom-integration-brematic-calls-async-write-ha-state/722238/2

I can make a PR for this fix.

tpcarman commented 6 months ago

Thanks @lionslair. I implemented the change in PR #29 and it is working as expected.

lionslair commented 6 months ago

Thanks @lionslair. I implemented the change in PR #29 and it is working as expected.

Has worked for me all day too

tpcarman commented 6 months ago

@lionslair How do you group blinds?

sillyfrog commented 6 months ago

Sorry for the delay, been flat out with work.

The latest release v0.9.10 now addresses this.

lionslair commented 6 months ago

@lionslair How do you group blinds?

I use groups under helpers to group bedroom, living, kids, all

I then have automations that call those helpers at different times not open and close