Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Climate control unavailable #216

Closed
3 tasks done
chasebolt opened this issue Apr 30, 2024 · 40 comments
Closed
3 tasks done

[Bug]: Climate control unavailable #216

chasebolt opened this issue Apr 30, 2024 · 40 comments
Labels
bug Something isn't working master/next-release Fixed in master branch, Will be ready in the next release

Comments

@chasebolt
Copy link

chasebolt commented Apr 30, 2024

LocalTuya Version

3.2.5.1

Home Assistant Version

2024.4.4

Environment

  • Does the device work using the Home Assistant Tuya Cloud component?
  • Is this device connected to another local integration, including Home Assistant and any other tools?
  • The devices are within the same HA subnet, and they get discovered automatically when I add them

What happened?

Adding a climate device with auto-discovery populates everything but the entity is not controllable. It is related to a dp called temp_set_f which says cloud-pull

Steps to reproduce.

  1. Add New Device.
  2. Choose auto-discovery
  3. Accept configured settings
  4. Try to control climate device

Relevant log output

2024-04-29 19:16:43.128 ERROR (SyncWorker_6) [homeassistant.util.logging] Exception in _update_handler when dispatching 'localtuya_41742628483fda389ea0': ({'1': True, '2': 780, '3': 25, '4': 'cold', '5': 'auto', '18': 0, '20': 0, '101': 0, '105': 'off', '110': 2232892, '113': '0', '114': '1', '119': '0', '120': 'off', '123': '0018', '125': 'great', '126': '1', '127': '0', '128': '0', '129': '1', '130': 26, '131': False, '132': False, '133': '1', '134': '{"t":1713762837,"s":false,"clr":true}'},)
Traceback (most recent call last):
  File "/config/custom_components/localtuya/common.py", line 598, in _update_handler
    self.status_updated()
  File "/config/custom_components/localtuya/climate.py", line 409, in status_updated
    self.dp_value(CONF_TARGET_TEMPERATURE_DP) * self._precision_target
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'

Diagnostics information.

config_entry-localtuya-7ecc619af53d32968e4b2b28a5834ea1.json

home-assistant_localtuya_2024-04-30T02-18-27.169Z.log

@chasebolt chasebolt added the bug Something isn't working label Apr 30, 2024
@xZetsubou
Copy link
Owner

Diagnostics information are broken fix the link.

@chasebolt
Copy link
Author

sorry about that. fixed.

@xZetsubou
Copy link
Owner

xZetsubou commented May 1, 2024

This issue has been fixed on the master release

So if you want to fix this manually,
1, Go to Ha -> localtuya -> configure -> reconfigure existed device -> choose the climate Air conditioner -> click on submit once the device config shows up and click submit again to processed into Climate entity Configuration
2. Change Target Temperature from 136 to 2

edit: or you install master version using HACS and re-add the device

@xZetsubou xZetsubou added the master/next-release Fixed in master branch, Will be ready in the next release label May 1, 2024
@chasebolt chasebolt changed the title [Bug]: [Bug]: Climate control unavailable May 1, 2024
@chasebolt
Copy link
Author

Thanks - I installed master and readded the device. It now is controllable!

The set temperature is calculated incorrectly. 2 is reporting 780, which is 78.0F (it is what I have set on the unit), and the Current Temperature is being reported as 26C.

SCR-20240430-pyjc
SCR-20240430-qaes

@xZetsubou
Copy link
Owner

xZetsubou commented May 1, 2024

I think what happening is that because to set temperature_unit to celsius and your home assistant unit is Fahrenheit

Try this:
Go to Ha -> localtuya -> configure -> reconfigure existed device -> choose the climate Air conditioner -> click on submit once the device config shows up and click submit again to processed into Climate entity Configuration.

Change the temperature unit from celsius to fahrenheit

@chasebolt
Copy link
Author

doing that makes the current temperature incorrect.

this issue is set temp is reported in F while current temp is reported in C. this is a very shitty device lol

@xZetsubou
Copy link
Owner

I know that the fix should be in localtuya, however I wanted you to test to see the results :), I'll look into this.

@chasebolt
Copy link
Author

hah well yes you are correct that setting it to F fixes 1 of 2 temp outputs. not sure best way to fix this or even if it is possible - pretty dumb manufacture on this device.

@xZetsubou
Copy link
Owner

xZetsubou commented May 1, 2024

Not sure if the changes I made will handle this as expected, you can re-download master version and see if it will fix.

