localtuya
localtuya copied to clipboard
No Values ?Returned for DP-IDS
The problem
Environment
- Localtuya version: 4.1.0
- Last working localtuya version (if known and relevant): Dont know
- Home Assistant Core version:
- [] Are you using the Home Assistant Tuya Cloud component ? No
- [] Are you using the Tuya App in parallel ? No
Steps to reproduce
- Selected add new device
- Entered ID and local Key
- add the following dp_id: 20,21,22,23,24,25
- Chose the appropriate id to match the color, brightness etc.
Configuration configuration.yaml
or config_flow
DP dump
Provide Home Assistant taceback/logs
Additional information
DP dump:
` { "result": { "category": "dj", "functions": [ { "code": "switch_led", "dp_id": 20, "type": "Boolean", "values": "{}" }, { "code": "work_mode", "dp_id": 21, "type": "Enum", "values": "{"range":["white","colour","scene","music"]}" }, { "code": "bright_value_v2", "dp_id": 22, "type": "Integer", "values": "{"min":10,"max":1000,"scale":0,"step":1}" }, { "code": "temp_value_v2", "dp_id": 23, "type": "Integer", "values": "{"min":0,"max":1000,"scale":0,"step":1}" }, { "code": "colour_data_v2", "dp_id": 24, "type": "Json", "values": "{"h":{"min":0,"scale":0,"unit":"","max":360,"step":1},"s":{"min":0,"scale":0,"unit":"","max":1000,"step":1},"v":{"min":0,"scale":0,"unit":"","max":1000,"step":1}}" }, { "code": "scene_data_v2", "dp_id": 25, "type": "Json", "values": "{"scene_num":{"min":1,"scale":0,"max":8,"step":1},"scene_units": {"unit_change_mode":{"range":["static","jump","gradient"]},"unit_switch_duration":{"min":0,"scale":0,"max":100,"step":1},"unit_gradient_duration":{"min":0,"scale":0,"max":100,"step":1},"bright":{"min":0,"scale":0,"max":1000,"step":1},"temperature":{"min":0,"scale":0,"max":1000,"step":1},"h":{"min":0,"scale":0,"unit":"","max":360,"step":1},"s":{"min":0,"scale":0,"unit":"","max":1000,"step":1},"v":{"min":0,"scale":0,"unit":"","max":1000,"step":1}}}" }, { "code": "countdown_1", "dp_id": 26, "type": "Integer", "values": "{"unit":"s","min":0,"max":86400,"scale":0,"step":1}" }, { "code": "music_data", "dp_id": 27, "type": "Json", "values": "{"change_mode":{"range":["direct","gradient"]}, "bright":{"min":0,"scale":0,"unit":"","max":1000,"step":1}, "temperature":{"min":0,"scale":0,"unit":"","max":1000,"step":1}, "h":{"min":0,"scale":0,"unit":"","max":360,"step":1},"s":{"min":0,"scale":0,"unit":"","max":255,"step":1},"v":{"min":0,"scale":0,"unit":"","max":255,"step":1}}" }, { "code": "control_data", "dp_id": 28, "type": "Json", "values": "{"change_mode":{"range":["direct","gradient"]}, "bright":{"min":0,"scale":0,"unit":"","max":1000,"step":1}, "temperature":{"min":0,"scale":0,"unit":"","max":1000,"step":1}, "h":{"min":0,"scale":0,"unit":"","max":360,"step":1},"s":{"min":0,"scale":0,"unit":"","max":255,"step":1},"v":{"min":0,"scale":0,"unit":"","max":255,"step":1}}" }, { "code": "rhythm_mode", "dp_id": 30, "type": "Raw", "values": "{"maxlen":255}" }, { "code": "sleep_mode", "dp_id": 31, "type": "Raw", "values": "{"maxlen":255}" }, { "code": "wakeup_mode", "dp_id": 32, "type": "Raw", "values": "{"maxlen":255}" }, { "code": "power_memory", "dp_id": 33, "type": "Raw", "values": "{}" }, { "code": "do_not_disturb", "dp_id": 34, "type": "Boolean", "values": "{}" }, { "code": "cycle_timing", "dp_id": 209, "type": "Raw", "values": "{}" }, { "code": "random_timing", "dp_id": 210, "type": "Raw", "values": "{}" } ], "status": [ { "code": "switch_led", "dp_id": 20, "type": "Boolean", "values": "{}" }, { "code": "work_mode", "dp_id": 21, "type": "Enum", "values": "{"range":["white","colour","scene","music"]}" }, { "code": "bright_value_v2", "dp_id": 22, "type": "Integer", "values": "{"min":10,"max":1000,"scale":0,"step":1}" }, { "code": "temp_value_v2", "dp_id": 23, "type": "Integer", "values": "{"min":0,"max":1000,"scale":0,"step":1}" }, { "code": "colour_data_v2", "dp_id": 24, "type": "Json", "values": "{"h":{"min":0,"scale":0,"unit":"","max":360,"step":1},"s":{"min":0,"scale":0,"unit":"","max":1000,"step":1},"v":{"min":0,"scale":0,"unit":"","max":1000,"step":1}}" }, { "code": "scene_data_v2", "dp_id": 25, "type": "Json", "values": "{"scene_num":{"min":1,"scale":0,"max":8,"step":1},"scene_units": {"unit_change_mode":{"range":["static","jump","gradient"]},"unit_switch_duration":{"min":0,"scale":0,"max":100,"step":1},"unit_gradient_duration":{"min":0,"scale":0,"max":100,"step":1},"bright":{"min":0,"scale":0,"max":1000,"step":1},"temperature":{"min":0,"scale":0,"max":1000,"step":1},"h":{"min":0,"scale":0,"unit":"","max":360,"step":1},"s":{"min":0,"scale":0,"unit":"","max":1000,"step":1},"v":{"min":0,"scale":0,"unit":"","max":1000,"step":1}}}" }, { "code": "countdown_1", "dp_id": 26, "type": "Integer", "values": "{"unit":"s","min":0,"max":86400,"scale":0,"step":1}" }, { "code": "music_data", "dp_id": 27, "type": "Json", "values": "{"change_mode":{"range":["direct","gradient"]}, "bright":{"min":0,"scale":0,"unit":"","max":1000,"step":1}, "temperature":{"min":0,"scale":0,"unit":"","max":1000,"step":1}, "h":{"min":0,"scale":0,"unit":"","max":360,"step":1},"s":{"min":0,"scale":0,"unit":"","max":255,"step":1},"v":{"min":0,"scale":0,"unit":"","max":255,"step":1}}" }, { "code": "control_data", "dp_id": 28, "type": "Json", "values": "{"change_mode":{"range":["direct","gradient"]}, "bright":{"min":0,"scale":0,"unit":"","max":1000,"step":1}, "temperature":{"min":0,"scale":0,"unit":"","max":1000,"step":1}, "h":{"min":0,"scale":0,"unit":"","max":360,"step":1},"s":{"min":0,"scale":0,"unit":"","max":255,"step":1},"v":{"min":0,"scale":0,"unit":"","max":255,"step":1}}" }, { "code": "rhythm_mode", "dp_id": 30, "type": "Raw", "values": "{"maxlen":"255"}" }, { "code": "sleep_mode", "dp_id": 31, "type": "Raw", "values": "{"maxlen":"255"}" }, { "code": "wakeup_mode", "dp_id": 32, "type": "Raw", "values": "{"maxlen":"255"}" }, { "code": "power_memory", "dp_id": 33, "type": "Raw", "values": "{}" }, { "code": "do_not_disturb", "dp_id": 34, "type": "Boolean", "values": "{}" }, { "code": "cycle_timing", "dp_id": 209, "type": "Raw", "values": "{}" }, { "code": "random_timing", "dp_id": 210, "type": "Raw", "values": "{}" } ] }, "success": true, "t": 1662470871582, "tid": "b4f794932de711ed91ce464d4e80a014" }
Logs:
` [bff...wgt] Connect to 172.16.0.125 failed Traceback (most recent call last): File "/usr/local/lib/python3.10/asyncio/locks.py", line 390, in acquire await fut asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/local/lib/python3.10/asyncio/tasks.py", line 456, in wait_for return fut.result() asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 202, in _make_connection status = await self._interface.status() File "/config/custom_components/localtuya/pytuya/init.py", line 507, in status status = await self.exchange(STATUS) File "/config/custom_components/localtuya/pytuya/init.py", line 486, in exchange msg = await self.dispatcher.wait_for(seqno) File "/config/custom_components/localtuya/pytuya/init.py", line 259, in wait_for await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for raise exceptions.TimeoutError() from exc asyncio.exceptions.TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 216, in _make_connection await self._interface.reset(self._default_reset_dpids) AttributeError: 'NoneType' object has no attribute 'reset'
My problem is that the dp_ids return a value of -1 when setting up devices.
The device adds but I cannot control it,.
My apologies for not having all this detail in the initial post. I messed up the formatting
Can you see if the change in PR #1022 fixes your issue? It seems to be related to the RESET call which that PR changes the behavior of.
The update of the integration does not show up by me yet or am I understanding you incorrectly
Hi @Merril-r - no it won't appear yet. I'd like to get a few people to test the change, which essentially involves manually updating the code in their HA to match the changes in the PR. If this isn't something you're comfortable with, then you might be best to wait for others to test and then, once proven, the changes will be pushed to a release.
Hi @sibowler
I would love to help test. If you can point me in the direction of what I must do I will gladly help. I’m comfortable working in code.
Hi @Merril-r - Essentially you take the modifications identified in the PR (https://github.com/rospogrigio/localtuya/pull/1022/files) and apply them to the files in your Home Assistant install.
From my experience you can do this several ways:
- Use the HA File Editor: localtuya files are under custom_components/localtuya
- Use VS.code (essentially same as HA file editor, but with syntax highlighting)
- Use a SMB mount to modify the files that way.
Hi @sibowler
So I copied the code from your files and replaced the code in my two files.
Did a reboot of HA.
Added the device again.
The device adds but the dp_ids still return a value of -1 for each of them
You'll get a -1 for any of the manually added DPS, until the DPS are refreshed (i.e. after you've finished setting it up as a device). I've made a further change to the PR, so for these 'passive' type DPS, you'll need to configure that entity as being a 'passive' type. This will then cause an initialisation value to be sent to trigger ongoing updates.
@sibowler how do I configure it as a passive type?
@sibowler so I need to copy you code again. Then setup the device again. After adding change settings via the tuya app and then see if it works? I am understanding correctly?
@sibowler can you just confirm I am copying the file correctly.
On the screen where I can see your changes. If I click on the view file and copy and paste that into my file. Is that the correct way?
@sibowler I copied and pasted code as per my question above. Still not working. I don’t get an option to select passive mode.
@sibowler I copied and pasted code as per my question above. Still not working. I don’t get an option to select passive mode.
Hi @Merril-r - Yep, that's one way of doing it. You just need to make sure you've made those changes to all the files covered by the PR. After making the changes, restart your HA.
@sibowler how do I configure it as a passive type?
@sibowler so I need to copy you code again. Then setup the device again. After adding change settings via the tuya app and then see if it works? I am understanding correctly?
Once you've made these changes, you don't need to setup the device again - you can just edit the existing one. Go to Settings-> Devices & Services ->Localtuya->Configure->Edit a Device
When editing the device, on the relevant Configure Entity screens you will see a new option at the bottom of the screen saying Passive entity - requires integration to send initialisation value. Tick this if that particular entity/DPS is a passive one.
This process is the same when you're adding a new device.
Hi @sibowler
I do not see that option after make the changes
Hi @sibowler
I do not see that option after make the changes
Unfortunately, that means you probably haven't installed all the changes (or haven't restarted after making the change).
@sibowler Quiet possibly. I did restore and did it all again and restarted HA.
can you perhaps share the files that I download the files you changed and copy them to my folders
@sibowler i really would like to help test for you.
I did a downgrade to a version before, because local tuya was stopped working. Lights were off and HA saw it as light on. Devices didnt response at all. Now everything is working fine. Gonna wait for a fix until works good again.
@Merril-r - all the full files are available in GitHub... https://github.com/sibowler/localtuya/tree/fix_restart_behaviour is the source of that PR so you can find them there.
@sibowler
I followed your link.
Downloaded the zip source code from the link you sent.
Copied the files that had recent change dates common config_flow const cover manifest number select switch.
I restarted home assistant,
I still do not see the options for passive entity option
@sibowler
Just an update:
I setup a new instance of HA.
Copied the whole tuya integration folder from the zip to the new instance and configured it
I still do not see passive entity option
@sibowler here are my screen shots
Ahh - yes you won't see the passive option on the light entity, as this entity hasn't yet been enabled for this functionality. You'll see the passive options on switch, select and number.
@sibowler When will you be adding this for lights.
I installed the new update. Still getting -1 returned
@sibowler When will you be adding this for lights.
I installed the new update. Still getting -1 returned
Hi @Merril-r - I've actually just got a globe so i've now got a device to test with, so will look to make that enhancement soon.