Update README.md
This commit is contained in:
17
README.md
17
README.md
@@ -1,15 +1,14 @@
|
|||||||
# localtuya-homeassistant
|
# localtuya-homeassistant
|
||||||
local handling for Tuya switch devices and getting parameters from them (as Power Meters: Voltage, Current, Watt)
|
|
||||||
|
|
||||||
|
Local handling for Tuya Devices under Home-Assistant and Hassio, getting parameters from them (as Power Meters: Voltage, Current, Watt)
|
||||||
|
|
||||||
Local handling for Tuya Devices under Home-Assistant and Hassio
|
#How it works:
|
||||||
|
|
||||||
How it works:
|
|
||||||
|
|
||||||
1. Copy switch.py to /custom_components/mytuya/ folder, inside /config folder (via Samba for HASSIO).
|
1. Copy switch.py to /custom_components/mytuya/ folder, inside /config folder (via Samba for HASSIO).
|
||||||
2. Identify on your Home-Assistant logs (putting your logging into debug mode), the different attributes you want to handle by HA.
|
2. Identify on your Home-Assistant logs (putting your logging into debug mode), the different attributes you want to handle by HA.
|
||||||
|
|
||||||
3. Find in the switch.py file that part, and edit it for ID/DPS that is correct for your device.
|
3. Find in the switch.py file that part, and edit it for ID/DPS that is correct for your device.
|
||||||
|
```
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
attrs = {}
|
attrs = {}
|
||||||
@@ -20,8 +19,9 @@ How it works:
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
return attrs
|
return attrs
|
||||||
|
```
|
||||||
4. Use this declaration on your configuration.yaml file (you need to get the 'device_id' and 'local_key' parameters for your device, as it can be obtained on other tutorials on the web:
|
4. Use this declaration on your configuration.yaml file (you need to get the 'device_id' and 'local_key' parameters for your device, as it can be obtained on other tutorials on the web:
|
||||||
|
```
|
||||||
switch:
|
switch:
|
||||||
- platform: localtuya
|
- platform: localtuya
|
||||||
host: 192.168.1.251
|
host: 192.168.1.251
|
||||||
@@ -34,8 +34,10 @@ How it works:
|
|||||||
switch2:
|
switch2:
|
||||||
friendly_name: TUYA_SW01
|
friendly_name: TUYA_SW01
|
||||||
id: 101
|
id: 101
|
||||||
|
```
|
||||||
NOTE: (as many switch declared as the device has, take note that: If your device is composed (ex. one switch with a independent led light in it), this led can be declared as a 'switch'. ¡This Python script does not include RGB handling! (RGB Handling is independent and must be declared as a 'light' custom device, you can search web for examples, but i have not test this).
|
NOTE: (as many switch declared as the device has, take note that: If your device is composed (ex. one switch with a independent led light in it), this led can be declared as a 'switch'. ¡This Python script does not include RGB handling! (RGB Handling is independent and must be declared as a 'light' custom device, you can search web for examples, but i have not test this).
|
||||||
5. Use this declaration on your configuration.yaml file, for stating sensors that handle its attributes:
|
5. Use this declaration on your configuration.yaml file, for stating sensors that handle its attributes:
|
||||||
|
```
|
||||||
sensor:
|
sensor:
|
||||||
- platform: template
|
- platform: template
|
||||||
sensors:
|
sensors:
|
||||||
@@ -51,11 +53,12 @@ How it works:
|
|||||||
value_template: >-
|
value_template: >-
|
||||||
{{ states.switch.TUYA_SW01.attributes.current_consumption }}
|
{{ states.switch.TUYA_SW01.attributes.current_consumption }}
|
||||||
unit_of_measurement: 'W'
|
unit_of_measurement: 'W'
|
||||||
6. If all gone OK, your switch is working, so the sensors are working too.
|
```
|
||||||
|
6. If all gone OK (your device's parameters local_key and device_id are correct), your switch is working, so the sensors are working too.
|
||||||
|
|
||||||
NOTE: You can do as changes as you want in scripts ant/or yaml files. But: You can't declare your "custom_component" as "tuya", tuya is a forbidden word from 0.88 version or so. So if you declare a switch.tuya, the embedded (cloud based) Tuya component will be load instead custom_component one.
|
NOTE: You can do as changes as you want in scripts ant/or yaml files. But: You can't declare your "custom_component" as "tuya", tuya is a forbidden word from 0.88 version or so. So if you declare a switch.tuya, the embedded (cloud based) Tuya component will be load instead custom_component one.
|
||||||
|
|
||||||
Thanks to:
|
#Thanks to:
|
||||||
sean6541, for the working (standard) Python Handler for Tuya devices
|
sean6541, for the working (standard) Python Handler for Tuya devices
|
||||||
some-other-user, i really can't find now, (i will credit/thank him here), who published a partialy Python script that inspired this solution
|
some-other-user, i really can't find now, (i will credit/thank him here), who published a partialy Python script that inspired this solution
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user