RobertD502 / home-assistant-flair

Custom component for Home Assistant Core for Flair pucks, vents, rooms, structures, and minisplits
MIT License
87 stars 12 forks source link

HVAC units reporting absurd temperature #46

Closed shauntarves closed 1 year ago

shauntarves commented 1 year ago

Hi Robert,

I was finally able to get Flair support to resolve the missing temperature scale on my pucks so they are appearing in HA, however, as you can see in the screenshots below, the reported temperatures are all out-of-whack. Any ideas?

Screen Shot 2023-01-06 at 8 21 10 AM Screen Shot 2023-01-06 at 8 23 35 AM Screen Shot 2023-01-06 at 8 23 42 AM
RobertD502 commented 1 year ago

That is pretty out of whack. Can you manually run the flairaio backend to fetch all the data?

I'll need to take a look at the data returned for all of those mini splits as well as the data for the rooms associated with the units.

Edit: Also, what units is your Home Assistant set to and what version are you running?

shauntarves commented 1 year ago

I ran the flairaio backend manually and there seems to be a discrepancy in temperature scale.

The structure has 'temperature-scale': 'F' but the HVAC unit is reporting 'temperature-scale': 'C' in its codesets.

Some logging output pasted below:

#### STRUCTURE ####
Structures(structures={'3379': Structure(id='3379', attributes={'longitude': None, 'current-dr-state': None, 'preheat-precool': True, 'home-away-mode': 'Flair Autohome Autoaway', 'frozen-pipe-pet-protect': True, 'dr-program-signup-in-progress': False, 'updated-at': '2023-01-06T23:03:25.438222+00:00', 'structure-away-mode': 'Off Only', 'active-schedule-id': None, 'backpressure-priority': 'Prioritize Active Rooms', 'setup-mode-first-time': True, 'temp-away-min-c': 17.0, 'zip-code': None, 'puck-client-secret': '<REDACTED>', 'use-single-set-point': None, 'dr-event-string': None, 'state': None, 'dr-program-active': False, 'location-type': None, 'dr-end-time': None, 'structure-heat-cool-mode': 'auto', 'structure-heat-cool-mode-calculated': None, 'licensed-features': [], 'setup-step': 'step-five-puck', 'hvac-unit-group-lock': True, 'set-point-mode': 'Home Evenness For Active Rooms Flair Setpoint', 'dr-start-time': None, 'temp-away-max-c': 25.0, 'temperature-scale': 'F', 'release-channel': 'production', 'hysteresis-room-sense': None, 'tombstone': False, 'dr-program-enrollment-meta': None, 'state-updated-at': '2023-01-01T18:45:54.834889+00:00', 'hysteresis-heat-cool-mode': None, 'name': 'Our Crib', 'setup-complete': True, 'humidity-away-min': 10, 'structure-heat-cool-mode-popup-resolved-at': None, 'city': None, 'hold-reason': None, 'dr-program-enrolled': False, 'reporting-gateway': True, 'created-at': '2017-12-28T14:11:56.954484+00:00', 'hold-until': None, 'latitude': None, 'time-zone': 'America/New_York', 'setup-mode': False, 'set-point-temperature-c': 20.45, 'default-hold-duration': '3h', 'country': 'US', 'mode': 'manual', 'home': True, 'structure-type': None, 'is-active': True, 'hysteresis-b': None, 'humidity-away-max': 80, 'hysteresis-a': 50, 'location': None, 'hold-until-schedule-event': False, 'use-remote-sensor-occupancy': None, 'puck-client-id': '<REDACTED>'}, relationships={'plug-invites': {'links': {'self': '/api/structures/3379/relationships/plug-invites', 'related': '/api/structures/3379/plug-invites'}}, 'hvac-units': {'links': {'self': '/api/structures/3379/relationships/hvac-units', 'related': '/api/structures/3379/hvac-units'}}, 'remote-sensors': {'links': {'self': '/api/structures/3379/relationships/remote-sensors', 'related': '/api/structures/3379/remote-sensors'}}, 'thermostats': {'links': {'self': '/api/structures/3379/relationships/thermostats', 'related': '/api/structures/3379/thermostats'}}, 'release-approvals': {'links': {'related': '/api/structures/3379/release-approvals'}}, 'current-weather': {'links': {'related': '/api/structures/3379/current-weather'}}, 'current-conclusions': {'links': {'related': '/api/structures/3379/current-conclusions'}}, 'occupancy-conclusions': {'links': {'related': '/api/structures/3379/occupancy-conclusions'}}, 'integration-structures': {'links': {'self': '/api/structures/3379/relationships/integration-structures', 'related': '/api/structures/3379/integration-structures'}}, 'demand-response-program-enrollments': {'links': {'self': '/api/structures/3379/relationships/demand-response-program-enrollments', 'related': '/api/structures/3379/demand-response-program-enrollments'}, 'data': []}, 'structure-states': {'links': {'related': '/api/structures/3379/structure-states'}}, 'rooms': {'links': {'self': '/api/structures/3379/relationships/rooms', 'related': '/api/structures/3379/rooms'}}, 'zones': {'links': {'self': '/api/structures/3379/relationships/zones', 'related': '/api/structures/3379/zones'}}, 'schedules': {'links': {'self': '/api/structures/3379/relationships/schedules', 'related': '/api/structures/3379/schedules'}}, 'plugs': {'links': {'self': '/api/structures/3379/relationships/plugs', 'related': '/api/structures/3379/plugs'}}, 'weather-readings': {'links': {'related': '/api/structures/3379/weather-readings'}}, 'default-zone': {'links': {'self': '/api/structures/3379/relationships/default-zone', 'related': '/api/structures/3379/default-zone'}}, 'vents': {'links': {'self': '/api/structures/3379/relationships/vents', 'related': '/api/structures/3379/vents'}}, 'supported-device-brands': {'links': {'related': '/api/structures/3379/supported-device-brands'}}, 'invitations': {'links': {'self': '/api/structures/3379/relationships/invitations', 'related': '/api/structures/3379/invitations'}}, 'geofence-events': {'links': {'self': '/api/structures/3379/relationships/geofence-events', 'related': '/api/structures/3379/geofence-events'}}, 'editor-users': {'links': {'self': '/api/structures/3379/relationships/editor-users', 'related': '/api/structures/3379/editor-users'}}, 'viewer-users': {'links': {'self': '/api/structures/3379/relationships/viewer-users', 'related': '/api/structures/3379/viewer-users'}}, 'geofences': {'links': {'self': '/api/structures/3379/relationships/geofences', 'related': '/api/structures/3379/geofences'}}, 'hvac-unit-groups': {'links': {'self': '/api/structures/3379/relationships/hvac-unit-groups', 'related': '/api/structures/3379/hvac-unit-groups'}}, 'bridges': {'links': {'self': '/api/structures/3379/relationships/bridges', 'related': '/api/structures/3379/bridges'}}, 'active-schedule': {'links': {'self': '/api/structures/3379/relationships/active-schedule', 'related': '/api/structures/3379/active-schedule'}, 'data': None}, 'pucks': {'links': {'self': '/api/structures/3379/relationships/pucks', 'related': '/api/structures/3379/pucks'}}, 'releases': {'links': {'self': '/api/structures/3379/relationships/releases', 'related': '/api/structures/3379/releases'}}, 'licenses': {'links': {'self': '/api/structures/3379/relationships/licenses', 'related': '/api/structures/3379/licenses'}}, 'ui-notifications': {'links': {'self': '/api/structures/3379/relationships/ui-notifications', 'related': '/api/structures/3379/ui-notifications'}}, 'alerts': {'links': {'related': '/api/structures/3379/alerts'}}, 'beacon-sightings': {'links': {'self': '/api/structures/3379/relationships/beacon-sightings', 'related': '/api/structures/3379/beacon-sightings'}}, 'current-state': {'links': {'related': '/api/structures/3379/current-state'}, 'data': {'type': 'structure-states', 'id': '72decf6b-4452-4543-9a7e-947d6f9c6117'}}, 'admin-users': {'links': {'self': '/api/structures/3379/relationships/admin-users', 'related': '/api/structures/3379/admin-users'}}, 'demand-response-program-eligibility': {'links': {'self': '/api/structures/3379/relationships/demand-response-program-eligibility', 'related': '/api/structures/3379/demand-response-program-eligibility'}, 'data': {'type': 'demand-response-program-eligibilities', 'id': '3379'}}}, rooms='Not Fetched', pucks='Not Fetched', vents='Not Fetched', thermostats='Not Fetched', hvac_units='Not Fetched', zones='Not Fetched', schedules='Not Fetched')})

