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

What is a DP? #148

Open
mstarks01 opened this issue Nov 10, 2020 · 9 comments
Open

What is a DP? #148

mstarks01 opened this issue Nov 10, 2020 · 9 comments
Labels
question Further information is requested

Comments

@mstarks01
Copy link

Thank you for the work on this project. I appreciate your efforts.

The documentation states, 'For each entity, the associated DP has to be selected' and presumes the reader knows what DP stands for. What is DP? I have two options (for my Tuya OEM), but I don't know which option to select.

@postlund
Copy link
Collaborator

Yeah, our documentation is kinda scarce and we will have to improve that over time (there are lots of information on other pages on the net in the mean time). But a datapoint is basically a function of the device, e.g if it's on, current power consumption, position of a cover, brightness value, etc. A datapoint is just a number mapping to something representing its value. For a switch/outlet for instance, DP 1 normally maps to the state of the switch. Since it can be either on or off, it's a boolean value (True/False). I would expect that this is the case for you as well. The other datapoint is likely a built in timer, which we don't support.

In due time, the config flow will suggest likely values for you as well (see PR #125).

@postlund postlund added the question Further information is requested label Nov 10, 2020
@mstarks01
Copy link
Author

Thank you for the answer. Would a dimmable switch still be considered a switch? Light bulb seems to be more appropriate. When I add it this way, I have these values for ID and Brightness:

image

Brightness Lower Value defaults to 29 and Brightness Upper Value defaults to 1000.
I have tried different combinations of values for ID and Brightness, and kept the default values for Brightness. The result is that the actual max brightness ends up at around 1/3 of the slider.

How do I know which values for ID and Brightness are appropriate?

@postlund
Copy link
Collaborator

You should use DP 1 for ID and DP 3 for brightness. The range is hard to tell, but I suggest that you set the maximum value in the app you are using and then try to add the switch. DP 3 should have the maximum value in the list now. The do the same thing for lowest brightness, or close to it. Based on what you are saying it's likely that lower limit is 0 and upper 255.

@mstarks01
Copy link
Author

Ok, I finally got it working. Your reply helped.

The values that eventually worked were 25 for the min and 255 for the max. Interestingly, the min value defaults to 29 every time. If I use any values other than 25 and 255, the slider acts funny. For example, at 29 and 255, if I drag the slider to 100%, the light does change to full brightness but the slider snaps back to about 1/3.

@mstarks01
Copy link
Author

mstarks01 commented Nov 19, 2020

There were some errors along the way. Here are some logs if it helps.

2020-11-18 20:53:39 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for localtuya which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.
2020-11-18 20:53:39 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.
2020-11-18 20:53:40 ERROR (MainThread) [custom_components.localtuya.common] Connect to 192.168.2.117 failed
Traceback (most recent call last):
File "/config/custom_components/localtuya/common.py", line 151, in _make_connection
status = await self._interface.status()
File "/config/custom_components/localtuya/pytuya/__init__.py", line 429, in status
if "dps" in status:
TypeError: argument of type 'NoneType' is not iterable
2020-11-18 20:53:40 ERROR (MainThread) [custom_components.localtuya.common] Connect to 192.168.2.117 failed
Traceback (most recent call last):
File "/config/custom_components/localtuya/common.py", line 151, in _make_connection
status = await self._interface.status()
File "/config/custom_components/localtuya/pytuya/__init__.py", line 429, in status
if "dps" in status:
TypeError: argument of type 'NoneType' is not iterable`

@postlund
Copy link
Collaborator

Would it be possible if you tried running using the code in #177? Based on the error, I guess you are using. 3.0.3 or so? Lots of fixes have been made since then.

@mstarks01
Copy link
Author

I updated to 3.1.0 via HACS. There are still some errors in the logs.

`Log Details (ERROR)
Logger: custom_components.localtuya.pytuya
Source: custom_components/localtuya/pytuya/init.py:239
Integration: LocalTuya (documentation, issues)
First occurred: 8:22:53 PM (20 occurrences)
Last logged: 8:36:54 PM

[420...4ae] Heartbeat failed (), disconnecting
[004...0cc] Heartbeat failed (), disconnecting
[004...f63] Heartbeat failed (), disconnecting
Traceback (most recent call last):
File "/config/custom_components/localtuya/pytuya/init.py", line 379, in heartbeat_loop
await self.heartbeat()
File "/config/custom_components/localtuya/pytuya/init.py", line 468, in heartbeat
return await self.exchange(HEARTBEAT)
File "/config/custom_components/localtuya/pytuya/init.py", line 440, in exchange
msg = await self.dispatcher.wait_for(seqno)
File "/config/custom_components/localtuya/pytuya/init.py", line 239, in wait_for
await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
File "/usr/local/lib/python3.8/asyncio/tasks.py", line 498, in wait_for
raise exceptions.TimeoutError()
asyncio.exceptions.TimeoutError`

I also see frequent 'unavailable' messages in the log book, although the lights appear to be working OK.

Front Room Lights turned on 8:47:01 PM - 6 seconds ago Front Room Lights became unavailable 8:47:01 PM - 6 seconds ago Living Room Lights turned on 8:46:58 PM - 9 seconds ago Living Room Lights became unavailable 8:46:58 PM - 9 seconds ago Living Room Fan turned off 8:46:26 PM - 41 seconds ago

@mstarks01
Copy link
Author

I'm sorry to report that things are worse with the new version. I sometimes see switches physically flash red. In HA, it's now not uncommon to see the switch toggle not match the state of the light, or not respond to moving the slider. Usually, this means it's stuck in the on position. If I try to toggle it off, it quickly goes back to on, regardless of the actual light status.

@MacDada
Copy link

MacDada commented Nov 9, 2022

The docs instruct:

Adding/editing a device
For each entity, the associated DP has to be selected. All the options requiring to select a DP will provide a drop-down menu showing all the available DPs found on the device (with their current status!!) for easy identification.

The first question that comes to mind is: wth is DP? o.O

And I'm here after googling two years later after OP :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants