Xenomes / Domoticz-TinyTUYA-Plugin

A bridge between Tinytuya and Domoticz
12 stars 7 forks source link

Error: Device not found in Domoticz #126

Open helsdingen opened 1 week ago

helsdingen commented 1 week ago

I installed this plug-in in Domoticz according to the instructions (including installing Python 3.8) on Raspberry 4. Connection to Tuya works and all JSON files are created using the tinytuya commands. Devices (configured as DP instruction) are being found.

Starting the plugin from Domoticz causes 2 errors. The first one is: 2024-10-08 18:04:10.781 Error: Tuya: handleThread: Crypto library does not support GCM line 925 I think that this is no issue since the devices are all version 3.4 or below.

The second error is:

2024-10-08 18:18:47.081 Tuya: Device name=Breaker id=bf7fe490f497c66dd24bxb category=powermeter
2024-10-08 18:18:47.519 Tuya: Device name= Breaker id= bf7fe490f497c66dd24bxb FunctionProperties= [{'code': 'switch_prepayment', 'desc': '{}', 'name': '预付费功能开关', 'type': 'Boolean', 'values': '{}'}, {'code': 'clear_energy', 'desc': '{}', 'name': '电量清零', 'type': 'Boolean', 'values': '{}'}, {'code': 'charge_energy', 'desc': '{"unit":"kW·h","min":0,"max":999999,"scale":2,"step":1}', 'name': '电量充值', 'type': 'Integer', 'values': '{"unit":"kW·h","min":0,"max":999999,"scale":2,"step":1}'}, {'code': 'switch', 'desc': '{}', 'name': '断路器开关', 'type': 'Boolean', 'values': '{}'}, {'code': 'alarm_set_1', 'desc': '{}', 'name': '告警设置1', 'type': 'Raw', 'values': '{}'}, {'code': 'alarm_set_2', 'desc': '{}', 'name': '告警设置2', 'type': 'Raw', 'values': '{}'}, {'code': 'countdown_1', 'desc': '{"unit":"s","min":0,"max":86400,"scale":0,"step":1}', 'name': '开关倒计时', 'type': 'Integer', 'values': '{"unit":"s","min":0,"max":86400,"scale":0,"step":1}'}, {'code': 'cycle_time', 'desc': '{"maxlen":255}', 'name': '循环定时', 'type': 'String', 'values': '{"maxlen":255}'}, {'code': 'random_time', 'desc': '{}', 'name': '随机定时', 'type': 'String', 'values': '{}'}]
2024-10-08 18:18:47.520 Tuya: Device name= Breaker id= bf7fe490f497c66dd24bxb StatusProperties= [{'code': 'total_forward_energy', 'name': '正向总有功电量', 'type': 'Integer', 'values': '{"unit":"kW·h","min":0,"max":99999999,"scale":2,"step":1}'}, {'code': 'phase_a', 'name': '上报A相电压,电流及功率', 'type': 'Raw', 'values': '{}'}, {'code': 'phase_b', 'name': '上报B相电压,电流及功率', 'type': 'Raw', 'values': '{}'}, {'code': 'phase_c', 'name': '上报C相电压,电流及功率', 'type': 'Raw', 'values': '{}'}, {'code': 'fault', 'name': '故障告警', 'type': 'Bitmap', 'values': '{"label":["short_circuit_alarm","surge_alarm","overload_alarm","leakagecurr_alarm","temp_dif_fault","fire_alarm","high_power_alarm","self_test_alarm","ov_cr","unbalance_alarm","ov_vol","undervoltage_alarm","miss_phase_alarm","outage_alarm","magnetism_alarm","credit_alarm","no_balance_alarm","phase_seq_err_alarm","vol_unbalance_alarm","low_current_alarm"]}'}, {'code': 'switch_prepayment', 'name': '预付费功能开关', 'type': 'Boolean', 'values': '{}'}, {'code': 'energy_reset', 'name': '电量清零', 'type': 'Enum', 'values': '{"range":["empty"]}'}, {'code': 'balance_energy', 'name': '剩余可用电量', 'type': 'Integer', 'values': '{"unit":"kW·h","min":0,"max":99999999,"scale":2,"step":1}'}, {'code': 'charge_energy', 'name': '电量充值', 'type': 'Integer', 'values': '{"unit":"kW·h","min":0,"max":999999,"scale":2,"step":1}'}, {'code': 'leakage_current', 'name': '剩余电流', 'type': 'Integer', 'values': '{"unit":"mA","min":0,"max":1000,"scale":0,"step":1}'}, {'code': 'switch', 'name': '断路器开关', 'type': 'Boolean', 'values': '{}'}, {'code': 'alarm_set_1', 'name': '告警设置1', 'type': 'Raw', 'values': '{}'}, {'code': 'alarm_set_2', 'name': '告警设置2', 'type': 'Raw', 'values': '{}'}, {'code': 'temp_current', 'name': '当前温度', 'type': 'Integer', 'values': '{"unit":"℃","min":-20,"max":200,"scale":0,"step":1}'}, {'code': 'countdown_1', 'name': '开关倒计时', 'type': 'Integer', 'values': '{"unit":"s","min":0,"max":86400,"scale":0,"step":1}'}, {'code': 'cycle_time', 'name': '循环定时', 'type': 'String', 'values': '{"maxlen":255}'}, {'code': 'random_time', 'name': '随机定时', 'type': 'String', 'values': '{}'}]
2024-10-08 18:18:47.520 Tuya: Device name= Breaker id= bf7fe490f497c66dd24bxb result= [{'code': 'total_forward_energy', 'value': 18199}, {'code': 'phase_a', 'value': 'CSEAAAAAAAA='}, {'code': 'phase_b', 'value': 'CSEAAAAAAAA='}, {'code': 'phase_c', 'value': 'AAAAAAAAAAA='}, {'code': 'fault', 'value': 0}, {'code': 'switch_prepayment', 'value': False}, {'code': 'clear_energy', 'value': False}, {'code': 'balance_energy', 'value': 0}, {'code': 'charge_energy', 'value': 0}, {'code': 'leakage_current', 'value': 0}, {'code': 'switch', 'value': False}, {'code': 'alarm_set_1', 'value': 'BQEAVQQBAB4='}, {'code': 'alarm_set_2', 'value': 'AQEDIAMBAREEAQCvAgAAFAUAAAA='}, {'code': 'recover_sec', 'value': 1}, {'code': 'recover_cnt', 'value': 30}, {'code': 'temp_current', 'value': 31}, {'code': 'recover_enable', 'value': True}, {'code': 'countdown_1', 'value': 0}, {'code': 'cycle_time', 'value': 'EwAAAAAAAAAAAA=='}, {'code': 'leak_delay', 'value': 20}, {'code': 'random_time', 'value': ''}, {'code': 'switch_inching', 'value': 'AAA8'}, {'code': 'reverse_energy_total', 'value': 0}, {'code': 'power_total', 'value': 0}, {'code': 'power_reactive', 'value': 1}, {'code': 'pa_instant', 'value': 'CSEAAAAAAAAAAAAD6MNG'}, {'code': 'pb_instant', 'value': 'CSEAAAAAAAAAAAAD6MNG'}, {'code': 'pc_instant', 'value': 'AAAAAAAAAAAAAAAD6MNG'}, {'code': 'energy_total', 'value': 1}, {'code': 'energy_all', 'value': 'AABHFwAARxcAAAAAAAAAAAAAAAAAAAAAAAAACgAARw0AAAAAAAAAAAAAAAAAAAAAAAAACgAARw0AAAAA'}, {'code': 'power_factor', 'value': 1000}, {'code': 'power_on_delay', 'value': 5}, {'code': 'alarm_v_delay', 'value': 20}, {'code': 'alarm_over_c_delay', 'value': 20}, {'code': 'alarm_low_c_delay', 'value': 20}, {'code': 'alam_v_cnt', 'value': 3}, {'code': 'alarm_over_c_cnt', 'value': 5}, {'code': 'alarm_low_c_cnt', 'value': 10}, {'code': 'alarm_set3', 'value': 'AQAAAAIAABQDAABk'}, {'code': 'status', 'value': '0'}, {'code': 'status_b', 'value': '0'}, {'code': 'status_c', 'value': '0'}, {'code': 'n_current', 'value': 0}, {'code': 'over_current_cnt', 'value': 0}, {'code': 'lost_current_cnt', 'value': 0}, {'code': 'leak_cnt', 'value': 0}, {'code': 'swithc_power_save', 'value': '2'}, {'code': 'switch_delay', 'value': 0}, {'code': 'energy_pt', 'value': 1}, {'code': 'energy_ct', 'value': 1}]
2024-10-08 18:18:47.520 Tuya: Acquiring GIL for 'onHeartbeatCallback'
2024-10-08 18:18:47.520 Error: Tuya: handleThread: Device not found in Domoticz! Has the device been removed, or is the "Accept New Hardware" option not enabled? line 2220

