Aha, now I understand, then it makes more sense. This is a protection to prevent HTML injection, & l t ; is indeed the HTML way of dealing with less than (<). I wonder if I can do something with the driver to overcome this issue. Thanks for pointing this out, and good that you found a workaround.
The fix seems to be to feed the escaped key back into the device settings.
// Update the setting in case < got replaced in the original input
device.updateSetting("localKey", [value: localKey.replaceAll('<', '<'), type: "text"])
@holand.ivar FYI, there is something wrong with the lights/driver when the Configure Bulb Mode device setting is set to HSV (native Hubitat). It must be set to HSL for the light to work properly.
Background: (from memory) My lights stopped working in Jan. Well, one or two lights worked but not consistently, the others did not. I troubleshot everything: the phone app worked, the device ID/IP/keys were correct, changes to through the app showed in the device page, but there was no way to control the light (on/off or any control button on the device page, nor any existing rules). I know there was a lot more done to troubleshoot, but nothing worked, and I gave up. Fast forward many months later, I decided for kicks to change the Bulb Mode setting from HSV to HSL on a "broken" light, and it suddenly started working again!
Changed the setting on all lights, and the driver is working perfectly again! Something broke it in the Dec 2023/Jan 2024 driver updates. I suspect it had to do with the scene settings being added. I had been testing the scenes on the light that was set to HSL and the color controls on the ones set to HSV.
I had this issue when first setting up this driver. But my solution was to remove and readd the light into my account as many as time needed until I got a key that worked in the driver!
I am using it with a couple of ledvance bulbs. It works for me. There are some python tools out there that helps you extract the needed keys. It is a bit fiddly but I think I managed to do it using this guide: https://youtu.be/IzmA2VAhecA?si=SsJ6oDJU0Y0PKXUi
You have to make sure your key consists of exactly 16 characters. There has been some issues in the past where the key contained special characters that was eaten by the Hubitat interface. Do not post your key here, but do you see any obvious special characters? Previously "<" and ">" has been problematic, but these was fixed.
Ideally if you can just create a similar key that generates the same error and send to me by PM it would make it much easier for me to debug and fix.
Locate the device under Devices in Hubitat and select the Preferences tab, then you should see this view, which should provide fields for Device IP, ID, and local key.
I was forced to reset my XMCosy lights to connect to a new WiFi. When running the tinytuya scan locally, I get the following, which now includes an error. My tuya developer account is no longer active. The scan shows the same keys, ids, etc as before. I no longer have local control as before.
% python3 -m tinytuya wizard -nocolor
TinyTuya Setup Wizard [1.12.7]
Existing settings:
API Key=<redacted>
Secret=<redacted>
DeviceID=<redacted>
Region=us
Use existing credentials (Y/n): y
Error from Tuya server: Error from Tuya Cloud: Code 28841002: 'No permissions. Your subscription to cloud development plan has expired.'
Check DeviceID and Region
% Tuya % python3 -m tinytuya scan -nocolor
TinyTuya (Tuya device scanner) [1.12.7]
[Loaded devices.json - 6 devices]
Scanning on UDP ports 6666 and 6667 and 7000 for devices for 18 seconds...
Unknown v3.3 Device Product ID = keynremrcjf97twe [Valid Broadcast]:
Address = 192.168.xxx.xxx Device ID = <redacted> (len:22) Local Key = Version = 3.3 Type = default, MAC =
No Stats for 192.168.xxx.xxx: DEVICE KEY required to poll for status
Tree Product ID = keynremrcjf97twe [Valid Broadcast]:
Address = 192.168.xxx.xxx Device ID = <redacted> (len:22) Local Key = <redacted> Version = 3.3 Type = default, MAC = <redacted>
Access rejected by 192.168.xxx.xxx (check key): Unexpected Payload from Device: None
Path Lights Front Product ID = keynremrcjf97twe [Valid Broadcast]:
Address = 192.168.3.81 Device ID = <redacted>(len:22) Local Key = <redacted> Version = 3.3 Type = default, MAC = <redacted>
Access rejected by 192.168.xxx.xxx (check key): Unexpected Payload from Device: None
Path Lights Side Product ID = keynremrcjf97twe [Valid Broadcast]:
Address = 192.168.xxx.xxx Device ID = <redacted> (len:22) Local Key = <redacted> Version = 3.3 Type = default, MAC = <redacted>
Access rejected by 192.168.xxx.xxx (check key): Unexpected Payload from Device: None
Scan completed in 18.0342 seconds
Scan Complete! Found 4 devices.
Broadcasted: 4
Versions: 3.3: 4
Unknown Devices: 1
>> Saving device snapshot data to snapshot.json
EDIT: Keeping the above in case others run into similar issues. Turns out that I have to renew my developers account, then run the wizard again, and then run the local scan for the updated keys.
So does that mean this driver can never be completely independent of the cloud and the tuya account?
Local devices will continue to work until they have to be reset for a different SSID?
New devices can never be added after my free developer account expires again?
Your "Edit:" was going to be my suggestion. I think you are correct in that you need to re-run the whole process if you change the network SSID. Without trying it myself I assume you had to re-pair the devices in the app itself. The keys you found when scanning initially after the re-pairing is actually stored locally on your PC (if i remember correctly), or tinytuya fetches the old information from tuya developer platform.
For security reasons it is a logical choice by Tuya to disable the current key if network changes, somewhat a pain for us, but logical from a security side.
Ideally one should have developed functions to pair the Tuya devices directly to Hubitat, however that requires some serious hacking, if it is at all possible without changing the firmware of the device itself.
So that basically means that I have just under 6 months to add any more Tuya networked devices to my hub and never to change SSID again. Tuya has made free renewal a one time thing.
Since it's a password, yeah, I think it would be a lot of hacking if it could be done at all. I might have to see if I can sniff communications to see what is happening during the adding process.
GOOD NEWS! After going down the proverbial rabbit hole, I discovered that Tuya has moved the Device Management commands from IoT Core (paid with free trial) to Smart Home Basic Service, which doesn't expire. I also discovered that I was still using 1.12.x of tinytuya, and just updated to 1.16.1. Don't know if the newer version has updated the API commands. And looking at the code, I can't make heads or tails of the actual command to see if it's the old or new one.
My problem now is that my developer account is active, so I can't test if the updated tinytuya fixes the need for a developer account with IoT Core service.