Closed CFFAA closed 3 weeks ago
You are not making it easy for me. No config, no debug logs. Obvious question, do you use power sensor functionality? Is is correctly named? Does it work? Check in HA what is the state of the power sensor entity.
Thanks for answer sorry about the lack of more context. Yes Im using the power sensor feature. All the power sensor entities works in HA
Maybe some of the power sensors I use are not available when HA recently started?
Got one climate entity configured for a broadlink:
And same AC controlled by the UFO-R11 using MQTT with a custom_climate file
And another AC controlled only with UFO-R11 with the same custom_climate file:
the problem is, that HA returned back to the SmartIR integration, that state object of the power sensor is 'None'. I can fix easily that this will not throw exceptions, but the problem is, that this should not happen. And we do not know the reason why it is happening.
Could you please try to reproduce the issue with:
debug log enabled - add this into HA configuration.yaml and restart HA
logger:
default: warning
logs:
custom_components.smartir.climate: debug
check what is the current state of the power sensor entity under 'Developed tools -> States'
Thanks for taking your time after adding the lines you suggested here is the results from the log:
2024-06-12 14:55:38.317 DEBUG (MainThread) [custom_components.smartir.climate] Setting up the SmartIR climate platform
2024-06-12 14:55:38.321 DEBUG (MainThread) [custom_components.smartir.climate] Setting up the SmartIR climate platform
2024-06-12 14:55:38.323 DEBUG (MainThread) [custom_components.smartir.climate] Setting up the SmartIR climate platform
2024-06-12 14:55:38.378 DEBUG (MainThread) [custom_components.smartir.climate] SmartIRClimate init started for device Salon AC LG supported models ['P12RK']
2024-06-12 14:55:38.380 DEBUG (MainThread) [custom_components.smartir.climate] async_added_to_hass
All the binary_sensors to manage the power sensor entity are off according to dev tools
Thank you, but I need the debug log after the exception appears... This seems to be only after startup.
I made again some tests deleting the part of the power sensor entity and with that no more errors are printed in the log, so I assume that the binary sensors are not ready yet when the component requires. As I said after HA started completely the smartIR entities worked as expected
Thank you for help. I now probably understand, what is going on. When SmartIR entity is registered to HA, it schedule run of the power sensor check routine in (by default) 10seconds.
Unfortunately this is not very scientific approach in some cases it can take longer for HA to register power sensor entity. And if after 10second entity is not registered the HA return None instead of expected state object. So I need to find best way how to schedule initial power sensor check (or check if it is really necessary...).
Ok, can you please edit climate.py a replace somewhere around line 723:
current_state = self.hass.states.get(self._power_sensor).state
by
current_state = getattr(self.hass.states.get(self._power_sensor), 'state', None)
you can also delete line around 263:
self._async_power_sensor_check_schedule(self._state)
Please restart HA and recheck, it should solve the issue. ;-)
After those changes no more Errors are shown in the log. Also the power sensor options worked as expected! thank you
Cool, thank you for testing. I will inherit proposed changes into new release ASAP.
Fixed in release 1.17.16, closing issue now.
Hi Recently installed version 1.17.15 Currently Running HA 2024.6.1
Devices working fine (all are UFO R11) but there are some errors in logs:
Logger: homeassistant Source: custom_components/smartir/climate.py:725 integration: smartir (documentation, issues) First occurred: 09:52:06 (3 occurrences) Last logged: 09:52:06
Error doing job: Exception in callback _run_async_call_action(, >) at /usr/src/homeassistant/homeassistant/helpers/event.py:1506 (None)
Error doing job: Exception in callback _run_async_call_action(, >) at /usr/src/homeassistant/homeassistant/helpers/event.py:1506 (None)
Error doing job: Exception in callback _run_async_call_action(, >) at /usr/src/homeassistant/homeassistant/helpers/event.py:1506 (None)
Traceback (most recent call last): File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1510, in _run_async_call_action hass.async_run_hass_job(job, time_tracker_utcnow()) File "/usr/src/homeassistant/homeassistant/core.py", line 936, in async_run_hass_job hassjob.target(*args) File "/config/custom_components/smartir/climate.py", line 725, in _async_power_sensor_check current_state = self.hass.states.get(self._power_sensor).state ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'state'