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

Missing DPIDs for Tuya PIR Sensor #97

Closed
phrak opened this issue Jan 8, 2024 · 18 comments
Closed

Missing DPIDs for Tuya PIR Sensor #97

phrak opened this issue Jan 8, 2024 · 18 comments
Labels
auto configure Related to auto configure entities feature.

Comments

@phrak
Copy link

phrak commented Jan 8, 2024

Environment

  • Localtuya version: 3.2.3h1
  • Home Assistant Core version: 2024.1.2
  • Home Assistant Installtion Method: OS v11.3
  • [UNKNOWN] Does the device work using the Home Assistant Tuya Cloud component ?
  • [UNKNOWN] Does the device work using the Tinytuya (https://github.com/jasonacox/tinytuya) command line tool ?
  • [NO] Was the device working with earlier versions of localtuya ? Which one?
  • [NO] Are you using the Tuya/SmartLife App in parallel ?

The problem

Hi Bander,

Would you be able to have a look to see why this PIR sensor device is not pulling the correct DPIDs from the Cloud please?

Product: Mercator Ikuu SXSEN003PIR IP65 Motion Detector (Wi-Fi)

Device Information
Product Name: SXSEN003PIR
Device ID: 63580033e8db8481fd5d
Product Category: pir

When I add the device, it can't map the auto-discovered DPIDs with any known entities.

An error occurred: Couldn't find the data for your device category: pir.. If reason isn't showing, check logs.

Log file:

2024-01-08 15:58:07.225 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [635...d5d] Sending command 10 (device type: type_0a)
2024-01-08 15:58:07.225 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [635...d5d] Sending payload: b'{"gwId":"63580033e8db8481fd5d","devId":"63580033e8db8481fd5d","uid":"63580033e8db8481fd5d","t":"1704689887"}'
2024-01-08 15:58:07.230 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [635...d5d] Command 10 waiting for seq. number 1
2024-01-08 15:58:07.240 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [635...d5d] Dispatching message CMD 10 TuyaMessage(seqno=1, cmd=10, retcode=0, payload=b'8l\xeb>\xdf%\xf2\xd1Z\xb2B\x955\xaa\x00u\xa5\'-|\x0fuL%pV\x9aoy\xb9\xdfw7Y_\x8d\xb6n\x9c\xd2\xcd\xa0\x06;m\xe8\xee\xb6\xc4?"\xd1,\xd3\xb6\xde\xf6\xd6\xe6{\xa2\x89\xb0|\x1b\x9c\xa2)\xf9\x0e\xaa\xe9\x8b\x0f\xdamV\xa7\xb0%\x0e?\xef7\x17\x12\xfd\xfb"\xa3P:\xc5\x8c\xfbA\x00\n\x9dP\x9d\xf5\xc2\'v\xa9\xc4^za\x0f\xc2', crc=3000766292, crc_good=True, prefix=21930, iv=None)
2024-01-08 15:58:07.241 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [635...d5d] Deciphered data = '{"devId":"63580033e8db8481fd5d","dps":{"101":"mode_auto","102":false,"103":2,"104":600,"105":600,"106":false}}'
2024-01-08 15:58:07.242 DEBUG (MainThread) [custom_components.localtuya.config_flow] Detected DPS: {'101': 'mode_auto', '102': False, '103': 2, '104': 600, '105': 600, '106': False}
2024-01-08 15:58:07.242 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [635...d5d] Closing connection
2024-01-08 15:58:07.242 DEBUG (MainThread) [custom_components.localtuya.config_flow] Total DPS: {'101': 'mode_auto', '102': False, '103': 2, '104': 600, '105': 600, '106': False}
2024-01-08 15:58:07.246 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [635...d5d] Connection lost: None
2024-01-08 15:58:09.302 DEBUG (MainThread) [custom_components.localtuya.core.tuya_devices] Driveway PIR: Entities configured: []

I get the following DPIDs when I Query the Things Data Model

{
  "result": {
    "model": "{\"modelId\":\"00000208gn\",\"services\":[{\"actions\":[],\"code\":\"\",\"description\":\"\",\"events\":[],\"name\":\"默认服务\",\"properties\":[{\"
abilityId\":101,\"accessMode\":\"rw\",\"code\":\"mod\",\"description\":\"\",\"name\":\"Sensor Mode\",\"typeSpec\":{\"range\":[\"mode_off\",\"mode_auto\",\"mode_on\"],\"type\":\"enum\",\"typeDefaultValue\":\"mode_off\"}},{\"
abilityId\":102,\"accessMode\":\"ro\",\"code\":\"sta\",\"description\":\"\",\"name\":\"Sensor Status\",\"typeSpec\":{\"type\":\"bool\",\"typeDefaultValue\":false}},{\"
abilityId\":103,\"accessMode\":\"rw\",\"code\":\"sens\",\"description\":\"\",\"name\":\"sensitivity\",\"typeSpec\":{\"max\":4,\"min\":0,\"scale\":1,\"step\":1,\"type\":\"value\",\"typeDefaultValue\":0,\"unit\":\"\"}},{\"
abilityId\":104,\"accessMode\":\"rw\",\"code\":\"tim\",\"description\":\"\",\"name\":\"Sensor Hold Time\",\"typeSpec\":{\"max\":900,\"min\":10,\"scale\":1,\"step\":1,\"type\":\"value\",\"typeDefaultValue\":10,\"unit\":\"\"}},{\"
abilityId\":105,\"accessMode\":\"rw\",\"code\":\"lux\",\"description\":\"\",\"name\":\"light level\",\"typeSpec\":{\"max\":981,\"min\":0,\"scale\":1,\"step\":1,\"type\":\"value\",\"typeDefaultValue\":0,\"unit\":\"\"}},{\"
abilityId\":106,\"accessMode\":\"rw\",\"code\":\"mod_on_tmr\",\"description\":\"\",\"name\":\"Mode On Timer\",\"typeSpec\":{\"type\":\"bool\",\"typeDefaultValue\":false}},{\"
abilityId\":107,\"accessMode\":\"ro\",\"code\":\"mod_on_tmr_cd\",\"description\":\"\",\"name\":\"Mode On Timer CD\",\"typeSpec\":{\"max\":3600,\"min\":0,\"scale\":1,\"step\":1,\"type\":\"value\",\"typeDefaultValue\":0,\"unit\":\"\"}}]}]}"
  },
  "success": true,
  "t": 1704686955350,
  "tid": "afb9300daddb11ee965f7eb6fd123fbf"
}

This is what the Smart Life app shows for the device:
Screenshot_20240108-160800_Tuya_Smart

Thanks in advance :)

@phrak phrak added the bug Something isn't working label Jan 8, 2024
@xZetsubou xZetsubou added auto configure Related to auto configure entities feature. and removed bug Something isn't working labels Jan 8, 2024
@xZetsubou
Copy link
Owner

xZetsubou commented Jan 8, 2024

This isn't bug it just Auto configure couldn't find data for your device.
Can you post your entry diagnostics

@phrak
Copy link
Author

phrak commented Jan 8, 2024

This isn't bug it just Auto configure couldn't find data for your device.

Yep, That's what I thought. Sorry if it was tagged as a bug.

Can you post your entry diagnostics

Full Diags config_entry-localtuya-d6d1c62282b4cf4e32f66d2628357f28.json.txt

@xZetsubou
Copy link
Owner

You can re-download integration via HACS and choose to install "master version" then test if it works :)

@phrak
Copy link
Author

phrak commented Jan 8, 2024

Works perfectly! Thank you!
Solved with commit c5f8bae

image

I'll mark this as solved.

@phrak phrak closed this as completed Jan 8, 2024
@phrak
Copy link
Author

phrak commented Jan 8, 2024

Actually, one minor tweak if it's possible please.

The Sensitivity and Light Level values should be logically reversed.

0 = High Sensitivity
4 = Low Sensitivity

0 = High Light Level
981 = Low Light Level

Not sure if that's possible to represent on the card or not, but thanks for trying.

@phrak phrak reopened this Jan 8, 2024
@xZetsubou
Copy link
Owner

xZetsubou commented Jan 8, 2024

The entity number can have "min" and "max" values, and the "min" can't be greater then "max" otherwise the entity will stuck on minimum value and can't be slide anymore.

