Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use async_write_ha_state() instead of async_update_ha_state() #152

Merged
merged 1 commit into from
May 10, 2023

Conversation

Chupaka
Copy link
Contributor

@Chupaka Chupaka commented May 9, 2023

Indeed, async_update_ha_state() without params simply calls async_write_ha_state(): https://github.com/home-assistant/core/blob/23e24d75dcaae04c888df37144e9f405f10014fa/homeassistant/helpers/entity.py#L562-L598

Closes #149

@ScratMan ScratMan merged commit 1c1b124 into ScratMan:master May 10, 2023
2 checks passed
@Chupaka Chupaka deleted the patch-1 branch May 10, 2023 18:57
@ScratMan ScratMan mentioned this pull request May 11, 2023
@Chupaka
Copy link
Contributor Author

Chupaka commented Jun 5, 2023

@ScratMan okay, now I tested this change and it fails :(

Jun 05 16:08:22 home-assistant hass[428768]: 2023-06-05 16:08:22.975 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Jun 05 16:08:22 home-assistant hass[428768]: Traceback (most recent call last):
Jun 05 16:08:22 home-assistant hass[428768]:   File "/home/homeassistant/.homeassistant/custom_components/smart_thermostat/climate.py", line 823, in _async_sensor_changed
Jun 05 16:08:22 home-assistant hass[428768]:     await self._async_control_heating(calc_pid=True)
Jun 05 16:08:22 home-assistant hass[428768]:   File "/home/homeassistant/.homeassistant/custom_components/smart_thermostat/climate.py", line 893, in _async_control_heating
Jun 05 16:08:22 home-assistant hass[428768]:     await self.async_write_ha_state()
Jun 05 16:08:22 home-assistant hass[428768]: TypeError: object NoneType can't be used in 'await' expression

While async_update_ha_state is defined as async, async_write_ha_state is not. Should we simply remove "await" keyword in front of async_write_ha_state?..

@ScratMan
Copy link
Owner

ScratMan commented Jun 5, 2023

Hi, yes, if there is no async in front of the definition, then the await should be removed when calling the method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warning in log file after update to Home Assistant 2023.5.0
2 participants