rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.91k stars 557 forks source link

localtuya/number.py: Number set to correct DP but comes back as set to 0. Issue with int vs float? #931

Open ingoratsdorf opened 2 years ago

ingoratsdorf commented 2 years ago

May be related to #https://github.com/rospogrigio/localtuya/issues/710 ?

The problem

Move a slider for a number entity to any number other than 0, comes back as set to 0 (zero)

Environment

Steps to reproduce

LocalTuya defined for a PIR sensor. It’s DPS config represents the following:

- 101 - Mode: mode_auto/mode_on/mode_off <Select>
- 102 - Light State: true/false <Binary Sensor Only>
- 103 - Motion Sensitivity: 0=sensitive, 4=no sensitivity [0-4] <Number>
- 104 - Light Timeout when in Auto mode (secs) [10-900] <Number>
- 105 - Light Cutout Threshold 0=bright, 981=darkness [0-981] <Number>
- 106 - Reset to Auto after 1 hr in Manual On: True/False <Switch>

When I move the slider for DP103 to any number in Home Asiistant, it comes back as set to 0 (zero) Same for DP104 and DP105. Comes back as zero. If I call a service as below

  - service: localtuya.set_dp
    data:
      device_id: 21463430e098061daaed
      dp: 103
      value: 2

The value is correctly set to what it is supposed to be.

Configuration configuration.yaml or config_flow

config_flow

Provide Home Assistant taceback/logs

2022-07-03 19:30:37 DEBUG (MainThread) [custom_components.localtuya.pytuya] [214...533] Sending command set (device type: type_0a)
2022-07-03 19:30:37 DEBUG (MainThread) [custom_components.localtuya.pytuya] [214...533] Send payload: b'{"devId":"xxxxxxxxxx","uid":"xxxxxxxxxxxxx","t":"1656833437","**dps":{"103":4.0}}'**
2022-07-03 19:30:37 DEBUG (MainThread) [custom_components.localtuya.pytuya] [214...533] Waiting for sequence number 72
2022-07-03 19:30:37 DEBUG (MainThread) [custom_components.localtuya.pytuya] [214...533] Dispatching message TuyaMessage(seqno=72, cmd=7, retcode=0, payload=b'', crc=2669490775)
2022-07-03 19:30:37 DEBUG (MainThread) [custom_components.localtuya.pytuya] [214...533] Dispatching sequence number 72
2022-07-03 19:30:37 DEBUG (MainThread) [custom_components.localtuya.pytuya] [214...533] Decrypted payload: {}
2022-07-03 19:30:37 DEBUG (MainThread) [custom_components.localtuya.pytuya] [214...533] Dispatching message TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b"3.3\x00\x00\x00\x00\x00\x00\x00\x9b\x00\x00\x00\x01\xab\x98d\xbd\xfa,\x83'\xf8\x9e\xfe\xb9\xc6\x99}G?\x08N\x1b\x0c\xd4\xc4*\x06\x1f\xb2\x90\x19\xed\x92JL\x14.\x07l\xb3\xddR\xc1\x1e\xe0L{\x84\xe8\xc5\xc53S\x82m\xb4\xe2\xe7&\xfc0$[\xf5LG", crc=233730411)
2022-07-03 19:30:37 DEBUG (MainThread) [custom_components.localtuya.pytuya] [214...533] Got status update
2022-07-03 19:30:37 DEBUG (MainThread) [custom_components.localtuya.pytuya] [214...533] Decrypted payload: {"devId":"xxxxxxxxxxxxx","**dps":{"103":0}**,"t":1656833436}

Additional information

As noted above, when manually calling the setDP service, all is working. I noticed in the trace above that the number is sent as 4.0 (float) and comes back as 0 (int). Can it be that tuya (or this device) does not support floats (4.0) but expects just an integer (4)? Can localtuya use integer only to send?

deese commented 2 years ago

FYI, This PR may help on that https://github.com/rospogrigio/localtuya/pull/942

ingoratsdorf commented 2 years ago

@deese , yes, that might work. But apparently still not even in fan. And needed everywhere with int's.

monkeyatcomputer commented 1 year ago

@deese , yes, that might work. But apparently still not even in fan. And needed everywhere with int's.

Ever find a solution to this? I've hit the same issue with an Arlec/DETA PIR sensor. Mode and load on/off works in HA for now and can set the sensitivity, time, and lux from the Tuya app, but it'd be nice to keep it all in HA.

janfromberlin commented 11 months ago

PR #1265 is waiting for Merge since March 2023. It will fix this issue and possibly a dozen more. Any chance to see this in the next release? It is essential for many Wall Plug Thermostats ( including mine).

browetd commented 1 month ago

I have this issue also with a pool heater... Evything is working fine except the target temperature settings. It is well discovered as a number and displayed correctly but when I try to change it, it goes to the minimum of the range... So probably requesting an INT instead of a FLOAT... Thanks !