#### ROOM ####
{'humidity-away-min': 10, 'current-humidity': 42.0, 'preheat-precool': True, 'state-updated-at': '2023-01-03T13:52:07.691272+00:00', 'name': 'Living Room', 'temp-away-min-c': 16.0, 'heat-cool-mode': 'FLOAT', 'occupancy-mode': 'Flair Auto', 'active': True, 'set-point-c': 21.12, 'room-type': None, 'hold-until-schedule-event': False, 'humidity-away-max': 80, 'created-at': '2021-12-26T20:39:36.746427+00:00', 'air-return': False, 'hold-reason': 'PuckActivity', 'current-temperature-c': 18.85, 'hold-until': None, 'temp-away-max-c': 22.5, 'level': None, 'frozen-pipe-pet-protect': True, 'pucks-inactive': 'Active', 'windows': None, 'room-away-mode': 'Smart Away', 'updated-at': '2023-01-03T13:52:07.698129+00:00', 'set-point-manual': False}

#### PUCK ####
{'temperature-offset-c': None, 'current-temperature-c': 18.85, 'bluetooth-tx-power-mw': 500, 'created-at': '2021-12-26T20:31:38.506813+00:00', 'updated-at': '2023-01-06T23:02:37.727646+00:00', 'inactive': False, 'is-gateway': False, 'oauth-app-assigned-at': None, 'ignore-readings-for-room': False, 'setpoint-bound-low': 18.89, 'demo-mode': 0, 'voltage': 2.75, 'display-number': '7689', 'ir-setup-enabled': None, 'current-rssi': -74.0, 'ir-download': False, 'sub-ghz-radio-tx-power-mw': None, 'last-reported-as-gateway': False, 'current-humidity': 42.0, 'temperature-offset-override-c': None, 'name': 'Living Room-7689', 'beacon-interval-ms': 4095, 'locked': False, 'puck-display-color': 'white', 'setpoint-bound-high': 24.45, 'orientation': 'standing', 'humidity-offset': None, 'reporting-interval-ds': 255, 'features': None}

