LocalTuyaSK - How to Integrate Tuya Devices into Home Assistant via Local Tuya.

(Ako integrovať Tuya zariadenia do Home Assistanta cez Local Tuya.)

Created at: 2021-03-02 08:32:02
Language: NULL
License: MIT

Local Tuya Tutorial SK

How to Integrate Tuya Devices into Home Assistant via Local Tuya.

Dzuris Home, Local Tuya, Tuya

Discord Instagram Twitter

Benefits

  • It works Locally does not use the Cloud, no Tuya Convert is needed.
  • It also works during an Internet outage (ISP).
  • Zero response.

Supported devices and Appky

  • Tuya
  • Smart Life
  • Switches and double switches, etc.
  • Switches
  • Plugs that also measure power consumption (including those with additional USB connectors)
  • Lights
  • Covers
  • Fans
  • Climates (Coming Soon)

Problems and shortcomings

🚨If there is a problem or a shortcoming, connect to Discord HERE and sleep there and I will help you with that.

🚨If something from YAML Config does not work or the YAML Codes that are verified by Fajka will also work, please write it to me on Discord or in a message on Facebook, if something that is not verified and you do it, send me a screen from YAML Code or copy, thank you.

Map

  • 1 required without further immovably .
  • 2.1 Obtaining a KEY / KEY via Tuya IoT .
  • 2.Cors It may happen that we do not show the answer in 2.1 so we will need Cors which only works on Chromium browsers .
  • 2.2 Faster acquisition of key / keys , you can get on par handles all at once plus keys and need only install Node.js .
  • 3 How to add devices to the Home Assistant .
  • 3.2 How to set ID, Current, Current Consumption, Voltage if we have something other than a Switch and an ordinary Socket that does not measure anything.

1

First we will go to the Tuya IoT page we will register there and log in then we will go to the Cloud item we just see TRIAL EDITION in front of it and below that is the Free Trial so we click on the Free Trial and a new card opens and we just give Buy now and we can close the card and go back to the Cloud and put F5 , click on Create, fill in the necessary things that require us after completing, click on create , right in front of us we see our Project that we created, click on it, we see there Authorization Key under it isAccess ID / Client ID: fgdfhg41g4ghf and Access Secret / Client Secret: gh54j5gh4j5gjfhjgh22 we will copy both of these keys somewhere, we will see the Link Device there,then click on the Link devices by App Account and click on Add App Account just shown the QR Code now we go to the applications we have in our mobile or tablet either (Tuya or SmartLife) we press the plus that is in the top right and now we click on the small icon which is completely up in the right and now we can scan the QR KOD that showed us the Tuya IoT , we scan and the link is successful, now we click onDevice List and we will choose Europe and we will see our devices that we want to add to Home Assistant , we willcopyits Device Name / ID somewhere more precisely, it is just below the device name and now we go to the Cloud which is on the left then we click on API Product we find we will go there Smart Home Devices Management then we will give Project we will see there New Authorization we will clickthere and we will choose there our Project which we created and we will give OK , and we can close the Tuya IoT Cloud if we have chosen the variant to obtain the Key (Keys) 2.2 Node.js and CMD .

Tuya

2.1

We will go in Tuya IoT to Cloud then API Explorer in Data Center we will choose our area e.g. Europa click on Get device details we see device_id there : enter the Device Name / ID which we have copied and press Sumbit Request which is below, we just got a response in Response unless you click HERE , we will copy only local_key and we have done if we want from next device local_key we will do the same just use another Device Name / ID .

Tuya

2.Cors

We will install Cors then click up to the right on Cors and put Toggle ON and go back to Tuya IoT and give F5 , go to Cloud then API Explorer in the Data Center select our area e.g. Europa click on Get device details we see device_id there : we insert the Device Name / ID which we have copied and press Sumbit Request which is below, we just got a response in Response and we will copy only local_keyand we are done, if we want from another device local_key we will do the same just use another Device Name / ID .

⚠️Cors only works on Chromium browsers⚠️

Cors

2.2

We will go to the Node.js page and download Node.js and install it and after the installation we will open the CMD Command Line and copy it there

npm i @tuyapi/cli -g
and type enter, when finished we will copy it there
tuya-cli wizard
and give enter after the next exit it will ask us The API key from tuya.com: we will copy our Access ID / Client ID there: we will enter it then Access Secret / Client Secret: we will enter it will now ask us Provide a 'virtual ID' of a device currently registered in the app: we will insert it there and we will give enter again, now the answer (Keys) has come to us, now we are copying it all somewhere and we can turn off CMD.

Node JS Terminal

3

Open your in the Home Assistant HACS click the Integrations look up there Local Tuya install and we restart Home Assistant, open a Configuration we integrations click the + ADD INTEGRATION look up LocalTuya click to select the equipment that we want to add to the Home Assistant put SUMBIT set Name to Key: we will add the answer that came out in CMD / Tuya , the rovanko in CMD is named as in Home Assostant and in Tuya it is local_key, we select the latest protocol, we put SUMBIT next we have the ID there we set 1 (value: False) only if we have only a Switch or an ordinary Socket that does not measure anything, if we want to add something else we will do it accordingly HERE , we see Friendly name there we set the name we want if that given device was named Current it will be 1 (value: False) as well as Current: Consumption and Voltage and we can give SUMBIT and done.

Local Tuya Home Assistant

3.2

Original Tutorial 0.1

Tutorial 0.2

TinyTuya Tutorial 0.3

Socket that does not measure consumption Confirmed that it works