note: If the min/max have incorrect values due to the target temp will be forced to match current if that happen let me know.

@chasebolt
Copy link
Author

I think it is nearly there!!

Here is a loom video of what I am seeing. I trimmed out the section that exposed my keys - I kept everything as defaults.

https://www.loom.com/share/863ece7841a5440d8d5ca981244657bd?sid=9ee3d581-8a44-445a-ae8c-4a4513d39861

@chasebolt
Copy link
Author

ah ignore this! i realized everything is in C but the min/max is in F. i updated min/max to C values and it is working as expected.

ok this is ridiculous now, but I can set the temp to 77F and 79F but not 78F (which is what I always set it to). is there possible rounding happening?

@chasebolt
Copy link
Author

here is an interesting section of the logs. it looks like dps 2 is being sent in C and we receive dps 2 in F. you will see DPS: {'2': 250} which is when I set the target temp to 77F and there is DPS: {'2': 256} which is when I set the target temp to 78F.

2024-05-01 15:32:19.885 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Sending command 7 (device type: type_0a) DPS: {'2': 250}
2024-05-01 15:32:19.887 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Sending payload: b'{"devId":"41742628483fda389ea0","uid":"41742628483fda389ea0","t":"1714602739","dps":{"2":250}}'
2024-05-01 15:32:19.893 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Command 7 waiting for seq. number 56
2024-05-01 15:32:19.989 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Dispatching message CMD 7 TuyaMessage(seqno=56, cmd=7, retcode=0, payload=b'', crc=636047059, crc_good=True, prefix=21930, iv=None)
2024-05-01 15:32:19.990 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Dispatching sequence number 56
2024-05-01 15:32:19.990 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Got message type 7 for unknown listener 56: TuyaMessage(seqno=56, cmd=7, retcode=0, payload=b'', crc=636047059, crc_good=True, prefix=21930, iv=None)
2024-05-01 15:32:19.991 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] ACK received for command 7: ignoring it
2024-05-01 15:32:20.410 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Dispatching message CMD 8 TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b"3.3\x00\x00\x00\x00\x00\x00L\xac\x00\x00\x00\x01\r=s\xf1J\xaf*']\xa9\x9b\xe8\x14\xe7C>\x80Z<\xa0.~\x93\xe1YnC\xb2\xcf\xd0\xc4)+G\xe4S\xb0\xbe\xa1Xr\n\xd2ST\xa5 \x0b\x8c\\\x8e\xc2\xddQTl\x05\xf3\xab\xfc\x94\xe1\x8c\xf8", crc=1627839006, crc_good=True, prefix=21930, iv=None)
2024-05-01 15:32:20.411 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Got status update
2024-05-01 15:32:20.416 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Deciphered data = '{"devId":"41742628483fda389ea0","dps":{"2":770},"t":1714602739}'
2024-05-01 15:32:20.427 DEBUG (MainThread) [custom_components.localtuya.climate] [417...ea0] Entity - Additional attributes: {'raw_state': True}
2024-05-01 15:32:26.081 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Sending command 9 (device type: type_0a) DPS: None
2024-05-01 15:32:26.082 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Sending payload: b'{"gwId":"41742628483fda389ea0","devId":"41742628483fda389ea0"}'
2024-05-01 15:32:26.087 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Command 9 waiting for seq. number -100
2024-05-01 15:32:26.113 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Dispatching message CMD 9 TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211, crc_good=True, prefix=21930, iv=None)
2024-05-01 15:32:26.114 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Got heartbeat response
2024-05-01 15:32:26.115 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] ACK received for command 9: ignoring it
2024-05-01 15:32:36.117 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Sending command 9 (device type: type_0a) DPS: None
2024-05-01 15:32:36.118 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Sending payload: b'{"gwId":"41742628483fda389ea0","devId":"41742628483fda389ea0"}'
2024-05-01 15:32:36.122 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Command 9 waiting for seq. number -100
2024-05-01 15:32:36.149 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Dispatching message CMD 9 TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211, crc_good=True, prefix=21930, iv=None)
2024-05-01 15:32:36.150 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Got heartbeat response
2024-05-01 15:32:36.151 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] ACK received for command 9: ignoring it
2024-05-01 15:32:40.886 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Sending command 7 (device type: type_0a) DPS: {'2': 256}
2024-05-01 15:32:40.887 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Sending payload: b'{"devId":"41742628483fda389ea0","uid":"41742628483fda389ea0","t":"1714602760","dps":{"2":256}}'
2024-05-01 15:32:40.896 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Command 7 waiting for seq. number 59
2024-05-01 15:32:40.981 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Dispatching message CMD 7 TuyaMessage(seqno=59, cmd=7, retcode=0, payload=b'', crc=2552439325, crc_good=True, prefix=21930, iv=None)
2024-05-01 15:32:40.982 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Dispatching sequence number 59
2024-05-01 15:32:40.983 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Got message type 7 for unknown listener 59: TuyaMessage(seqno=59, cmd=7, retcode=0, payload=b'', crc=2552439325, crc_good=True, prefix=21930, iv=None)
2024-05-01 15:32:40.983 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] ACK received for command 7: ignoring it

