jason0x43 / hacs-hubitat

A Hubitat integration for Home Assistant
MIT License
189 stars 46 forks source link

Some temperature sensors unit went from ºC to C after upgrade to Hubitat Integration v0.9.17 #242

Closed celticnestor closed 6 months ago

celticnestor commented 6 months ago

Hubitat Integration version: v0.9.17 Home Assistant Core version: 2023.12.1 Home Assistant Frontend version: 20231208.2

Issues started started after upgrading from few previous versions of Hubitat Integration, unclear how many.

This issue is reported on the Home Assistant log: 2024-01-03 14:21:44.059 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.temp_office (<class 'custom_components.hubitat.sensor.HubitatTemperatureSensor'>) is using native unit of measurement 'C' which is not a valid unit for the device class ('temperature') it is using; expected one of ['K', '°F', '°C']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/jason0x43/hacs-hubitat/issues

jason0x43 commented 6 months ago

I have a feeling I know what the issue is. Can you enable debug logging and record an event received from your sensor, or open the event log in Hubitat for the sensor and see what units it's using?

One of the recent changes to the integration is that it now pays attention to the units provided in temperature sensor update events. However, the integration assumes that sensor drivers are sending the units as °C and °F (which is how the Hubitat virtual temperature sensor behaves) rather than C and F. My guess is that your sensor's driver is using C and F (without the degree symbol). If that's the case, I'll just need to update the integration logic to account for that.

celticnestor commented 6 months ago

Thanks Jason for looking into this!

This is the Hubitat log, as you can see it reports in ºC: https://192.168.2.123/logs#2024-01-04 08:53:46.713 AM info https://192.168.2.123/logs# Multisensor office temperature is 21.4°C

Is there anything else I can help with?

jason0x43 commented 6 months ago

Hmmm... yeah, the real diagnosis would come from enabling debug logging for the integration and verifying what the sensor is actually sending to HA.

In the meantime, I'm going to assume the issue is that the unit being sent isn't in the expected format, and update the code to be a bit less trusting.

celticnestor commented 6 months ago

True.

From this log in Home Assistant, you are going to validate your assumption:

Logger: homeassistant.components.sensor Source: components/sensor/init.py:691 Integration: Sensor (documentation https://www.home-assistant.io/integrations/sensor, issues https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22 ) First occurred: 10:03:50 AM (2 occurrences) Last logged: 10:09:50 AM

jason0x43 commented 6 months ago

If you have debug logging enabled for the integration, the log will show exactly what what received from the hub, like

2024-01-04 15:41:41.221 DEBUG (MainThread) [custom_components.hubitat.hubitatmaker.hub] Received event: {'name': 'temperature', 'value': '72', 'displayName': 'Virtual Temperature Sensor', 'deviceId': '9', 'descriptionText': 'Virtual Temperature Sensor was set to 72°F', 'unit': '°F', 'type': None, 'data': None}
2024-01-04 15:41:41.225 DEBUG (MainThread) [custom_components.hubitat.hubitatmaker.hub] Updating temperature of 9 to 72 (°F)

It does look like that's the problem, though.

celticnestor commented 6 months ago

Thanks for referencing how to enable debug logging for the integration. Here is what I can see: 2024-01-04 11:07:50.131 DEBUG (MainThread) [custom_components.hubitat.hubitatmaker.hub] Received event: {'name': 'temperature', 'value': '21.7', 'displayName': 'Multisensor office', 'deviceId': '5', 'descriptionText': 'Multisensor office temperature is 21.7°C', 'unit': 'C', 'type': None, 'data': None} 2024-01-04 11:07:50.131 DEBUG (MainThread) [custom_components.hubitat.hubitatmaker.hub] Updating temperature of 5 to 21.7 (C)

jason0x43 commented 6 months ago

Excellent, that confirms my suspicion. Thanks!

celticnestor commented 6 months ago

You're welcome!

This is not an urgent required fix, but curious about when you are planning to push an updated version with the fix? If you need a tester, let me know.

On Thu, Jan 4, 2024 at 1:13 PM Jason Cheatham @.***> wrote:

Excellent, that confirms my suspicion. Thanks!

— Reply to this email directly, view it on GitHub https://github.com/jason0x43/hacs-hubitat/issues/242#issuecomment-1877550905, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI6Y2OI7TIEYZPTM67MF5EDYM3WM7AVCNFSM6AAAAABBL42EVCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZXGU2TAOJQGU . You are receiving this because you authored the thread.Message ID: @.***>

jason0x43 commented 6 months ago

This should be fixed in v0.9.18