So every first device (tried multiple devices) is being rejected to be added to Domoticz while it does not exist in Domoticz. "Accept new hardware" is enabled so I would expect the devices being added. No other devices are processed after the first device failed to be added to Domoticz.

I've tried restarting, reconfiguring Tuya and reinstalling software packages bur no success. What is the issue of the devices not being added?

Xenomes commented 1 week ago

On my test system, I encountered the same message:

Crypto library does not support GCM

I used the following line to install the necessary packages and fix the Crypto error:

pip3 install tinytuya PyCryptodome chardet requests==2.23.0 charset-normalizer==3.0.1

The exit on line 2220 occurs when the device list length returns 0. So creation of hardware is blocked.

helsdingen commented 1 week ago

I installed the PyCryptodome, restarted the plugin and rebooted the raspberry but still the same errors. Any other tips?

Xenomes commented 1 week ago

Hi Helsdingen, I can to test the device creation. Could you run debug_discovery.py from the tools directory and upload the dump.json file here, or send it to xenomes@outlook.com?

helsdingen commented 1 week ago

Hi Xenomes,

Attached the dump. When I run the script, the first message is: No device data returnd for Tuya. Trying again!

After that all devices are discovered and recorded in the dump file: dump.json

Xenomes commented 1 week ago

Thanks!

No device data returnd for Tuya. Trying again!

Is not a big issue, Tuya didn't respond to the first call, the script loops five times before error out.

Xenomes commented 1 week ago

Devices are created... afbeelding

Xenomes commented 1 week ago

Try to disable the accept new Hardware Devices.. afbeelding

helsdingen commented 2 days ago

Hi Xenomes,

Thanks for checking. Really appreciate it. Unfortunately, whatever I try with the accept new hardware and allow for 5 minutes, the tags won't be created. Schermafbeelding 2024-10-16 210313

Since it's not your plugin that's the issue, I'll check the Domoticz forum to see if I can get any help. Just to be sure. I'm running Domoticz2022.2 (build 14795). What version did you test on?

Xenomes commented 2 days ago

I have the latest stable and develop, running in Docker. 2022.2 is after the big change if i am not wrong.

helsdingen commented 2 days ago

I just upgaded to 2024.7 but still the same issue

Xenomes commented 2 days ago

Can you Set the switch to red and restart domoticz?

helsdingen commented 2 days ago

Just did, no effect, still Error: Tuya: handleThread: Device not found in Domoticz! Has the device been removed, or is the "Accept New Hardware" option not enabled? line 2220

Xenomes commented 1 day ago

What is the version of the plugin?