-
Notifications
You must be signed in to change notification settings - Fork 621
Description
The problem
I've added a New Zealand purchased GOLDAIR PLATINUM TOWER FAN WITH WIFI (Model from Tuya API reported as GPTF380 / GPTF390) to my localtuya configuration, and mapped the DPs so all features work aside from the oscillation toggle. Oscillation can be disabled by toggling the oscillate switch in HA (either on or off will result in it being turned off), but it is not possible to enable oscillation.
I've collected debug logs, used the scanner tool to map out the DPs, and used the localtuya.set_dp
service to confirm that the oscillation setting can be properly set from localtuya by sending the payloads of on
and off
accordingly.
The scanner correctly identifies the current value of the DP (DP 4 in this case) to be either on
or off
during device add. However, it seems the code is then sending boolean true
or false
to the service, perhaps due to this bit of code?
Environment
- Localtuya version: 5.1.0
- Home Assistant Core version: 2023.3.2
- [] Does the device work using the Home Assistant Tuya Cloud component ?
- [] Does the device work using the Tinytuya (https://github.com/jasonacox/tinytuya) command line tool ?
- [] Was the device working with earlier versions of localtuya ? Which one?
I have not used any of the above tools
- [] Are you using the Tuya/SmartLife App in parallel ?
Steps to reproduce
- Add device to localtuya using the wizard, add a Fan device
- Map DP 4 to the Oscillate setting, map other DPs as appropriate (my mappings are provided below)
- Optionally, add Sensor (for temperature) and Selects for timer and modes, again my mappings provided below.
- Attempt to toggle the new HA fan device's Oscillate function, which will not be able to turn on oscillation.
Example of how to properly set oscillation on, by calling the the localtuya.set_dp
service:
service: localtuya.set_dp
data:
device_id: deadbeefcafe
dp: 4
value: on
DP dump
DPS [1] VALUE [True] Power On/Off
DPS [2] VALUE [1] Mode (Nature/etc blah 1-4)
1: Cool
2: Nature (Varies speed randomly)
3: Sleep
4: Baby (speed 3, osc, 3hr timea, light/display off)
1;2;3;4
Cool;Nature;Sleep;3hr Intense
DPS [3] VALUE [1] Speed
1
2
3
DPS [4] VALUE [off] Oscillate
on
off
DPS [6] VALUE [0] Timer
(0-12 hrs)
0;1;2;3;4;5;6;7;8;9;10;11;12
Always On;1 Hour;2 Hours;3 Hours;4 Hours;5 Hours;6 Hours;7 Hours;8 Hours;9 Hours;10 Hours;11 Hours;12 Hours
DPS [19] VALUE [25] Temperature in C
n °C
Provide Home Assistant traceback/logs
Logs showing localtuya receiving the oscillate DP states (and properly decoding them):
2023-03-09 18:53:42.086 DEBUG (MainThread) [custom_components.localtuya.pytuya] [deadbeefcafe] Deciphered data = '{"dps":{"4":"on"},"t":1678341220}'
2023-03-09 18:54:49.034 DEBUG (MainThread) [custom_components.localtuya.pytuya] [deadbeefcafe] Deciphered data = '{"dps":{"4":"off"},"t":1678341287}'
Logs showing localtuya sending incorrect payloads for oscillate when I use the HA fan interface to change the setting:
2023-03-09 18:54:52.283 DEBUG (MainThread) [custom_components.localtuya.fan] Fan async_oscillate: False
2023-03-09 18:54:52.283 DEBUG (MainThread) [custom_components.localtuya.pytuya] [deadbeefcafe] Sending command 7 (device type: type_0a)
2023-03-09 18:54:52.283 DEBUG (MainThread) [custom_components.localtuya.pytuya] [deadbeefcafe] Sending payload: b'{"devId":"ebaf45e171f383d03ekcxl","uid":"ebaf45e171f383d03ekcxl","t":"1678341292","dps":{"4":false}}'
2023-03-09 18:54:52.284 DEBUG (MainThread) [custom_components.localtuya.pytuya] [deadbeefcafe] Command 7 waiting for seq. number 10
2023-03-09 18:54:52.290 DEBUG (MainThread) [custom_components.localtuya.pytuya] [deadbeefcafe] Dispatching message CMD 7 TuyaMessage(seqno=10, cmd=7, retcode=0, payload=b'', crc=1120671415, crc_good=True)
2023-03-09 18:54:52.291 DEBUG (MainThread) [custom_components.localtuya.pytuya] [deadbeefcafe] ACK received for command 7: ignoring it
2023-03-09 18:54:57.162 DEBUG (MainThread) [custom_components.localtuya.fan] Fan async_oscillate: True
2023-03-09 18:54:57.162 DEBUG (MainThread) [custom_components.localtuya.pytuya] [deadbeefcafe] Sending command 7 (device type: type_0a)
2023-03-09 18:54:57.162 DEBUG (MainThread) [custom_components.localtuya.pytuya] [deadbeefcafe] Sending payload: b'{"devId":"ebaf45e171f383d03ekcxl","uid":"ebaf45e171f383d03ekcxl","t":"1678341297","dps":{"4":true}}'
2023-03-09 18:54:57.165 DEBUG (MainThread) [custom_components.localtuya.pytuya] [deadbeefcafe] Command 7 waiting for seq. number 12
2023-03-09 18:54:57.171 DEBUG (MainThread) [custom_components.localtuya.pytuya] [deadbeefcafe] Dispatching message CMD 7 TuyaMessage(seqno=12, cmd=7, retcode=0, payload=b'', crc=3794389354, crc_good=True)
2023-03-09 18:54:57.172 DEBUG (MainThread) [custom_components.localtuya.pytuya] [deadbeefcafe] ACK received for command 7: ignoring it
Logs showing correct oscillate payload being sent (and the fan indeed changed the oscillation mode to on, working) via localtuya.set_dp service:
2023-03-09 19:01:41.192 DEBUG (MainThread) [custom_components.localtuya.pytuya] [deadbeefcafe] Sending command 7 (device type: type_0a)
2023-03-09 19:01:41.192 DEBUG (MainThread) [custom_components.localtuya.pytuya] [deadbeefcafe] Sending payload: b'{"devId":"ebaf45e171f383d03ekcxl","uid":"ebaf45e171f383d03ekcxl","t":"1678341701","dps":{"4":"on"}}'
2023-03-09 19:01:41.197 DEBUG (MainThread) [custom_components.localtuya.pytuya] [deadbeefcafe] Command 7 waiting for seq. number 53
2023-03-09 19:01:41.202 DEBUG (MainThread) [custom_components.localtuya.pytuya] [deadbeefcafe] Dispatching message CMD 7 TuyaMessage(seqno=53, cmd=7, retcode=0, payload=b'', crc=1657089709, crc_good=True)
2023-03-09 19:01:41.224 DEBUG (MainThread) [custom_components.localtuya.pytuya] [deadbeefcafe] ACK received for command 7: ignoring it
Additional information
Diagnostic dump for the device (what I believe to be the relevant part, if more is needed, just let me know):
[...]
"device_config": {
"friendly_name": "Living Room Fan",
"host": "<redacted>",
"local_key": "<redacted>",
"protocol_version": "3.3",
"enable_debug": true,
"entities": [
{
"friendly_name": "Fan",
"fan_speed_control": 3,
"fan_oscillating_control": 4,
"fan_direction_forward": "forward",
"fan_direction_reverse": "reverse",
"fan_speed_min": 1,
"fan_speed_max": 3,
"fan_speed_ordered_list": "disabled",
"fan_dps_type": "str",
"id": 1,
"platform": "fan"
},
{
"friendly_name": "Fan",
"unit_of_measurement": "\u00b0C",
"device_class": "temperature",
"id": 19,
"platform": "sensor"
},
{
"friendly_name": "Mode",
"select_options": "1;2;3;4",
"select_options_friendly": "Cool;Nature;Sleep;3hr Intense",
"restore_on_reconnect": false,
"is_passive_entity": false,
"id": 2,
"platform": "select"
},
{
"friendly_name": "Timer",
"select_options": "0;1;2;3;4;5;6;7;8;9;10;11;12",
"select_options_friendly": "Always On;1 Hour;2 Hours;3 Hours;4 Hours;5 Hours;6 Hours;7 Hours;8 Hours;9 Hours;10 Hours;11 Hours;12 Hours",
"restore_on_reconnect": false,
"is_passive_entity": false,
"id": 6,
"platform": "select"
}
],
"device_id": "deadbeefcafe",
"dps_strings": [
"1 (value: True)",
"2 (value: 1)",
"3 (value: 1)",
"4 (value: off)",
"6 (value: 0)",
"19 (value: 24)"
],
"product_key": "hgsp7xfajllkqujw"
}
[...]
Thanks!