Closed zaa94 closed 10 months ago
@zaa94 I am trying to get the same device working (https://www.amazon.de/dp/B09P3VRVVB/ref=pe_27091401_487027711_TE_SCE_dp_2)
I tried it with UI config as well as with your config. In both cases I only see disabled entities:
How did you get it working to sync the entities?
Hey @caco3 ! The UI config did not work for me at all. Did you make sure that the device ID for the valve controller in the config file is the cid
/node_id
for the valve controller and not the device ID Tuya?
Yes, I think so.
This is in configuration.yaml
:
localtuya:
- host: 192.168.1.170
device_id: bf641c545b9e1920da14vi
local_key: V+IuH~QWR`)v6A{r
friendly_name: Front Yard Gateway
protocol_version: "3.4"
is_gateway: true
- parent_gateway: bf641c545b9e1920da14vi
device_id: bf166cmaafamcows
friendly_name: Front Yard Sprinkler
protocol_version: "3.4"
entities:
- platform: switch
friendly_name: Front Yard Sprinkler Valve Switch
id: 1
- platform: sensor
friendly_name: Front Yard Sprinkler Valve Battery
id: 7
device_class: battery
unit_of_measurement: "%"
And this is the discovery output of tuya-cli wizard
:
{
name: 'Wi-Fi hub',
id: 'bf641c545b9e1920da14vi',
key: 'V+IuH~QWR`)v6A{r'
},
{
name: 'Bewässerungscomputer',
id: 'bf166cmaafamcows',
key: 'U=bYOieeUKH6-O5x'
}
@caco3 Yeah it looks like you're using the device ID for the sprinkler controller instead of the cid
. What version of the tuya-cli are you using? The output of tuya-cli wizard
for the WiFi gateway device should be like this:
{
name: 'Front Yard Gateway',
id: '<GW_DEVICE_ID_REDACTED>',
key: '<GW_KEY_REDACTED>',
subDevices: [
{
name: 'Front Yard Valve Controller',
id: 'CONRTOLLER_DEVICE_ID_REDACTED',
cid: '<CONTROLLER_CID_REDACTED>' //USE THIS FOR THE SPRINKLER DEVICE ID IN YOUR CONFIG
}
]
}
@zaa94 Thanks for your support.
I tried now the latest tuya-cli
from https://github.com/TuyaAPI/cli but the wizard still just shows me the output of my previous post, so the cid
is missing.
The tricky part seems to be to get this cid
, as of now I did not yet find a way to get it :(
@caco3 Just played around with the newer APIs on the Tuya IoT and I found a way to get it. You'll want to use the Query Device Details API and your cid
is equal to the value next to uuid
as shown in the screenshot:
Thank you very much! I saw the UUID but did not expect it to be the same as the cid.
And I found the issue of the missing cid on the wizard output: I missed to add the Water Irrigation Timer to the Gateway. Odly it still got found by the wizard. but now as I added it (using the smart phone and the Smart Life app) I now also get the cid.
I am able to see the valve status (dps 1):
> tuya-cli get --ip 192.168.1.170 --id bf641c545b9e1920da14vi --key 'V+IuH~QWR`)v6A{r' --protocol-version 3.3 --cid f2a63e4085f363b6 --full
{
dps: {
'1': true,
'4': 0,
'7': 32,
'9': 7311,
'10': 'cancel',
'11': 599,
'12': 'manual',
'14': false,
'15': 1111
},
cid: 'f2a63e4085f363b6'
}
Also I am able to switch it off:
> tuya-cli set --ip 192.168.1.170 --id bf641c545b9e1920da14vi --key 'V+IuH~QWR`)v6A{r' --protocol-version 3.3 --cid f2a63e4085f363b6 --set off --dps 1
Set succeeded.
But I cant switch it on:
> tuya-cli set --ip 192.168.1.170 --id bf641c545b9e1920da14vi --key 'V+IuH~QWR`)v6A{r' --protocol-version 3.3 --cid f2a63e4085f363b6 --set on --dps 1
Error [ERR_UNHANDLED_ERROR]: Unhandled error. ('Timeout waiting for status response from device id: bf641c545b9e1920da14vi')
at TuyaDevice.emit (events.js:303:17)
at /usr/local/lib/node_modules/@tuyapi/cli/node_modules/tuyapi/index.js:434:12
at Timeout._onTimeout (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/p-timeout/index.js:25:13)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7) {
code: 'ERR_UNHANDLED_ERROR',
context: 'Timeout waiting for status response from device id: bf641c545b9e1920da14vi'
}
Does this work for you?
Appendix: I need to use protocol 3.3, with 3.4 even the cli tool gets errors. But using protocoll 3.3, I can (in HA):
But I can not switch it on or off.
Using the cli tool, I can switch it off, but not on.
So I got it working now with cli, see https://github.com/TuyaAPI/cli/issues/162#issuecomment-1612002727
I guess that this is not yet handled correctly in localtuya
Hi, I'm confused with the different IDs:
I was thinking. is there any chance that the node_id needed to register the subdevice is not the ID that is needed to place the commands? Which would be the device_id or this UUID mentioned above?
thanks for any clarification!
@Gyosa3
Depending on which Tuya API you use, the identifier you want to use in your config.yaml
for the sub-device will be labeled any of these three variables in the JSON: 1) uuid
, 2) node_id
or 3) cid
; these are not to be confused with the sub-device's device_id
you enter into the Tuya API explorer to obtain these identifiers. To reiterate, the uuid
/node_id
/cid
is what you will enter as the device_id
in your config.yaml
only for sub-devices.
In the localtuya API, the uuid
/node_id
/cid
of the sub-device is needed to communicate between the sub-device and the gateway. I agree it is confusing and while it is a separate issue, the identifier used for sub-devices in the config should be named to cid
rather than device_id
.
ok thanks for the confirmation. So at least I understand the rationale up to the point of reading the DPs of subdevices via this identifier.
then I hope that someone will understand why the commands are then in error. I thought that maybe the wrong identifier was passed on but if they are all the same...
Hello, Same issue with a Zigbee generic switch device... I Can fetch its status but cannot control it. However, it was working before I've updated my gateway to latest firmware that seem to use 3.4 protocol. In the previous firmware (which I have not done a backup :/) it was working fine with 3.6 release and 3.3 protocol. Unfortunately I have not found a way to downgrade it...
Hello,
For anybody stumbling on this, there is a patch workaround to fix switch devices and restore its control abilities:
You should add the lines below to the file "/config/custom_components/localtuya/pytuya/init.py", after line 1378, considering you are using the release *"3.7.0 Beta 10"**:
#START - update from yakish777
if cid is not None:
json_data[PARAMETER_DATA][PARAMETER_CID] = cid
#END - update from yakish777
Here is a screenshot on how it should look like:
all credits to the guys from https://github.com/leeyuentuen/localtuya/issues/65
pushed new beta: https://github.com/leeyuentuen/localtuya/releases/tag/3.7.0-beta.12
I have updated to https://github.com/leeyuentuen/localtuya/tree/3.7.0-beta.11 and confirmed it still working ;) Thanks!
The problem
I have two BLE Diivoo water valve timers (Tuya category
sfkzq
) each with a WiFi gateway (Tuya categorywg2
) that I've got setup with v3.7.0b10 . I only have the switch and battery level entities configured as that's all I need for my current setup. Both the switch state and battery level state appear to be syncing correctly, but when I attempt to turn on/off the switch to either valve, nothing happens. According to the logs, it looks like once the payload is sent, it hangs, then once it receives an ACK, it stops.Environment
Configuration
configuration.yaml
orconfig_flow
DP dump
Gateway DPs
Valve Controller DPs
Provide Home Assistant taceback/logs
Additional information
Gateway Information
Valve Controller Information