#### HVAC ####
{'mode': 'Heat', 'quiet-hours-end': None, 'dr-start-time': None, 'codesets': [{'id': 3, 'codeset-id': '821', 'capabilities': 'Both', 'rank': 2, 'temperature-scale': 'C'}], 'ir-device-model-id': None, 'fan-speed': 'Auto', 'dr-end-time': None, '-temperature-compensation-limit-c': 300, 'is-wifi-enabled': False, 'codeset-id': '821', 'temperature-compensation-interval-minutes': 15, 'quiet-hours-start': None, 'name': 'Living Room Unit', 'type': 'MiniSplit', 'to-download': False, 'model-id': 'b8d96423-fbe4-4fcf-8352-d20eefb1287d', 'created-at': '2023-01-01T18:45:47.611290+00:00', 'make-id': '3f6b4204-b4e8-4f41-89e4-7ae7950a57b8', 'incremental': False, 'constraints': {'ON': {'DRY': {'ON': {'FAN AUTO': ['25']}, 'OFF': {'FAN AUTO': ['25']}}, 'FAN': {'ON': {'FAN AUTO': ['25']}, 'OFF': {'FAN AUTO': ['25']}}, 'AUTO': {'ON': {'FAN AUTO': ['25']}, 'OFF': {'FAN AUTO': ['25']}}, 'COOL': {'ON': {'FAN HI': ['18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30'], 'FAN LOW': ['18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30'], 'FAN MID': ['18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30'], 'FAN AUTO': ['18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30']}, 'OFF': {'FAN HI': ['18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30'], 'FAN LOW': ['18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30'], 'FAN MID': ['18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30'], 'FAN AUTO': ['25', '18', '19', '20', '21', '22', '23', '24', '26', '27', '28', '29', '30']}}, 'HEAT': {'ON': {'FAN HI': ['16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30'], 'FAN LOW': ['16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30'], 'FAN MID': ['16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30'], 'FAN AUTO': ['16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30']}, 'OFF': {'FAN HI': ['16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30'], 'FAN LOW': ['16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30'], 'FAN MID': ['16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30'], 'FAN AUTO': ['25', '16', '17', '18', '19', '20', '21', '22', '23', '24', '26', '27', '28', '29', '30']}}}, 'OFF': {'COOL': {'ON': {'FAN AUTO': ['25']}, 'OFF': {'FAN AUTO': ['25']}}}}, 'swing': 'On', 'swing-auto': True, 'updated-at': '2023-01-06T22:58:31.907328+00:00', 'allowed-range': 300, 'default-fan-speed': 'AUTO', 'button-presses': [], 'capabilities': 'Both', 'temperature-compensation': 'THIRD PARTY', 'temperature': 21, 'power': 'On', 'user-selected-make-id': '3f6b4204-b4e8-4f41-89e4-7ae7950a57b8', 'current-dr-state': None, 'make-name': 'FUJITSU'}
RobertD502 commented 1 year ago

Thank you for bringing this to my attention.