@chasebolt
Copy link
Author

more data for you. in the tuya dev platform this is what my device being set to 78F looks like. it has a temp_set of 780. when I change the temp to 77F the temp_set becomes 770. even though temp_set is reporting the unit should be C, it is actually treating the value as it is F. id guess this is why the min/max value is so high for set_temp.

SCR-20240501-omrv
SCR-20240501-omut

xZetsubou added a commit that referenced this issue May 3, 2024
* If set temp is the one who have fahrenheit then convert min/max and handle set temp service.
* Prefer set_temp over set_temp_f
@xZetsubou
Copy link
Owner

xZetsubou commented May 3, 2024

Try latest master, by re-downloading it.
-- It should fix auto configure for your device.
-- It should convert min/max temps automatically.
-- It should also fix set new temperature in HA as well :)

@chasebolt
Copy link
Author

chasebolt commented May 3, 2024

getting this error when adding the device and the thermostat is blank

2024-05-02 18:40:41.960 DEBUG (MainThread) [custom_components.localtuya.climate] [417...ea0] Initialized climate []
2024-05-02 18:40:41.976 DEBUG (MainThread) [custom_components.localtuya.climate] [417...ea0] Adding climate.air_conditioner with configuration: {'entity_category': 'None', 'target_temperature_dp': '2', 'current_temperature_dp': '3', 'temperature_step': '1', 'min_temperature': 60.0, 'max_temperature': 90.0, 'precision': '1', 'target_precision': '0.1', 'hvac_mode_dp': '4', 'hvac_mode_set': {'cool': 'cold', 'heat': 'hot', 'dry': 'wet', 'fan_only': 'wind', 'auto': 'auto'}, 'hvac_action_set': {'heating': 'heating', 'cooling': 'cooling'}, 'preset_dp': '4', 'preset_set': {'cold': 'cold', 'hot': 'hot', 'wet': 'wet', 'wind': 'wind', 'auto': 'auto'}, 'fan_speed_dp': '5', 'fan_speed_list': 'strong,high,mid_high,mid,mid_low,low,mute,auto', 'temperature_unit': 'celsius', 'friendly_name': '', 'id': '1', 'platform': <Platform.CLIMATE: 'climate'>, 'icon': ''}
2024-05-02 18:40:41.991 DEBUG (SyncWorker_3) [custom_components.localtuya.coordinator] [417...ea0] New entity climate.air_conditioner was added to 192.168.1.102
2024-05-02 18:40:42.002 ERROR (SyncWorker_3) [homeassistant.util.logging] Exception in _update_handler when dispatching 'localtuya_41742628483fda389ea0': ({'1': True, '2': 780, '3': 24, '4': 'cold', '5': 'auto', '18': 0, '20': 0, '101': 0, '105': 'off', '110': 2232892, '113': '0', '114': '1', '119': '0', '120': 'off', '123': '0000', '125': 'great', '126': '1', '127': '0', '128': '0', '129': '1', '130': 26, '131': False, '132': False, '133': '1', '134': '{"t":1713762837,"s":false,"clr":true}'},)
Traceback (most recent call last):
File "/config/custom_components/localtuya/entity.py", line 172, in _update_handler
self.status_updated()
File "/config/custom_components/localtuya/climate.py", line 462, in status_updated
self.target_temperature = target_temp
^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: property 'target_temperature' of 'LocalTuyaClimate' object has no setter

localtuya-7ecc619af53d32968e4b2b28a5834ea1-Air Conditioner-b973da2d1e8f88bad4c0badc31e1761c.json

@chasebolt
Copy link
Author

here is another loom video of the process

https://www.loom.com/share/400196a5e83c4b438209aac10e3ea3f9

@xZetsubou
Copy link
Owner

