TawfikDaim / home_automation

home automation user stories
0 stars 0 forks source link

tuya integration local #57

Open TawfikDaim opened 4 months ago

TawfikDaim commented 4 months ago

Tuya developer

We are using this method to get local keys (there are other methods if the trial expires -> https://www.youtube.com/watch?v=vq2L9c5hDfQ ) https://auth.tuya.com/register?from=http%3A%2F%2Fiot.tuya.com%2F tawfikabdeldaim@gmail.com Company: Daim Technology Regios: USA Egypt tawfikabdeldaim@gmail.com Password: Newipad1! Skip individual or corporate option After login go to Cloud

Image

On project page, edit and select a central Europe data center Go to Devices ;> link device by tuya app Scan the code and all devices from Tuya smart app will be visible on IOT developer
Subscribe to cloud:API Smart Home Basic Service Provides Tuya smart home basic abilities,including App user, device management. Go to project and under authorization click add authorization Now go to API explorer, find ‘Query Device Details’ API and make sure you are in Western Europe data center; then add the device id you got from devices under the project and you will retrieve the local_key

Image

Curtain shutter1: device id: "bf71b19d8fe2389605ctrw": "local_key": "d;Z&?8Aj(awH409u" ip: 192.168.1.31 (ok) SMART IR 1: device id: "bf3ac6d18b99e4284418gz" or “bf3a32daf91c8fdcf8cemx” : "local_key": "4~h{i8YylK[=LQP~" guessing ip: 192.168.1.29 (ok) Living room air condition: device id: "bf71b19d8fe2389605ctrw": "local_key": "local_key": "w;U^f#BBp#Y>aMrp", guessing ip: 10.195.1.122 Lamar door: device id: "bf71b19d8fe2389605ctrw": "local_key": "Ap)d2D5L@YI}>~A&" 10.195.1.207 Master lock: device id: "37867803a4e57c12f81d": "local_key": "2PrRVrL3m.kWu6Cx" nader door: device id: "bfa619d4f350253fa1byoq": "local_key": "MJLEmzbtsf-eFNFH"

Image

Go to Home assistant integration

  1. Make sure the HA Tuya integration is indeed fully removed.
  2. Delete ./custom_components/localtuya Then install Hacs-> Local Tuya

Image

Client ID and Secret from: Access ID/Client ID: qnrmeg3m9hetf8cws7sm Access Secret/Client Secret: 3d4b8735cb774b4caef9cbb77389d4fe

Image

UID from: eu1667041643936bmWft

Image

https://www.google.com/search?q=local+tyua+in+home+assistant&rlz=1C5CHFA_enEG1080EG1091&oq=local+tyua+in+home+assistant&gs_lcrp=EgZjaHJvbWUyBggAEEUYOTILCAEQABgNGBMYgAQyDAgCEAAYBRgNGBMYHtIBCDYzNjVqMGo0qAIAsAIA&sourceid=chrome&ie=UTF-8#fpstate=ive&vld=cid:10bb9acc,vid:VCd0kYWLvMQ,st:0

Debug

Image

The best advice I can give you on this step is to be patient, do NOT try to work all the settings out at once, and be prepared to delete the integration and put it back in. The reason I selected the ID of 3(value: 3) is because it’s the one that I see as mostly likely to be the cover control because it has 3 controls (open, stop, close). Do it like this, jump into the curtain and see if you can see basic controls (it will probably just be an on/off slider). If you have that, then you know you have the correct device ID. If you don’t get that or when you enter the device, it says unavailable, then you’ve got the wrong one, delete the integration and try another one. I would probably try 1 as my second choice. I know this trial and error stinks but it’s the easiest/fastest way I’ve learned how to do this. None of the documentation online matches 100% and in my own house with the same devices, the setup of two of my fans is wildly different than the other 4 despite being the same device. Trial and error is the only way I survived and got all my devices to work. The reason it’s like this is because once you select the device ID, there’s no going back. So if you get it wrong and you want to try another one, you basically have to rip the integration out and put it in using a different ID. All the other settings can be changed if you get them wrong so don’t worry about those just yet.

Once you get confirmation that the device at least has the correct ID and is communicating, then you can go back into the local tuya config for this device and tweak the other settings to give you the bells and whistles (there shouldn’t be many with a curtain). With each change, go into HA settings and reload the tuya integration, then go into the device, see if it controls accurately. If it does, move onto the next functionality, if not, go back into local tuya config and play with the settings again and reload the tuya integration to bring down the new settings and try again.

Position mode should be position The actual position of curtains is 100% for open and 0% for closed. Many of the tuya curtains have to be reversed to be accurate. That’s what these settings are for: 2022-03-20 11_33_11-Greenshot 2022-03-20 11_33_11-Greenshot 723×358 8.54 KB

Current position will give you the current position of the curtain if selected properly and is supported set position will give you the ability to select 25% position and is supported Full opening time is irrelevant because curtains calculate position based on position not time and you already selected position mode above. Again, check the invert position box if you notice 100% is closed and 0% is open for your curtains.