This is a custom component for home assistant to integrate Tuya switch device locally.
- device id
- local key of the device
This custom component supports both HACS and legacy custom componennts methods.
- Navigate to HACS
- Choose "Integrations"
- Choose "Custom repositories" from the menu at top right of the window
- Add this repository url to "Add custom repository URL"
- Choose "Integration" for "Category"
- Click "Add"
- Find "Tuya Local" and click "Install"
- Download the files
- Copy the folder "custom_components/tuyalocal" to your config folder
This component supports config flow, so you can either configure it in configuration.yaml or add from frontend "Configuration -> Integrations"
switch:
- platform: localtuya
host: 192.168.10.122 # (required) ip addres of the device
local_key: !secret local_key # (required) local key of the device
device_id: !secret device_id # (required) device id
update_interval: 10 # (optional) frequency to update the status in seconds, default: 10
current: 5 # (optional) attribute id for current
current_consumption: 6 #(optional) attribute id for current consumption
voltage: 7 #(optional) attribute id for voltage
switches: # (optional)
switch1:
friendly_name: tuya switch restroom
id: 1
update_interval is different from scan_interval, this value limits the frequency between updates of a tuya device. Default value is 10, generally 3 seconds works fine.
- Navigate to "Configuration -> Integrations"
- Click "+" in "Integrations" tab
- Enter "Tuya Local" in the search box and click to start configuration
Credits: Thanks to @mileperhour for all the work.