mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
Matter energy optimization opt-out attribute (#147096)
* ESAStateEnum * Update snapshot * Add test * Update homeassistant/components/matter/strings.json Co-authored-by: Norbert Rittel <norbert@rittel.de> * Update homeassistant/components/matter/strings.json Co-authored-by: Norbert Rittel <norbert@rittel.de> * Update homeassistant/components/matter/icons.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Update homeassistant/components/matter/sensor.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Update homeassistant/components/matter/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Update sensor.py * Update snapshot --------- Co-authored-by: Norbert Rittel <norbert@rittel.de> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
a11e274434
commit
e98ec38ad8
@ -93,6 +93,9 @@
|
||||
"battery_time_to_full_charge": {
|
||||
"default": "mdi:battery-clock"
|
||||
},
|
||||
"esa_opt_out_state": {
|
||||
"default": "mdi:home-lightning-bolt"
|
||||
},
|
||||
"evse_state": {
|
||||
"default": "mdi:ev-station"
|
||||
},
|
||||
|
@ -93,6 +93,13 @@ CHARGE_STATE_MAP = {
|
||||
clusters.PowerSource.Enums.BatChargeStateEnum.kUnknownEnumValue: None,
|
||||
}
|
||||
|
||||
DEM_OPT_OUT_STATE_MAP = {
|
||||
clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kNoOptOut: "no_opt_out",
|
||||
clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kLocalOptOut: "local_opt_out",
|
||||
clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kGridOptOut: "grid_opt_out",
|
||||
clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kOptOut: "opt_out",
|
||||
}
|
||||
|
||||
ESA_STATE_MAP = {
|
||||
clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOffline: "offline",
|
||||
clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline: "online",
|
||||
@ -1159,6 +1166,19 @@ DISCOVERY_SCHEMAS = [
|
||||
entity_class=MatterSensor,
|
||||
required_attributes=(clusters.DeviceEnergyManagement.Attributes.ESAState,),
|
||||
),
|
||||
MatterDiscoverySchema(
|
||||
platform=Platform.SENSOR,
|
||||
entity_description=MatterSensorEntityDescription(
|
||||
key="ESAOptOutState",
|
||||
translation_key="esa_opt_out_state",
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
options=list(DEM_OPT_OUT_STATE_MAP.values()),
|
||||
measurement_to_ha=DEM_OPT_OUT_STATE_MAP.get,
|
||||
),
|
||||
entity_class=MatterSensor,
|
||||
required_attributes=(clusters.DeviceEnergyManagement.Attributes.OptOutState,),
|
||||
),
|
||||
MatterDiscoverySchema(
|
||||
platform=Platform.SENSOR,
|
||||
entity_description=MatterSensorEntityDescription(
|
||||
|
@ -363,6 +363,15 @@
|
||||
"paused": "[%key:common::state::paused%]"
|
||||
}
|
||||
},
|
||||
"esa_opt_out_state": {
|
||||
"name": "Energy optimization opt-out",
|
||||
"state": {
|
||||
"no_opt_out": "[%key:common::state::off%]",
|
||||
"local_opt_out": "Local",
|
||||
"grid_opt_out": "Grid",
|
||||
"opt_out": "Local and grid"
|
||||
}
|
||||
},
|
||||
"evse_fault_state": {
|
||||
"name": "Fault state",
|
||||
"state": {
|
||||
|
@ -1486,6 +1486,68 @@
|
||||
'state': '0.0',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[battery_storage][sensor.mock_battery_storage_energy_optimization_opt_out-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'options': list([
|
||||
'no_opt_out',
|
||||
'local_opt_out',
|
||||
'grid_opt_out',
|
||||
'opt_out',
|
||||
]),
|
||||
}),
|
||||
'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.mock_battery_storage_energy_optimization_opt_out',
|
||||
'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': 'Energy optimization opt-out',
|
||||
'platform': 'matter',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'esa_opt_out_state',
|
||||
'unique_id': '00000000000004D2-0000000000000019-MatterNodeDevice-1-ESAOptOutState-152-7',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[battery_storage][sensor.mock_battery_storage_energy_optimization_opt_out-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'enum',
|
||||
'friendly_name': 'Mock Battery Storage Energy optimization opt-out',
|
||||
'options': list([
|
||||
'no_opt_out',
|
||||
'local_opt_out',
|
||||
'grid_opt_out',
|
||||
'opt_out',
|
||||
]),
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.mock_battery_storage_energy_optimization_opt_out',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'no_opt_out',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[battery_storage][sensor.mock_battery_storage_power-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
@ -4645,6 +4707,68 @@
|
||||
'state': '32.0',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[silabs_evse_charging][sensor.evse_energy_optimization_opt_out-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'options': list([
|
||||
'no_opt_out',
|
||||
'local_opt_out',
|
||||
'grid_opt_out',
|
||||
'opt_out',
|
||||
]),
|
||||
}),
|
||||
'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.evse_energy_optimization_opt_out',
|
||||
'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': 'Energy optimization opt-out',
|
||||
'platform': 'matter',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'esa_opt_out_state',
|
||||
'unique_id': '00000000000004D2-0000000000000017-MatterNodeDevice-1-ESAOptOutState-152-7',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[silabs_evse_charging][sensor.evse_energy_optimization_opt_out-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'enum',
|
||||
'friendly_name': 'evse Energy optimization opt-out',
|
||||
'options': list([
|
||||
'no_opt_out',
|
||||
'local_opt_out',
|
||||
'grid_opt_out',
|
||||
'opt_out',
|
||||
]),
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.evse_energy_optimization_opt_out',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'no_opt_out',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[silabs_evse_charging][sensor.evse_fault_state-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
@ -5389,6 +5513,68 @@
|
||||
'state': '0.1',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[silabs_water_heater][sensor.water_heater_energy_optimization_opt_out-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'options': list([
|
||||
'no_opt_out',
|
||||
'local_opt_out',
|
||||
'grid_opt_out',
|
||||
'opt_out',
|
||||
]),
|
||||
}),
|
||||
'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.water_heater_energy_optimization_opt_out',
|
||||
'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': 'Energy optimization opt-out',
|
||||
'platform': 'matter',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'esa_opt_out_state',
|
||||
'unique_id': '00000000000004D2-0000000000000019-MatterNodeDevice-2-ESAOptOutState-152-7',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[silabs_water_heater][sensor.water_heater_energy_optimization_opt_out-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'enum',
|
||||
'friendly_name': 'Water Heater Energy optimization opt-out',
|
||||
'options': list([
|
||||
'no_opt_out',
|
||||
'local_opt_out',
|
||||
'grid_opt_out',
|
||||
'opt_out',
|
||||
]),
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.water_heater_energy_optimization_opt_out',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'no_opt_out',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[silabs_water_heater][sensor.water_heater_hot_water_level-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
|
@ -524,6 +524,18 @@ async def test_water_heater(
|
||||
assert state
|
||||
assert state.state == "offline"
|
||||
|
||||
# DeviceEnergyManagement -> OptOutState attribute
|
||||
state = hass.states.get("sensor.water_heater_energy_optimization_opt_out")
|
||||
assert state
|
||||
assert state.state == "no_opt_out"
|
||||
|
||||
set_node_attribute(matter_node, 2, 152, 7, 3)
|
||||
await trigger_subscription_callback(hass, matter_client)
|
||||
|
||||
state = hass.states.get("sensor.water_heater_energy_optimization_opt_out")
|
||||
assert state
|
||||
assert state.state == "opt_out"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("node_fixture", ["pump"])
|
||||
async def test_pump(
|
||||
|
Loading…
x
Reference in New Issue
Block a user