Closed gian72 closed 1 year ago
on which version was this?
Hi Leeyuentuen, it happen on latest version on your master branch, but I think that similar issue happens also for older versions
ok, I'll take a look at it. In the meantime, you can use YAML to use Zigbee gateway?
I could use YAML, but I don't know how to configure my thermostatic valves (I didn't find any example implementing climate platform)
I am having the same issue. Tried adding the Gateway via YAML and it does adds there but doesn't show any device entry for that. Also adding subdevice from YAML doesn't work. Enabled debug and see below error entries -
2023-01-12 10:47:48.430 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf7...j3l] Decrypted payload: devid not found 2023-01-12 10:47:48.430 ERROR (MainThread) [custom_components.localtuya.pytuya] [bf7...j3l] Failed to get status for cid bfbfac5d0fba5f2a599mpn: Expecting value: line 1 column 1 (char 0) Traceback (most recent call last): File "/config/custom_components/localtuya/pytuya/init.py", line 684, in detect_available_dps status = await self.status(cid) File "/config/custom_components/localtuya/pytuya/init.py", line 598, in status status = await self.exchange(ACTION_STATUS, cid=cid) File "/config/custom_components/localtuya/pytuya/init.py", line 576, in exchange payload = self._decode_payload(msg.payload) File "/config/custom_components/localtuya/pytuya/init.py", line 788, in _decode_payload return json.loads(payload) File "/usr/local/lib/python3.10/json/init.py", line 346, in loads return _default_decoder.decode(s) File "/usr/local/lib/python3.10/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/lib/python3.10/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
@gian72 and @nigam-sa which value are you providing when adding sub devices? I have TRV valves and no problems at all. I provide NODE-ID values, not local key values
@Anycubic Thanks for pointing this out. Using Node-ID i was able to add the zigbee device and they are working as well so clearly zigbee gateway is working as well but as soon as I click configure under Zigbee Gateay i get the error - 'Config flow could not be loaded: 500 Internal Server Error Server got itself in trouble'
After spending sometime on debugging, this could be due to there isn't any configuration available for zigbee hub.
@leeyuentuen - Is it possible for you handle the below exception in File "/config/custom_components/localtuya/config_flow.py", line 577, in async_step_init
AttributeError: 'LocalTuyaOptionsFlowHandler' object has no attribute 'entities'
@Anycubic Thanks for pointing this out. Using Node-ID i was able to add the zigbee device and they are working as well so clearly zigbee gateway is working as well but as soon as I click configure under Zigbee Gateay i get the error - 'Config flow could not be loaded: 500 Internal Server Error Server got itself in trouble'
After spending sometime on debugging, this could be due to there isn't any configuration available for zigbee hub.
@leeyuentuen - Is it possible for you handle the below exception in File "/config/custom_components/localtuya/config_flow.py", line 577, in async_step_init
AttributeError: 'LocalTuyaOptionsFlowHandler' object has no attribute 'entities'
the entities issue is know issue. i need to fix them when i'm back from holiday. atm no laptop to troubleshooting
Thanks for quick response @leeyuentuen . Enjoy your holidays. I also managed to add zigbee 2 channel dimmer after bit of hit and try.. will send you the details to update for others
@Anycubic: my problem is that after adding gateway, I cannot add any other subdevices
@gian72 i have tried adding gateway via YAML and UI method and both works for me and allows to add subdevice. Have you tried adding via UI method?
@gian72 , I have seen this issue when trying to reconfigure the gateway (same as @nigam-sa). Was this the same for you? The process to add sub-devices is the the normal flow: add integration + select (sub-device) from the 'discovered devices' list + parent gateway is populated (or I guess you select it if you have more than 1) @nigam-sa , looking at your exception you may be using the device id and not the cid (when you get the device information for a sub-device you should have both device id and cid keys)
Hi @alexualbu, using config flow I can only add gateway, then, further operations (e.g. adding sub devices, have an early error). Trying with YAML, I added Gatetway, but didn't manage to add sub-devices
@gian72 , how are you trying to add the sub-devices and what is the error? I am doing it all via the config flow now because I couldn't get the YAML config right for the sub-devices. The steps should be, in the config flow:
Hi @alexualbu, I was able to add both Gateway and subdevices. I used nodeid instead of device id to make subdevice work but everything is working except when you click on configure button for gateway after its added you get error but that's a known error and leeyuentuen mentioned it will be fixed once he's back.
Can you confirm how you get CID of subdevice as I can't get this from iot.tuya?
@nigam-sa, i get them either from iot.tuya (where they're called node_id) or tuya-cli. So it's the same thing.
For the error you can checkout my PR which fixes it - it's not extensively tested, but it works for me.
Thank you @leeyuentuen, I did further steps:
localtuya:
- host: 192.168.1.43
device_id: bfde06e5532b876684yuxq
local_key: XXXXXXXXXXXXX
friendly_name: Tuya Gateway
protocol_version: "3.3"
is_gateway: true # This tells it is to be treated as a gateway and skip adding entities
- parent_gateway: bfde06e5532b876684yuxq # This tells it is a sub-device dependent on a parent gateway
device_id: a4c1385ae1d684ea # The cid of sub-device
friendly_name: Tuya Zigbee TRV
entities:
- platform: sensor
friendly_name: Mode
id: 2
- platform: sensor
friendly_name: Working status
id: 3
- platform: sensor
friendly_name: Set temperature
scaling: 0.1
id: 4
- platform: sensor
friendly_name: Current temperature
scaling: 0.1
id: 5
should entities not in this example? a4c1385ae1d684ea
it should be node-id instead of cid for the sub-devices if i remember correctly
a4c1385ae1d684ea is the id (also called node_id or uuid.. in my tuya.iot) of one TRV valve, that exposes these dps:
With the above YAML, I can see correct values: but obviously, if I dont' set "climate platform" I cannot set target temperature a neither see the right widget in dashboard
i mean that you put the node id in the config flow as entities instead of (keyfa7hya4gfa7g9)
Yes I added a4c1385ae1d684ea, I didnt't see any error, but it seems to do anything (the only configured device is gateway)
@gian72 , you should not go into reconfigure for the gateway to add the TRV (what your seing there is actually the checkbox for is_gateway and the key is the product_key - @leeyuentuen , btw these labels are missing too). you need to add a new integration, select (sub_device) then add the node_id / cid there and it will go in the config flow for the entities.
@alexualbu thanks! it works! :-) Now i just need to detect corrects status: "Heating" / "Pause"
great, @gian72 !
if you are talking about setting the mode then that is here in the climate.py file. If you want it to show the current state, the predefined values are below in HVAC_ACTIONS. My TRVs don't have a DP for the current state, but the current climate logic only works like that I believe. In my case I would need to change that code to update the status based on the valve opening % I guess.
Thanks again @alexualbu @leeyuentuen now it works 100% with config flow :-)
BTW my TRV valves are these: https://m.it.aliexpress.com/item/1005003952150617.html?gatewayAdapt=glo2ita (quite good, even if it seems don't support partial opening)
great to hear, i'll close this issue and put the beta to release
After having sucessfully created zigbee gateway entity (through config flow), trying to call again configuration flow in order to add zigbee entities, I got an error message: ".. 500 Internal Server Error Server got itself in trouble"
Stack trace in the log is this (full log attached)