vpathuis / ultraheat

MIT License
5 stars 3 forks source link

Changes to the API for better integration with Home Assistant #3

Closed vpathuis closed 2 years ago

robbinonline commented 2 years ago

Is there already some progress to test /integrate with Home Assistant?

vpathuis commented 2 years ago

Hi @robbinonline, yes there is some. Please have a look at https://github.com/home-assistant/core/pull/73363 if you want to follow or contribute :)

robbinonline commented 2 years ago

@vpathuis Nice!! For now i installed as a custom component and it works awesome!

vpathuis commented 2 years ago

That's great! Let me know if you stumble onto something, or have some requests.

robbinonline commented 2 years ago

@vpathuis

Ik heb regelmatig een foutmelding:

` Update for sensor.heat_meter_heat_usage_gj fails

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 514, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 709, in async_device_update raise exc File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 350, in async_update await self.coordinator.async_request_refresh() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 158, in async_request_refresh await self._debounced_refresh.async_call() File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 78, in async_call await task File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 182, in async_refresh await self._async_refresh(log_failures=True) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh self.async_update_listeners() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 110, in async_update_listeners update_callback() File "/config/custom_components/landisgyr_heat_meter/sensor.py", line 88, in _handle_coordinator_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 532, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 570, in _async_write_ha_state state = self._stringify_state(available) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 538, in _stringify_state if (state := self.state) is None: File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 398, in state raise ValueError(

ValueError: Invalid datetime: sensor.heat_meter_meter_date_time provides state '2022-07-30 12:53:09', which is missing timezone information `

vpathuis commented 2 years ago

@robbinonline thanks for reporting. I'll have a look asap, although I'm in the middle of nowhere atm without proper internet. If you have more info on the when/how, could possibly be of help.

vpathuis commented 2 years ago

@robbinonline I have solved this in the commit of yesterday (https://github.com/home-assistant/core/pull/73363). I think something changed in the last version that made specifying time zones more strict than before.

If you find more, or have any suggestions for improvement, feel free to use the issues. That way I could link issues and commits in the future.

robbinonline commented 2 years ago

@vpathuis It looks like the error is gone. Only since that version there is no data in the enegery dashboard anymore. The sensor looks fine.

Scherm­afbeelding 2022-08-13 om 14 49 54
vpathuis commented 2 years ago

@robbinonline how did you add it to the dashboard? I had to change GJ to MWh and remove GJ as a energy sensor. MWh should work with Gas, now that another pr is released in 2022.8. Using m3 could work I guess, but do you have a consistent price per m3?

Could you also check Dev options > statistics, to see if there are warnings/errors there? This part is tricky to test, so thank you!

robbinonline commented 2 years ago

I used the m3 sensor not the GJ that one stoped working after the timezone update.

robbinonline commented 2 years ago

I found out the update left some old sensors, I now use: sensor.heat_meter_volume_usage that works again in the engery dashboard.

vpathuis commented 2 years ago

Great. Yeah, the some changes were needed for the PR that were not backwards compatible, unfortunately. It can help to delete the integration and re-add it. It should preserve statistics but give you a clean start on the entities.

robbinonline commented 2 years ago

@vpathuis Hi, after updating to 2022.9 and remove the custom component and I want to add it the official way I get this error:

Error This integration does not support configuration via the UI. If you followed this link from the Home Assistant website, make sure you run the latest version of Home Assistant.

vpathuis commented 2 years ago

Hi @robbinonline , that's strange. I've also upgraded myself and didn't have this problem. Could you send me some logging? It's not necessary to remove the integration by the way. If all works fine, it will understand the new official integration after removing the custom component and restarting. But perhaps something went wrong because you had the beta ...