localtuya icon indicating copy to clipboard operation
localtuya copied to clipboard

No Values ?Returned for DP-IDS

Open Merril-r opened this issue 2 years ago • 26 comments

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

  1. Selected add new device
  2. Entered ID and local Key
  3. add the following dp_id: 20,21,22,23,24,25
  4. 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

Merril-r avatar Sep 06 '22 14:09 Merril-r

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'

Merril-r avatar Sep 06 '22 14:09 Merril-r

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

Merril-r avatar Sep 06 '22 14:09 Merril-r

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.

sibowler avatar Sep 07 '22 13:09 sibowler

The update of the integration does not show up by me yet or am I understanding you incorrectly

Merril-r avatar Sep 07 '22 14:09 Merril-r

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.

sibowler avatar Sep 07 '22 19:09 sibowler

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.

Merril-r avatar Sep 07 '22 20:09 Merril-r

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:

  1. Use the HA File Editor: localtuya files are under custom_components/localtuya
  2. Use VS.code (essentially same as HA file editor, but with syntax highlighting)
  3. Use a SMB mount to modify the files that way.

sibowler avatar Sep 08 '22 09:09 sibowler

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

Merril-r avatar Sep 08 '22 10:09 Merril-r

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 avatar Sep 09 '22 20:09 sibowler

@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?

Merril-r avatar Sep 10 '22 03:09 Merril-r

@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?

Merril-r avatar Sep 10 '22 04:09 Merril-r

@sibowler I copied and pasted code as per my question above. Still not working. I don’t get an option to select passive mode.

Merril-r avatar Sep 10 '22 18:09 Merril-r

@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.

sibowler avatar Sep 10 '22 19:09 sibowler

Hi @sibowler

I do not see that option after make the changes

Merril-r avatar Sep 11 '22 01:09 Merril-r

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 avatar Sep 11 '22 10:09 sibowler

@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

Merril-r avatar Sep 11 '22 10:09 Merril-r

@sibowler i really would like to help test for you.

Merril-r avatar Sep 11 '22 10:09 Merril-r

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.

besiktas97 avatar Sep 11 '22 15:09 besiktas97

@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 avatar Sep 14 '22 19:09 sibowler

@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

Merril-r avatar Sep 19 '22 15:09 Merril-r

@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

Merril-r avatar Sep 21 '22 15:09 Merril-r

@sibowler here are my screen shots

tuya4 tuya2 tuya3

Merril-r avatar Sep 21 '22 15:09 Merril-r

tuya1

Merril-r avatar Sep 21 '22 15:09 Merril-r

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 avatar Sep 23 '22 20:09 sibowler

@sibowler When will you be adding this for lights.

I installed the new update. Still getting -1 returned

Merril-r avatar Oct 12 '22 02:10 Merril-r

@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.

sibowler avatar Oct 15 '22 19:10 sibowler