Add palazzetti status sensor (#131348)
* Add status sensor * Lower the case of strings keys * Make const Final * Fix typo * Fix typo * Merge similar statuses * Increase readability * Update snapshotpull/133392/head
parent
ac6d718094
commit
c0264f73b0
homeassistant/components/palazzetti
tests/components/palazzetti
snapshots
|
@ -4,6 +4,8 @@ from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import Final
|
from typing import Final
|
||||||
|
|
||||||
|
from homeassistant.helpers.typing import StateType
|
||||||
|
|
||||||
DOMAIN: Final = "palazzetti"
|
DOMAIN: Final = "palazzetti"
|
||||||
PALAZZETTI: Final = "Palazzetti"
|
PALAZZETTI: Final = "Palazzetti"
|
||||||
LOGGER = logging.getLogger(__package__)
|
LOGGER = logging.getLogger(__package__)
|
||||||
|
@ -17,3 +19,53 @@ FAN_SILENT: Final = "silent"
|
||||||
FAN_HIGH: Final = "high"
|
FAN_HIGH: Final = "high"
|
||||||
FAN_AUTO: Final = "auto"
|
FAN_AUTO: Final = "auto"
|
||||||
FAN_MODES: Final = [FAN_SILENT, "1", "2", "3", "4", "5", FAN_HIGH, FAN_AUTO]
|
FAN_MODES: Final = [FAN_SILENT, "1", "2", "3", "4", "5", FAN_HIGH, FAN_AUTO]
|
||||||
|
|
||||||
|
STATUS_TO_HA: Final[dict[StateType, str]] = {
|
||||||
|
0: "off",
|
||||||
|
1: "off_timer",
|
||||||
|
2: "test_fire",
|
||||||
|
3: "heatup",
|
||||||
|
4: "fueling",
|
||||||
|
5: "ign_test",
|
||||||
|
6: "burning",
|
||||||
|
7: "burning_mod",
|
||||||
|
8: "unknown",
|
||||||
|
9: "cool_fluid",
|
||||||
|
10: "fire_stop",
|
||||||
|
11: "clean_fire",
|
||||||
|
12: "cooling",
|
||||||
|
50: "cleanup",
|
||||||
|
51: "ecomode",
|
||||||
|
241: "chimney_alarm",
|
||||||
|
243: "grate_error",
|
||||||
|
244: "pellet_water_error",
|
||||||
|
245: "t05_error",
|
||||||
|
247: "hatch_door_open",
|
||||||
|
248: "pressure_error",
|
||||||
|
249: "main_probe_failure",
|
||||||
|
250: "flue_probe_failure",
|
||||||
|
252: "exhaust_temp_high",
|
||||||
|
253: "pellet_finished",
|
||||||
|
501: "off",
|
||||||
|
502: "fueling",
|
||||||
|
503: "ign_test",
|
||||||
|
504: "burning",
|
||||||
|
505: "firewood_finished",
|
||||||
|
506: "cooling",
|
||||||
|
507: "clean_fire",
|
||||||
|
1000: "general_error",
|
||||||
|
1001: "general_error",
|
||||||
|
1239: "door_open",
|
||||||
|
1240: "temp_too_high",
|
||||||
|
1241: "cleaning_warning",
|
||||||
|
1243: "fuel_error",
|
||||||
|
1244: "pellet_water_error",
|
||||||
|
1245: "t05_error",
|
||||||
|
1247: "hatch_door_open",
|
||||||
|
1248: "pressure_error",
|
||||||
|
1249: "main_probe_failure",
|
||||||
|
1250: "flue_probe_failure",
|
||||||
|
1252: "exhaust_temp_high",
|
||||||
|
1253: "pellet_finished",
|
||||||
|
1508: "general_error",
|
||||||
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
|
|
||||||
from . import PalazzettiConfigEntry
|
from . import PalazzettiConfigEntry
|
||||||
|
from .const import STATUS_TO_HA
|
||||||
from .coordinator import PalazzettiDataUpdateCoordinator
|
from .coordinator import PalazzettiDataUpdateCoordinator
|
||||||
from .entity import PalazzettiEntity
|
from .entity import PalazzettiEntity
|
||||||
|
|
||||||
|
@ -23,10 +24,19 @@ class PropertySensorEntityDescription(SensorEntityDescription):
|
||||||
"""Describes a Palazzetti sensor entity that is read from a `PalazzettiClient` property."""
|
"""Describes a Palazzetti sensor entity that is read from a `PalazzettiClient` property."""
|
||||||
|
|
||||||
client_property: str
|
client_property: str
|
||||||
|
property_map: dict[StateType, str] | None = None
|
||||||
presence_flag: None | str = None
|
presence_flag: None | str = None
|
||||||
|
|
||||||
|
|
||||||
PROPERTY_SENSOR_DESCRIPTIONS: list[PropertySensorEntityDescription] = [
|
PROPERTY_SENSOR_DESCRIPTIONS: list[PropertySensorEntityDescription] = [
|
||||||
|
PropertySensorEntityDescription(
|
||||||
|
key="status",
|
||||||
|
device_class=SensorDeviceClass.ENUM,
|
||||||
|
translation_key="status",
|
||||||
|
client_property="status",
|
||||||
|
property_map=STATUS_TO_HA,
|
||||||
|
options=list(STATUS_TO_HA.values()),
|
||||||
|
),
|
||||||
PropertySensorEntityDescription(
|
PropertySensorEntityDescription(
|
||||||
key="pellet_quantity",
|
key="pellet_quantity",
|
||||||
device_class=SensorDeviceClass.WEIGHT,
|
device_class=SensorDeviceClass.WEIGHT,
|
||||||
|
@ -103,4 +113,11 @@ class PalazzettiSensor(PalazzettiEntity, SensorEntity):
|
||||||
def native_value(self) -> StateType:
|
def native_value(self) -> StateType:
|
||||||
"""Return the state value of the sensor."""
|
"""Return the state value of the sensor."""
|
||||||
|
|
||||||
return getattr(self.coordinator.client, self.entity_description.client_property)
|
raw_value = getattr(
|
||||||
|
self.coordinator.client, self.entity_description.client_property
|
||||||
|
)
|
||||||
|
|
||||||
|
if self.entity_description.property_map:
|
||||||
|
return self.entity_description.property_map[raw_value]
|
||||||
|
|
||||||
|
return raw_value
|
||||||
|
|
|
@ -57,6 +57,42 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sensor": {
|
"sensor": {
|
||||||
|
"status": {
|
||||||
|
"name": "Status",
|
||||||
|
"state": {
|
||||||
|
"off": "Off",
|
||||||
|
"off_timer": "Timer-regulated switch off",
|
||||||
|
"test_fire": "Ignition test",
|
||||||
|
"heatup": "Pellet feed",
|
||||||
|
"fueling": "Ignition",
|
||||||
|
"ign_test": "Fuel check",
|
||||||
|
"burning": "Operating",
|
||||||
|
"burning_mod": "Operating - Modulating",
|
||||||
|
"unknown": "Unknown",
|
||||||
|
"cool_fluid": "Stand-by",
|
||||||
|
"fire_stop": "Switch off",
|
||||||
|
"clean_fire": "Burn pot cleaning",
|
||||||
|
"cooling": "Cooling in progress",
|
||||||
|
"cleanup": "Final cleaning",
|
||||||
|
"ecomode": "Ecomode",
|
||||||
|
"chimney_alarm": "Chimney alarm",
|
||||||
|
"grate_error": "Grate error",
|
||||||
|
"pellet_water_error": "Pellet probe or return water error",
|
||||||
|
"t05_error": "T05 error disconnected or faulty probe",
|
||||||
|
"hatch_door_open": "Feed hatch or door open",
|
||||||
|
"pressure_error": "Safety pressure switch error",
|
||||||
|
"main_probe_failure": "Main probe failure",
|
||||||
|
"flue_probe_failure": "Flue gas probe failure",
|
||||||
|
"exhaust_temp_high": "Too high exhaust gas temperature",
|
||||||
|
"pellet_finished": "Pellets finished or ignition failed",
|
||||||
|
"firewood_finished": "Firewood finished",
|
||||||
|
"general_error": "General error",
|
||||||
|
"door_open": "Door open",
|
||||||
|
"temp_too_high": "Temperature too high",
|
||||||
|
"cleaning_warning": "Cleaning warning",
|
||||||
|
"fuel_error": "Fuel error"
|
||||||
|
}
|
||||||
|
},
|
||||||
"pellet_quantity": {
|
"pellet_quantity": {
|
||||||
"name": "Pellet quantity"
|
"name": "Pellet quantity"
|
||||||
},
|
},
|
||||||
|
|
|
@ -66,6 +66,7 @@ def mock_palazzetti_client() -> Generator[AsyncMock]:
|
||||||
mock_client.has_on_off_switch = True
|
mock_client.has_on_off_switch = True
|
||||||
mock_client.has_pellet_level = False
|
mock_client.has_pellet_level = False
|
||||||
mock_client.connected = True
|
mock_client.connected = True
|
||||||
|
mock_client.status = 6
|
||||||
mock_client.is_heating = True
|
mock_client.is_heating = True
|
||||||
mock_client.room_temperature = 18
|
mock_client.room_temperature = 18
|
||||||
mock_client.T1 = 21.5
|
mock_client.T1 = 21.5
|
||||||
|
|
|
@ -305,6 +305,152 @@
|
||||||
'state': '21.5',
|
'state': '21.5',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
|
# name: test_all_entities[sensor.stove_status-entry]
|
||||||
|
EntityRegistryEntrySnapshot({
|
||||||
|
'aliases': set({
|
||||||
|
}),
|
||||||
|
'area_id': None,
|
||||||
|
'capabilities': dict({
|
||||||
|
'options': list([
|
||||||
|
'off',
|
||||||
|
'off_timer',
|
||||||
|
'test_fire',
|
||||||
|
'heatup',
|
||||||
|
'fueling',
|
||||||
|
'ign_test',
|
||||||
|
'burning',
|
||||||
|
'burning_mod',
|
||||||
|
'unknown',
|
||||||
|
'cool_fluid',
|
||||||
|
'fire_stop',
|
||||||
|
'clean_fire',
|
||||||
|
'cooling',
|
||||||
|
'cleanup',
|
||||||
|
'ecomode',
|
||||||
|
'chimney_alarm',
|
||||||
|
'grate_error',
|
||||||
|
'pellet_water_error',
|
||||||
|
't05_error',
|
||||||
|
'hatch_door_open',
|
||||||
|
'pressure_error',
|
||||||
|
'main_probe_failure',
|
||||||
|
'flue_probe_failure',
|
||||||
|
'exhaust_temp_high',
|
||||||
|
'pellet_finished',
|
||||||
|
'off',
|
||||||
|
'fueling',
|
||||||
|
'ign_test',
|
||||||
|
'burning',
|
||||||
|
'firewood_finished',
|
||||||
|
'cooling',
|
||||||
|
'clean_fire',
|
||||||
|
'general_error',
|
||||||
|
'general_error',
|
||||||
|
'door_open',
|
||||||
|
'temp_too_high',
|
||||||
|
'cleaning_warning',
|
||||||
|
'fuel_error',
|
||||||
|
'pellet_water_error',
|
||||||
|
't05_error',
|
||||||
|
'hatch_door_open',
|
||||||
|
'pressure_error',
|
||||||
|
'main_probe_failure',
|
||||||
|
'flue_probe_failure',
|
||||||
|
'exhaust_temp_high',
|
||||||
|
'pellet_finished',
|
||||||
|
'general_error',
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
'config_entry_id': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'disabled_by': None,
|
||||||
|
'domain': 'sensor',
|
||||||
|
'entity_category': None,
|
||||||
|
'entity_id': 'sensor.stove_status',
|
||||||
|
'has_entity_name': True,
|
||||||
|
'hidden_by': None,
|
||||||
|
'icon': None,
|
||||||
|
'id': <ANY>,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'name': None,
|
||||||
|
'options': dict({
|
||||||
|
}),
|
||||||
|
'original_device_class': <SensorDeviceClass.ENUM: 'enum'>,
|
||||||
|
'original_icon': None,
|
||||||
|
'original_name': 'Status',
|
||||||
|
'platform': 'palazzetti',
|
||||||
|
'previous_unique_id': None,
|
||||||
|
'supported_features': 0,
|
||||||
|
'translation_key': 'status',
|
||||||
|
'unique_id': '11:22:33:44:55:66-status',
|
||||||
|
'unit_of_measurement': None,
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_all_entities[sensor.stove_status-state]
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'device_class': 'enum',
|
||||||
|
'friendly_name': 'Stove Status',
|
||||||
|
'options': list([
|
||||||
|
'off',
|
||||||
|
'off_timer',
|
||||||
|
'test_fire',
|
||||||
|
'heatup',
|
||||||
|
'fueling',
|
||||||
|
'ign_test',
|
||||||
|
'burning',
|
||||||
|
'burning_mod',
|
||||||
|
'unknown',
|
||||||
|
'cool_fluid',
|
||||||
|
'fire_stop',
|
||||||
|
'clean_fire',
|
||||||
|
'cooling',
|
||||||
|
'cleanup',
|
||||||
|
'ecomode',
|
||||||
|
'chimney_alarm',
|
||||||
|
'grate_error',
|
||||||
|
'pellet_water_error',
|
||||||
|
't05_error',
|
||||||
|
'hatch_door_open',
|
||||||
|
'pressure_error',
|
||||||
|
'main_probe_failure',
|
||||||
|
'flue_probe_failure',
|
||||||
|
'exhaust_temp_high',
|
||||||
|
'pellet_finished',
|
||||||
|
'off',
|
||||||
|
'fueling',
|
||||||
|
'ign_test',
|
||||||
|
'burning',
|
||||||
|
'firewood_finished',
|
||||||
|
'cooling',
|
||||||
|
'clean_fire',
|
||||||
|
'general_error',
|
||||||
|
'general_error',
|
||||||
|
'door_open',
|
||||||
|
'temp_too_high',
|
||||||
|
'cleaning_warning',
|
||||||
|
'fuel_error',
|
||||||
|
'pellet_water_error',
|
||||||
|
't05_error',
|
||||||
|
'hatch_door_open',
|
||||||
|
'pressure_error',
|
||||||
|
'main_probe_failure',
|
||||||
|
'flue_probe_failure',
|
||||||
|
'exhaust_temp_high',
|
||||||
|
'pellet_finished',
|
||||||
|
'general_error',
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'sensor.stove_status',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'burning',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
# name: test_all_entities[sensor.stove_tank_water_temperature-entry]
|
# name: test_all_entities[sensor.stove_tank_water_temperature-entry]
|
||||||
EntityRegistryEntrySnapshot({
|
EntityRegistryEntrySnapshot({
|
||||||
'aliases': set({
|
'aliases': set({
|
||||||
|
|
Loading…
Reference in New Issue