whoops it's typo, I changed "target_temperature" instead "_target_temperature" :)

@xZetsubou
Copy link
Owner

Should be fixed in bf5d8f5

@chasebolt
Copy link
Author

the unit isnt accepting the temperature change command. i think dps 2 is maybe out of the expected range since it expects it to be in F * 10?

2024-05-02 19:13:09.708 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Sending command 7 (device type: type_0a) DPS: {'2': 462}

https://www.loom.com/share/c9f93e9b50504678a1ff052716776e70

@xZetsubou
Copy link
Owner

"2" range is from 160 to 880 and it already scaled back *10 before sending the command.
can you re-download the master after the changed made in 5ad7962 and re-add the device.

@chasebolt
Copy link
Author

"2" range is from 160 to 880 and it already scaled back *10 before sending the command. can you re-download the master after the changed made in 5ad7962 and re-add the device.

i set the temp to 75 so i would expect dps 2 to be sent as 750, but instead it was sent as 462.

creating a new loom to show the new behavior

@chasebolt
Copy link
Author

@chasebolt
Copy link
Author

if there is a setting i should be adjusting before saving the device let me know

xZetsubou added a commit that referenced this issue May 3, 2024
* Added scale option in cloud_value
* force to int if the float point is .0
* Fix set_temperture if set_temp forced to celsius.
* Auto configure now will scale min/max for climates.
* Removed dev logs.
@xZetsubou
Copy link
Owner

Can you try the latest master version 😸

@chasebolt
Copy link
Author

getting this when changing the temperature

SCR-20240502-slzr

@chasebolt
Copy link
Author

so close! in this video if i change the min/max it bugs out.

https://www.loom.com/share/113e0c85f3084ee5a442b93586a7f2ba

@xZetsubou
Copy link
Owner

I updated the master e004ade it should fix access variable error. note: don't change the min/max values also step value should be fixed in c9c8ae8

@chasebolt
Copy link
Author

chasebolt commented May 3, 2024

controls look to be working but the device isn't actually updating when I verify with the tuya app.

2024-05-02 21:48:35.295 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Sending payload: b'{"devId":"41742628483fda389ea0","uid":"41742628483fda389ea0","t":"1714711715","dps":{"2":-70}}'

https://www.loom.com/share/441b013f534a4371b18066394ba0abe4

@xZetsubou
Copy link
Owner

Let me double-check this not sure why it set -70 as the value...

@xZetsubou
Copy link
Owner

xZetsubou commented May 3, 2024

Ok now I understand what happened, both Home Assistant and localtuya are converting the temperature you set.
Give a try to latest master :)

@chasebolt
Copy link
Author

unfortunately still running into an issue. let me know if there is anything else I can provide to help.

https://www.loom.com/share/b7646a5deead41a9adaeb3273550ad26

@xZetsubou
Copy link
Owner

Hello, Can you give latest master a try.

@chasebolt
Copy link
Author

wow it is 99% working!! amazing job! 🥇

the only minor issue I am having is I cant set it to some temperatures, such as 76C and 78F, because of rounding.

Expected -> Actual
76F -> 75F
78F -> 77F

@xZetsubou
Copy link
Owner

Enable the debug for the device. Let's see what localtuya is sending on 76 or 78

@chasebolt
Copy link
Author

chasebolt commented May 8, 2024

76F: 2024-05-08 12:10:02.567 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Sending command 7 (device type: type_0a) DPS: {'2': 244}

78F: 2024-05-08 12:13:47.617 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [417...ea0] Sending command 7 (device type: type_0a) DPS: {'2': 256}

I would have expected sending 760 or 780, as that is the value we read it in as.

@xZetsubou

This comment was marked as outdated.

@xZetsubou
Copy link
Owner

Try latest master 74c77aa it should fix the issue 😺

@chasebolt
Copy link
Author

the most recent commit seems to have broken it. if you revert back I can grab the device diagnostics for you on the previous "working" commit.

https://www.loom.com/share/c014fbb64a4c496388e9f6844a473ed8

@xZetsubou
Copy link
Owner

Just updated it, it seems MAX / MIN was being converted more then once.

@chasebolt
Copy link
Author

holy shit you did it! everything works and I wasn't able to break anything 😂

thank you! very much appreciated it. let me know if there is any place I can send you a tip for the help on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working master/next-release Fixed in master branch, Will be ready in the next release
Projects
None yet
Development

No branches or pull requests

2 participants