diff --git a/custom_components/localtuya/__init__.py b/custom_components/localtuya/__init__.py index bdcd7ef..1650edc 100644 --- a/custom_components/localtuya/__init__.py +++ b/custom_components/localtuya/__init__.py @@ -1,4 +1,51 @@ -"""The LocalTuya integration integration.""" +"""The LocalTuya integration integration. + +Sample YAML config with all supported entity types (default values +are pre-filled for optional fields): + +localtuya: + - host: 192.168.1.x + device_id: xxxxx + local_key: xxxxx + friendly_name: Tuya Device + protocol_version: "3.3" + entities: + - platform: binary_sensor + friendly_name: Plug Status + id: 1 + device_class: power + state_on: "true" # Optional + state_off: "false" # Optional + + - platform: cover + friendly_name: Device Cover + id: 2 + open_cmd: "on" # Optional + close_cmd: "off" # Optional + stop_cmd: "stop" # Optional + + - platform: fan + friendly_name: Device Fan + id: 3 + + - platform: light + friendly_name: Device Light + id: 4 + + - platform: sensor + friendly_name: Plug Voltage + id: 20 + scaling: 0.1 # Optional + device_class: voltage # Optional + unit_of_measurement: "V" # Optional + + - platform: switch + friendly_name: Plug + id: 1 + current: 18 # Optional + current_consumption: 19 # Optional + voltage: 20 # Optional +""" import asyncio import logging diff --git a/custom_components/localtuya/binary_sensor.py b/custom_components/localtuya/binary_sensor.py index 92361ba..2d7ecb2 100644 --- a/custom_components/localtuya/binary_sensor.py +++ b/custom_components/localtuya/binary_sensor.py @@ -1,20 +1,4 @@ -""" -Platform to prsent any Tuya DP as a binary sensor. - -Sample config yaml - -sensor: - - platform: localtuya - host: 192.168.0.1 - local_key: 1234567891234567 - device_id: 12345678912345671234 - friendly_name: Current - protocol_version: 3.3 - id: 18 - state_on: "true" (optional, default is "true") - state_off: "false" (optional, default is "false") - device_class: current -""" +"""Platform to present any Tuya DP as a binary sensor.""" import logging import voluptuous as vol diff --git a/custom_components/localtuya/cover.py b/custom_components/localtuya/cover.py index 1fb4a36..ec2d1e9 100644 --- a/custom_components/localtuya/cover.py +++ b/custom_components/localtuya/cover.py @@ -1,23 +1,4 @@ -""" -Simple platform to locally control Tuya-based cover devices. - -Sample config yaml: - -cover: - - platform: localtuya #REQUIRED - host: 192.168.0.123 #REQUIRED - local_key: 1234567891234567 #REQUIRED - device_id: 123456789123456789abcd #REQUIRED - name: cover_guests #REQUIRED - friendly_name: Cover guests #REQUIRED - protocol_version: 3.3 #REQUIRED - id: 1 #OPTIONAL - icon: mdi:blinds #OPTIONAL - open_cmd: open #OPTIONAL, default is 'on' - close_cmd: close #OPTIONAL, default is 'off' - stop_cmd: stop #OPTIONAL, default is 'stop' - -""" +"""Platform to locally control Tuya-based cover devices.""" import logging from time import sleep diff --git a/custom_components/localtuya/fan.py b/custom_components/localtuya/fan.py index 4ab07cb..1077672 100644 --- a/custom_components/localtuya/fan.py +++ b/custom_components/localtuya/fan.py @@ -1,19 +1,4 @@ -""" -Simple platform to control LOCALLY Tuya cover devices. - -Sample config yaml - -fan: - - platform: localtuya - host: 192.168.0.123 - local_key: 1234567891234567 - device_id: 123456789123456789abcd - name: fan guests - friendly_name: fan guests - protocol_version: 3.3 - id: 1 - -""" +"""Platform to locally control Tuya-based fan devices.""" import logging from homeassistant.components.fan import ( diff --git a/custom_components/localtuya/light.py b/custom_components/localtuya/light.py index b8ddb9e..0f3ca7c 100644 --- a/custom_components/localtuya/light.py +++ b/custom_components/localtuya/light.py @@ -1,16 +1,4 @@ -""" -Simple platform to control LOCALLY Tuya light devices. - -Sample config yaml - -light: - - platform: localtuya - host: 192.168.0.1 - local_key: 1234567891234567 - device_id: 12345678912345671234 - friendly_name: This Light - protocol_version: 3.3 -""" +"""Platform to locally control Tuya-based light devices.""" import logging from homeassistant.const import CONF_ID diff --git a/custom_components/localtuya/sensor.py b/custom_components/localtuya/sensor.py index 60f1fe5..1d0cc4f 100644 --- a/custom_components/localtuya/sensor.py +++ b/custom_components/localtuya/sensor.py @@ -1,19 +1,4 @@ -""" -Platform to prsent any Tuya DP as a sensor. - -Sample config yaml - -sensor: - - platform: localtuya - host: 192.168.0.1 - local_key: 1234567891234567 - device_id: 12345678912345671234 - friendly_name: Current - protocol_version: 3.3 - id: 18 - unit_of_measurement: mA - device_class: current -""" +"""Platform to present any Tuya DP as a sensor.""" import logging import voluptuous as vol diff --git a/custom_components/localtuya/switch.py b/custom_components/localtuya/switch.py index 381809d..0ae6075 100644 --- a/custom_components/localtuya/switch.py +++ b/custom_components/localtuya/switch.py @@ -1,29 +1,4 @@ -""" -Simple platform to control LOCALLY Tuya switch devices. - -Sample config yaml - -switch: - - platform: localtuya - host: 192.168.0.1 - local_key: 1234567891234567 - device_id: 12345678912345671234 - name: tuya_01 - friendly_name: tuya_01 - protocol_version: 3.3 - switches: - sw01: - name: main_plug - friendly_name: Main Plug - id: 1 - current: 18 - current_consumption: 19 - voltage: 20 - sw02: - name: usb_plug - friendly_name: USB Plug - id: 7 -""" +"""Platform to locally control Tuya-based switch devices.""" import logging import voluptuous as vol