switch:
  - platform: localtuya
    host: 192.168.0.148 #IP ADRESA
    local_key: fdgdfg45f4g54d5fg4d6f5gdf5gd5f46g #LOCAL KEY
    device_id: dfjngnjdfng445gFGSD54 #DEVICE ID
    protocol: 3.3 #3.3 ALEBO 3.1
    current: Optional
    current_consumption: Optional
    voltage: Optional
    switches:
      Napr. Radiator:
        friendly_name: Radiator #Meno ktoré sa bude ukazovať v HA
        id: 1
   # ©Dzuriš Home

Socket that measures consumption Confirmed that it works

switch:
  - platform: localtuya
    host: 192.168.0.148 #IP ADRESA
    local_key: fdgdfg45f4g54d5fg4d6f5gdf5gd5f46g #LOCAL KEY
    device_id: dfjngnjdfng445gFGSD54 #DEVICE ID
    protocol: 3.3 #3.3 ALEBO 3.1
    current: 18
    current_consumption: 19
    voltage: 20
    switches:
      Napr. Radiator:
        friendly_name: Radiator #Meno ktoré sa bude ukazovať v HA
        id: 1
   # ©Dzuriš Home

Covers

cover:
  - platform: localtuya
    host: 192.168.0.148 #IP ADRESA
    local_key: fdgdfg45f4g54d5fg4d6f5gdf5gd5f46g #LOCAL KEY
    device_id: dfjngnjdfng445gFGSD54 #DEVICE ID
    protocol: 3.3 #3.3 ALEBO 3.1
    open_close_cmds: on_off #on_off ALEBO open_close
    positioning_mode: node #none, position ALEBO fake
    currpos_dps: 3 #Voliteľné, požadované iba pre režim poloha
    setpos_dps: 4 #Voliteľné, požadované iba pre režim poloha
    span_time: 25 #Voliteľné, alebo fake
    covers:
      Napr. Covers:
        friendly_name: Covers #Meno ktoré sa bude ukazovať v HA
        id: 2
   # ©Dzuriš Home

Fan

fan:
  - platform: localtuya
    host: 192.168.0.148 #IP ADRESA
    local_key: fdgdfg45f4g54d5fg4d6f5gdf5gd5f46g #LOCAL KEY
    device_id: dfjngnjdfng445gFGSD54 #DEVICE ID
    protocol: 3.3 #3.3 ALEBO 3.1
    fans:
      Napr. Fan:
        friendly_name: Fan #Meno ktoré sa bude ukazovať v HA
        id: 3
   # ©Dzuriš Home

Light

light:
  - platform: localtuya
    host: 192.168.0.148 #IP ADRESA
    local_key: fdgdfg45f4g54d5fg4d6f5gdf5gd5f46g #LOCAL KEY
    device_id: dfjngnjdfng445gFGSD54 #DEVICE ID
    protocol: 3.3 #3.3 ALEBO 3.1
    color_mode: 21 #Voliteľné, zvyčajne 2 alebo 21, predvolené: none
    brightness: 22 #Voliteľné, zvyčajne 3 alebo 22, predvolené: none
    color_temp: 23 #Voliteľné, zvyčajne 4 alebo 23, predvolené: none
    color: 24 #Voliteľné, zvyčajne 5 (RGB:HSV) alebo 24 (HSV), predvolené: none
    brightness_lower: 29 #Voliteľné, zvyčajne 0 alebo 29, predvolené: 29
    brightness_upper: 1000 #Voliteľné, zvyčajne 255 alebo 1000, predvolené: 1000
    color_temp_min_kelvin: 2700 #Voliteľné, predvolené: 2700
    color_temp_max_kelvin: 6500 #Voliteľné, predvolené: 6500
    scene: 25 #Voliteľné, zvyčajne 6 (RGB:HSV) alebo 25 (HSV), predvolené: none
    music_mode: False #Voliteľné, niektoré používajú interný mikrofón, iné telefónny mikrofón. Podporovaný je iba interný mikrofón, predvolené nastavenie: False
    lights:
      Napr. Light:
        friendly_name: Light #Meno ktoré sa bude ukazovať v HA
        id: 4 #Zvyčajne 1 alebo 20
   # ©Dzuriš Home

Sensor

sensor:
  - platform: localtuya
    host: 192.168.0.148 #IP ADRESA
    local_key: fdgdfg45f4g54d5fg4d6f5gdf5gd5f46g #LOCAL KEY
    device_id: dfjngnjdfng445gFGSD54 #DEVICE ID
    protocol: 3.3 #3.3 ALEBO 3.1
    scaling: 0.1 #Voliteľné
    device_class: voltage #Voliteľné
    unit_of_measurement: "V" #Voliteľné
    sensors:
      Napr. Sensor:
        friendly_name: Sensor #Meno ktoré sa bude ukazovať v HA
        id: 20
   # ©Dzuriš Home

Binary Sensor

binary_sensor:
  - platform: localtuya
    host: 192.168.0.148 #IP ADRESA
    local_key: fdgdfg45f4g54d5fg4d6f5gdf5gd5f46g #LOCAL KEY
    device_id: dfjngnjdfng445gFGSD54 #DEVICE ID
    protocol: 3.3 #3.3 ALEBO 3.1
    device_class: power
    state_on: true #Voliteľné
    state_off: false #Voliteľné
    binary_sensors:
      Napr. Binary_Sensor:
        friendly_name: Binary Sensor #Meno ktoré sa bude ukazovať v HA
        id: 1
    # ©Dzuriš Home

Social

Discord Instagram Twitter

Social Stats

Discord Server Twitter Discord Server

Repositary Stats

Issues License Forks Stars