It probably possible to make "min" is negative number e.g. -981 and "max" is 0. same for sensitivity -4 to 0. but not sure this the right approach?

@phrak
Copy link
Author

phrak commented Jan 8, 2024

Thank you, I understand. Thanks for considering it.

I know this is beyond the scope of LocalTuya, but are you aware of any way to visually represent the Low/High values on a sliders or some other control card please?

Thank you again!

@xZetsubou
Copy link
Owner

xZetsubou commented Jan 8, 2024

I always use the default "entities" card for numbers entities. if that what you mean.

@phrak
Copy link
Author

phrak commented Jan 9, 2024

Thanks, I'll have a look and see if I can find a way to represent the sliders in a more logical way.

I'll close this issue now, thanks again for your help.

@phrak phrak closed this as completed Jan 9, 2024
@xZetsubou
Copy link
Owner

Just making sure is this also the case in Tuya app? for example if you set the value 981 in HA does it shows 981 in Tuya app as well?

@phrak
Copy link
Author

phrak commented Jan 28, 2024

Just re-opening this issue because of some weird behaviour with this device.
(Please let me know if you would prefer a new issue raised instead)

The PIR sensor has changed behaviour recently - A few weird issues.

Local Tuya Master Branch 4afac6c
Home Assistant:
Core 2024.1.5
Supervisor 2023.12.1
Operating System 11.4
Frontend 20240104.0
Running on RPi4

Weird problems:

  1. I can no longer see the MODE selector for AUTO/ON/OFF in the Device page.
    image

However, the 101 DPID seems to be setup fine in the Device Configuration page.
image

  1. I am unable to change any of the device settings from Home Assistant.
    For example, setting the Sensitivity slider shows as changed on the screen, but does not actually set the device values.
    Same behaviour for the Lux and Timer configurations too.

However!
When I set the values from the Tuya SmartLife app, I can watch the Home Assistant page change in real-time to match.
It's like a one-way configuration.

I have attached an extract of the Debug log file and the Device Diagnostics as well.

home-assistant log extract

Driveway PIR Device Diags localtuya-d6d1c62282b4cf4e32f66d2628357f28-Driveway PIR-e7545994aa5b7596b9e0897555335533.json.txt

Thanks in advance for your awesome work!

@phrak phrak reopened this Jan 28, 2024
@xZetsubou
Copy link
Owner

This is related to #118 if the select platform failed to startup in one device it won't works for other devices

@xZetsubou
Copy link
Owner

any news about this after you fixed your select #118 issue?

@phrak
Copy link
Author

phrak commented Jan 29, 2024

Hi sorry for the delayed reply.

The 1st problem with the missing mode selection was resolved when I fixed #116

The 2nd problem of not being able to change the values still exists.
I think I know why, but I don't know how to test it.

When I set the values via a Scene in Tuya SmartLife, the values are 10x smaller than the display values.
E.g 0.2 instead of 2, and 60 Lux instead of 600.

Would you know how I can test this in HA to verify the theory?

Screenshot_20240129-233228_Tuya_Smart

@xZetsubou
Copy link
Owner

Set the scaling factor to 0.1 on the lux entity configuration.

image

@phrak
Copy link
Author

phrak commented Jan 30, 2024

Hi again,
Thanks - I tried setting the scaling to 0.1, but it doesn't change the behaviour unfortunately.

Changes made to the Lux, Time and Sensitivity attributes via the SmartLife app appear in the Home Assistant device.
But changes made via Home Assistant are not set on the device, and they do not appear on the SmartLife app.

However the MODE setting works fine both ways, so I know the communications are working.

Was there anything of interest in the debug logs above?

Thanks again for your help, I really appreciate it.

@xZetsubou
Copy link
Owner

if my guess is correct I think the value type that being set by localtuya float ? and your device only accept int.
try latest version of master hope it resolved the issue.

@phrak
Copy link
Author

phrak commented Jan 31, 2024

Perfect!
Thank you, the forced integer change on 2e80c00 fixed the problem.

Attribute changes work perfectly in both directions now.

Thanks again for your awesome work.

Closed issue as fixed.

@phrak phrak closed this as completed Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto configure Related to auto configure entities feature.
Projects
None yet
Development

No branches or pull requests

2 participants