Add sensor platform to Tuya qccdz (EV charger) (#181640)

This commit is contained in:
Oleksandr B
2026-09-08 16:30:01 +02:00
committed by GitHub
parent 5c16d82936
commit 4e49aa6f9e
4 changed files with 482 additions and 0 deletions
+1
View File
@@ -642,6 +642,7 @@ class DPCode(StrEnum):
CH4_SENSOR_STATE = "ch4_sensor_state"
CH4_SENSOR_VALUE = "ch4_sensor_value"
CHARGE_CUR_SET = "charge_cur_set"
CHARGE_ENERGY_ONCE = "charge_energy_once"
CHARGE_STATE = "charge_state"
CHILD_LOCK = "child_lock" # Child lock
CISTERN = "cistern"
+31
View File
@@ -986,6 +986,37 @@ SENSORS: dict[DeviceCategory, tuple[TuyaSensorEntityDescription, ...]] = {
),
*BATTERY_SENSORS,
),
DeviceCategory.QCCDZ: (
TuyaSensorEntityDescription(
key=DPCode.WORK_STATE,
translation_key="charger_status",
),
TuyaSensorEntityDescription(
key=DPCode.FORWARD_ENERGY_TOTAL,
translation_key="total_energy",
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
),
TuyaSensorEntityDescription(
key=DPCode.CHARGE_ENERGY_ONCE,
translation_key="session_energy",
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
),
TuyaSensorEntityDescription(
key=DPCode.POWER_TOTAL,
translation_key="total_power",
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
),
TuyaSensorEntityDescription(
key=DPCode.TEMP_CURRENT,
translation_key="temperature",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
),
),
DeviceCategory.QN: (
TuyaSensorEntityDescription(
key=DPCode.WORK_POWER,
@@ -705,6 +705,19 @@
"cat_weight": {
"name": "Cat weight"
},
"charger_status": {
"name": "Status",
"state": {
"charger_charging": "[%key:common::state::charging%]",
"charger_end": "Finished",
"charger_fault": "[%key:common::state::fault%]",
"charger_free": "[%key:common::state::idle%]",
"charger_free_fault": "Fault while idle",
"charger_insert": "Plugged in",
"charger_pause": "[%key:common::state::paused%]",
"charger_wait": "Waiting"
}
},
"cleaning_area": {
"name": "Cleaning area"
},
@@ -935,6 +948,9 @@
"rolling_brush_life": {
"name": "Rolling brush lifetime"
},
"session_energy": {
"name": "Session energy"
},
"side_brush_life": {
"name": "Side brush lifetime"
},
@@ -481,6 +481,136 @@
'state': '239.6',
})
# ---
# name: test_platform_setup_and_discovery[sensor.ac_charging_control_box_session_energy-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
None,
]),
'area_id': None,
'capabilities': dict({
<SensorEntityCapabilityAttribute.STATE_CLASS: 'state_class'>: <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.ac_charging_control_box_session_energy',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Session energy',
'options': dict({
'sensor': dict({
'suggested_display_precision': 2,
}),
}),
'original_device_class': <SensorDeviceClass.ENERGY: 'energy'>,
'original_icon': None,
'original_name': 'Session energy',
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'session_energy',
'unique_id': 'tuya.qyy1auihjyoogvb7zdccqcharge_energy_once',
'unit_of_measurement': <UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>,
})
# ---
# name: test_platform_setup_and_discovery[sensor.ac_charging_control_box_session_energy-state]
StateSnapshot({
'attributes': ReadOnlyDict({
<EntityStateAttribute.DEVICE_CLASS: 'device_class'>: 'energy',
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'AC charging control box Session energy',
<SensorEntityCapabilityAttribute.STATE_CLASS: 'state_class'>: <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: <UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>,
}),
'context': <ANY>,
'entity_id': 'sensor.ac_charging_control_box_session_energy',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '0.01',
})
# ---
# name: test_platform_setup_and_discovery[sensor.ac_charging_control_box_status-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
None,
]),
'area_id': None,
'capabilities': dict({
<SensorEntityCapabilityAttribute.OPTIONS: 'options'>: list([
'charger_free',
'charger_insert',
'charger_free_fault',
'charger_wait',
'charger_charging',
'charger_pause',
'charger_end',
'charger_fault',
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.ac_charging_control_box_status',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Status',
'options': dict({
}),
'original_device_class': <SensorDeviceClass.ENUM: 'enum'>,
'original_icon': None,
'original_name': 'Status',
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'charger_status',
'unique_id': 'tuya.qyy1auihjyoogvb7zdccqwork_state',
'unit_of_measurement': None,
})
# ---
# name: test_platform_setup_and_discovery[sensor.ac_charging_control_box_status-state]
StateSnapshot({
'attributes': ReadOnlyDict({
<EntityStateAttribute.DEVICE_CLASS: 'device_class'>: 'enum',
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'AC charging control box Status',
<SensorEntityCapabilityAttribute.OPTIONS: 'options'>: list([
'charger_free',
'charger_insert',
'charger_free_fault',
'charger_wait',
'charger_charging',
'charger_pause',
'charger_end',
'charger_fault',
]),
}),
'context': <ANY>,
'entity_id': 'sensor.ac_charging_control_box_status',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'charger_free',
})
# ---
# name: test_platform_setup_and_discovery[sensor.air_purifier_current-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
@@ -7917,6 +8047,310 @@
'state': '237.7',
})
# ---
# name: test_platform_setup_and_discovery[sensor.ev_charger_session_energy-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
None,
]),
'area_id': None,
'capabilities': dict({
<SensorEntityCapabilityAttribute.STATE_CLASS: 'state_class'>: <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.ev_charger_session_energy',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Session energy',
'options': dict({
'sensor': dict({
'suggested_display_precision': 2,
}),
}),
'original_device_class': <SensorDeviceClass.ENERGY: 'energy'>,
'original_icon': None,
'original_name': 'Session energy',
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'session_energy',
'unique_id': 'tuya.lr7th3bpx7masmsdzdccqcharge_energy_once',
'unit_of_measurement': <UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>,
})
# ---
# name: test_platform_setup_and_discovery[sensor.ev_charger_session_energy-state]
StateSnapshot({
'attributes': ReadOnlyDict({
<EntityStateAttribute.DEVICE_CLASS: 'device_class'>: 'energy',
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'EV Charger Session energy',
<SensorEntityCapabilityAttribute.STATE_CLASS: 'state_class'>: <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: <UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>,
}),
'context': <ANY>,
'entity_id': 'sensor.ev_charger_session_energy',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '0.0',
})
# ---
# name: test_platform_setup_and_discovery[sensor.ev_charger_status-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
None,
]),
'area_id': None,
'capabilities': dict({
<SensorEntityCapabilityAttribute.OPTIONS: 'options'>: list([
'charger_free',
'charger_insert',
'charger_free_fault',
'charger_wait',
'charger_charging',
'charger_pause',
'charger_end',
'charger_fault',
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.ev_charger_status',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Status',
'options': dict({
}),
'original_device_class': <SensorDeviceClass.ENUM: 'enum'>,
'original_icon': None,
'original_name': 'Status',
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'charger_status',
'unique_id': 'tuya.lr7th3bpx7masmsdzdccqwork_state',
'unit_of_measurement': None,
})
# ---
# name: test_platform_setup_and_discovery[sensor.ev_charger_status-state]
StateSnapshot({
'attributes': ReadOnlyDict({
<EntityStateAttribute.DEVICE_CLASS: 'device_class'>: 'enum',
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'EV Charger Status',
<SensorEntityCapabilityAttribute.OPTIONS: 'options'>: list([
'charger_free',
'charger_insert',
'charger_free_fault',
'charger_wait',
'charger_charging',
'charger_pause',
'charger_end',
'charger_fault',
]),
}),
'context': <ANY>,
'entity_id': 'sensor.ev_charger_status',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'charger_free',
})
# ---
# name: test_platform_setup_and_discovery[sensor.ev_charger_temperature-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
None,
]),
'area_id': None,
'capabilities': dict({
<SensorEntityCapabilityAttribute.STATE_CLASS: 'state_class'>: <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.ev_charger_temperature',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Temperature',
'options': dict({
'sensor': dict({
'suggested_display_precision': 1,
}),
}),
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
'original_icon': None,
'original_name': 'Temperature',
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'temperature',
'unique_id': 'tuya.lr7th3bpx7masmsdzdccqtemp_current',
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
})
# ---
# name: test_platform_setup_and_discovery[sensor.ev_charger_temperature-state]
StateSnapshot({
'attributes': ReadOnlyDict({
<EntityStateAttribute.DEVICE_CLASS: 'device_class'>: 'temperature',
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'EV Charger Temperature',
<SensorEntityCapabilityAttribute.STATE_CLASS: 'state_class'>: <SensorStateClass.MEASUREMENT: 'measurement'>,
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: <UnitOfTemperature.CELSIUS: '°C'>,
}),
'context': <ANY>,
'entity_id': 'sensor.ev_charger_temperature',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '24.0',
})
# ---
# name: test_platform_setup_and_discovery[sensor.ev_charger_total_energy-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
None,
]),
'area_id': None,
'capabilities': dict({
<SensorEntityCapabilityAttribute.STATE_CLASS: 'state_class'>: <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.ev_charger_total_energy',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Total energy',
'options': dict({
'sensor': dict({
'suggested_display_precision': 2,
}),
}),
'original_device_class': <SensorDeviceClass.ENERGY: 'energy'>,
'original_icon': None,
'original_name': 'Total energy',
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'total_energy',
'unique_id': 'tuya.lr7th3bpx7masmsdzdccqforward_energy_total',
'unit_of_measurement': <UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>,
})
# ---
# name: test_platform_setup_and_discovery[sensor.ev_charger_total_energy-state]
StateSnapshot({
'attributes': ReadOnlyDict({
<EntityStateAttribute.DEVICE_CLASS: 'device_class'>: 'energy',
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'EV Charger Total energy',
<SensorEntityCapabilityAttribute.STATE_CLASS: 'state_class'>: <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: <UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>,
}),
'context': <ANY>,
'entity_id': 'sensor.ev_charger_total_energy',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '0.2',
})
# ---
# name: test_platform_setup_and_discovery[sensor.ev_charger_total_power-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
None,
]),
'area_id': None,
'capabilities': dict({
<SensorEntityCapabilityAttribute.STATE_CLASS: 'state_class'>: <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.ev_charger_total_power',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Total power',
'options': dict({
'sensor': dict({
'suggested_display_precision': 2,
}),
}),
'original_device_class': <SensorDeviceClass.POWER: 'power'>,
'original_icon': None,
'original_name': 'Total power',
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'total_power',
'unique_id': 'tuya.lr7th3bpx7masmsdzdccqpower_total',
'unit_of_measurement': 'kW',
})
# ---
# name: test_platform_setup_and_discovery[sensor.ev_charger_total_power-state]
StateSnapshot({
'attributes': ReadOnlyDict({
<EntityStateAttribute.DEVICE_CLASS: 'device_class'>: 'power',
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'EV Charger Total power',
<SensorEntityCapabilityAttribute.STATE_CLASS: 'state_class'>: <SensorStateClass.MEASUREMENT: 'measurement'>,
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: 'kW',
}),
'context': <ANY>,
'entity_id': 'sensor.ev_charger_total_power',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '0.0',
})
# ---
# name: test_platform_setup_and_discovery[sensor.fenetre_cuisine_battery-entry]
EntityRegistryEntrySnapshot({
'aliases': list([