Keeping track of the different temp scales within Flair's system ended up causing me to miss a flaw in my logic when reporting current temperature for HVAC units.

I set the HVAC climate entity unit of measurement based on the temp scale reported by Flair since the target_temperature, as reported by the HVAC unit, is also based on said scale.

Depending on if the Flair structure is in auto mode or manual mode, the temp that is being sent to Flair could differ from this scale. If in auto mode, then the desired target_temp is actually being sent to the room endpoint the HVAC unit is in and not the HVAC unit itself. This temp always has to be in celsius so I have to check if the unit of measurement being reported to HA is in celsius and if not convert what HA plans on sending before it is actually sent.

If the structure is in manual mode then it is fairly easy as the scale of the target_temp is equivalent to the scale of the HVAC unit itself. In this scenario, the target_temp is being sent to the HVAC unit and not the room so no conversion problems.

The current_temperature being returned by the climate entity is actually the current temp of the room that the HVAC unit is in and not just of the Puck that is controlling the HVAC unit. I did this because some users have multiple sensors within a room.

As you can see, there are a lot of unit of measurement changes that I had to keep track of here, which resulted me missing crucial logic for users, such as yourself, where HA is in Fahrenheit, but the scale being reported by the HVAC unit is in Celsius.

The Cause of your problems: I mistakingly checked if HA is set to Celsius and returned the temp as reported by Flair (which is always in Celsius for room temps). If not, then the temp reported by Flair is converted to Fahrenheit. This is where things went wrong. For HA users in Fahrenheit and with HVAC units with a temp scale of Fahrenheit, the temp being reported by Flair would get converted Fahrenheit. Since the unit of measurement for the Climate entity is Fahrenheit, HA does no further conversion.

In your case, the temp being reported by Flair gets converted to Fahrenheit (since your HA is not set to Celsius). However, with the temp scale being reported by your HVAC unit as C, HA thinks that it needs to convert the temp I had already converted from C to F, but is in reality converting Fahrenheit to Fahrenheit. What you end up with is outrageously whacky high current temp readings.

Solution: I just released 0.1.8 as a pre-release. If you enable "show beta versions" in HACS you should be able to download the release.

If you download it, could you please report back if the current temp reading has been fixed.

Once confirmed, I will mark it as a regular release.

shauntarves commented 1 year ago

Hmmm...I enabled the beta channel, did the upgrade to 0.1.8, and restarted HA. That's where things got weird. For one of my devices (the gateway puck), your fix worked and the reported temperature looked correct. However, my other 2 pucks no longer appeared, and I got the dreaded "xxx does not have a temperature scale."

I confirmed via flairaio that the devices do, indeed, still have the temperature scale. So at that point, I disabled beta and redownloaded 0.1.7, restarted HA, AND AM STILL HAVING THE SAME PROBLEM!

Devices are showing as no longer provided by the integration (see screenshot).

Screen Shot 2023-01-07 at 9 21 41 AM

I did try enabling debug logging via the integration and performing another reload of the integration, so I have a big log file if you're interested. I don't want to upload it here because scrubbing creds seems like a nightmare in such a lot of output. If you want it, email me at shaun <at> tarves <dot> net and I'll send it to you.

RobertD502 commented 1 year ago

Something must have gone wrong because I only changed two lines of code related to current_temp and setting target temp.

Try going into HACS, go to the Flair integration, click on the overflow menu (upper right hand), select redownload, and pick 0.1.8 to download. After that, delete the Flair integration from the Home Assistant integrations screen. Restart Home Assistant and add the Flair integration again.

shauntarves commented 1 year ago

I followed these instructions and when I re-added the Flair integration, only the single HVAC unit that was working before was found. The others produced those same log messages as before:

2023-01-07 11:05:49.477 ERROR (MainThread) [custom_components.flair] Flair HVAC Unit Living Room Unit does not have a temperature scale.
Contact Flair customer support to get this fixed.
2023-01-07 11:05:49.520 ERROR (MainThread) [custom_components.flair] Flair HVAC Unit Kitchen Unit does not have a temperature scale.
Contact Flair customer support to get this fixed.
2023-01-07 11:05:49.525 ERROR (MainThread) [custom_components.flair] Flair HVAC Unit Living Room Unit does not have a temperature scale.
Contact Flair customer support to get this fixed.
2023-01-07 11:05:49.532 ERROR (MainThread) [custom_components.flair] Flair HVAC Unit Kitchen Unit does not have a temperature scale.
Contact Flair customer support to get this fixed.
RobertD502 commented 1 year ago

Email sent!

RobertD502 commented 1 year ago

Fixed in 0.1.8.1