Add Smart Kettle (bh) device support to Tuya (#58347)

This commit is contained in:
Franck Nijhof 2021-10-25 13:48:43 +02:00 committed by GitHub
parent 640a7fee9d
commit 367c4d3676
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 91 additions and 1 deletions

View file

@ -84,6 +84,7 @@ DEVICE_CLASS_TUYA_LIGHT_MODE = "tuya__light_mode"
DEVICE_CLASS_TUYA_MOTION_SENSITIVITY = "tuya__motion_sensitivity"
DEVICE_CLASS_TUYA_RECORD_MODE = "tuya__record_mode"
DEVICE_CLASS_TUYA_RELAY_STATUS = "tuya__relay_status"
DEVICE_CLASS_TUYA_STATUS = "tuya__status"
TUYA_DISCOVERY_NEW = "tuya_discovery_new"
TUYA_HA_SIGNAL_UPDATE_ENTITY = "tuya_entry_update"
@ -285,6 +286,8 @@ class DPCode(str, Enum):
SWITCH_USB6 = "switch_usb6" # USB 6
SWITCH_VERTICAL = "switch_vertical" # Vertical swing flap switch
SWITCH_VOICE = "switch_voice" # Voice switch
TEMP_BOILING_C = "temp_boiling_c"
TEMP_BOILING_F = "temp_boiling_f"
TEMP_CONTROLLER = "temp_controller"
TEMP_CURRENT = "temp_current" # Current temperature in °C
TEMP_CURRENT_F = "temp_current_f" # Current temperature in °F

View file

@ -21,6 +21,40 @@ from .const import DOMAIN, TUYA_DISCOVERY_NEW, DPCode
# default instructions set of each category end up being a number.
# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq
NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = {
# Smart Kettle
# https://developer.tuya.com/en/docs/iot/fbh?id=K9gf484m21yq7
"bh": (
NumberEntityDescription(
key=DPCode.TEMP_SET,
name="Temperature",
icon="mdi:thermometer",
entity_category=ENTITY_CATEGORY_CONFIG,
),
NumberEntityDescription(
key=DPCode.TEMP_SET_F,
name="Temperature",
icon="mdi:thermometer",
entity_category=ENTITY_CATEGORY_CONFIG,
),
NumberEntityDescription(
key=DPCode.TEMP_BOILING_C,
name="Temperature After Boiling",
icon="mdi:thermometer",
entity_category=ENTITY_CATEGORY_CONFIG,
),
NumberEntityDescription(
key=DPCode.TEMP_BOILING_F,
name="Temperature After Boiling",
icon="mdi:thermometer",
entity_category=ENTITY_CATEGORY_CONFIG,
),
NumberEntityDescription(
key=DPCode.WARM_TIME,
name="Heat Preservation Time",
icon="mdi:timer",
entity_category=ENTITY_CATEGORY_CONFIG,
),
),
# Human Presence Sensor
# https://developer.tuya.com/en/docs/iot/categoryhps?id=Kaiuz42yhn1hs
"hps": (

View file

@ -38,6 +38,7 @@ from homeassistant.helpers.typing import StateType
from . import HomeAssistantTuyaData
from .base import EnumTypeData, IntegerTypeData, TuyaEntity
from .const import (
DEVICE_CLASS_TUYA_STATUS,
DEVICE_CLASS_UNITS,
DOMAIN,
TUYA_DISCOVERY_NEW,
@ -82,6 +83,27 @@ BATTERY_SENSORS: tuple[SensorEntityDescription, ...] = (
# end up being a sensor.
# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq
SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = {
# Smart Kettle
# https://developer.tuya.com/en/docs/iot/fbh?id=K9gf484m21yq7
"bh": (
SensorEntityDescription(
key=DPCode.TEMP_CURRENT,
name="Current Temperature",
device_class=DEVICE_CLASS_TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT,
),
SensorEntityDescription(
key=DPCode.TEMP_CURRENT_F,
name="Current Temperature",
device_class=DEVICE_CLASS_TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT,
),
SensorEntityDescription(
key=DPCode.STATUS,
name="Status",
device_class=DEVICE_CLASS_TUYA_STATUS,
),
),
# CO2 Detector
# https://developer.tuya.com/en/docs/iot/categoryco2bj?id=Kaiuz3wes7yuy
"co2bj": (
@ -515,6 +537,7 @@ class TuyaSensorEntity(TuyaEntity, SensorEntity):
# match Home Assistants requirements.
if (
self.device_class is not None
and not self.device_class.startswith(DOMAIN)
and description.native_unit_of_measurement is None
):
# We cannot have a device class, if the UOM isn't set or the

View file

@ -0,0 +1,15 @@
{
"state": {
"tuya__status": {
"boiling_temp": "Boiling temperature",
"cooling": "Cooling",
"heating_temp": "Heating temperature",
"heating": "Heating",
"reserve_1": "Reserve 1",
"reserve_2": "Reserve 2",
"reserve_3": "Reserve 3",
"standby": "Standby",
"warm": "Heat preservation"
}
}
}

View file

@ -34,7 +34,7 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = {
),
SwitchEntityDescription(
key=DPCode.WARM,
name="Heat preservation",
name="Heat Preservation",
entity_category=ENTITY_CATEGORY_CONFIG,
),
),

View file

@ -0,0 +1,15 @@
{
"state": {
"tuya__status": {
"boiling_temp": "Boiling temperature",
"cooling": "Cooling",
"heating": "Heating",
"heating_temp": "Heating temperature",
"reserve_1": "Reserve 1",
"reserve_2": "Reserve 2",
"reserve_3": "Reserve 3",
"standby": "Standby",
"warm": "Heat preservation"
}
}
}