Skip to content

Conversation

@emoses
Copy link

@emoses emoses commented Mar 27, 2023

I'm using FGLair-us with HA. Even though my thermostats display in F, I have to set the temp_type to C to have anything function properly. It appears that the actual adjust_temperature commands that the wifi units accept must be in increments of 0.5 C, but when I change the temperature in F in HA, AirCon currenly rounds to the nearest degree C, which means many temperature adjustments are no-ops (e.g. 70F to 69F results in no change, they both round to 21C).

Here's an example log:

hisense_ac    | I0327 04:41:57.734  mqtt_client.py:37] MQTT message Topic: hisense_ac/[redacted]/adjust_temperature/command, Payload b'20.555555555555554'
hisense_ac    | I0327 04:41:57.749  web_log.py:206] 192.168.2.161 [27/Mar/2023:04:41:57 +0000] "GET /local_lan/commands.json HTTP/1.1" 200 418 "-" "-"
hisense_ac    | I0327 04:42:09.753  mqtt_client.py:37] MQTT message Topic: hisense_ac/[redacted]/adjust_temperature/command, Payload b'20.0'
hisense_ac    | I0327 04:42:09.767  web_log.py:206] 192.168.2.161 [27/Mar/2023:04:42:09 +0000] "GET /local_lan/commands.json HTTP/1.1" 200 418 "-" "-"
hisense_ac    | I0327 04:42:10.790  query_handlers.py:139] Decrypted: {"seq_no":96,"data":{"name":"adjust_temperature","value":200}}
hisense_ac    | I0327 04:42:10.794  web_log.py:206] 192.168.2.161 [27/Mar/2023:04:42:10 +0000] "POST /local_lan/property/datapoint.json HTTP/1.1" 200 150 "-" "-"
hisense_ac    | I0327 04:42:16.766  mqtt_client.py:37] MQTT message Topic: hisense_ac/[redacted]/adjust_temperature/command, Payload b'21.11111111111111'
hisense_ac    | I0327 04:42:16.786  web_log.py:206] 192.168.2.161 [27/Mar/2023:04:42:16 +0000] "GET /local_lan/commands.json HTTP/1.1" 200 418 "-" "-"
hisense_ac    | I0327 04:42:19.773  query_handlers.py:139] Decrypted: {"seq_no":97,"data":{"name":"adjust_temperature","value":210}}

To account for this, I've added a "granularity" property that will round to the nearest 0.5C before the precision is applied. This fixes the problem for me.

typed_value = data_type[value]

# Update value precision for value to be sent to the A/C
precision = self._properties.get_precision(name)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since precision only makes sense if the property is an int anyway, I've moved this to the int clause above

# Round rather than fail if the input is a float.
# This is commonly the case for temperatures converted by HA from Celsius.
data_value = round(float(value))
elif data_type is int:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason to check for "." here, if it's an int value that doesn't have a decimal place the float logic won't affect it.

@emoses
Copy link
Author

emoses commented Mar 31, 2023

Closed in favor of #222

@emoses emoses closed this Mar 31, 2023
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.

2 participants