Compare commits
4 commits
dev
...
convert-ma
Author | SHA1 | Date | |
---|---|---|---|
|
a66c1c47c4 | ||
|
d6eb1988d5 | ||
|
e52005b6c2 | ||
|
a0558d159e |
6 changed files with 60 additions and 46 deletions
|
@ -27,7 +27,6 @@ type SelectCluster = (
|
|||
| clusters.RvcRunMode
|
||||
| clusters.RvcCleanMode
|
||||
| clusters.DishwasherMode
|
||||
| clusters.MicrowaveOvenMode
|
||||
| clusters.EnergyEvseMode
|
||||
| clusters.DeviceEnergyManagementMode
|
||||
)
|
||||
|
@ -199,18 +198,6 @@ DISCOVERY_SCHEMAS = [
|
|||
clusters.DishwasherMode.Attributes.SupportedModes,
|
||||
),
|
||||
),
|
||||
MatterDiscoverySchema(
|
||||
platform=Platform.SELECT,
|
||||
entity_description=MatterSelectEntityDescription(
|
||||
key="MatterMicrowaveOvenMode",
|
||||
translation_key="mode",
|
||||
),
|
||||
entity_class=MatterModeSelectEntity,
|
||||
required_attributes=(
|
||||
clusters.MicrowaveOvenMode.Attributes.CurrentMode,
|
||||
clusters.MicrowaveOvenMode.Attributes.SupportedModes,
|
||||
),
|
||||
),
|
||||
MatterDiscoverySchema(
|
||||
platform=Platform.SELECT,
|
||||
entity_description=MatterSelectEntityDescription(
|
||||
|
|
|
@ -52,6 +52,12 @@ AIR_QUALITY_MAP = {
|
|||
clusters.AirQuality.Enums.AirQualityEnum.kUnknownEnumValue: "unknown",
|
||||
}
|
||||
|
||||
MICROWAVE_OVEN_MODE_MAP = {
|
||||
clusters.MicrowaveOvenMode.Enums.ModeTag.kNormal: "normal",
|
||||
clusters.MicrowaveOvenMode.Enums.ModeTag.kDefrost: "defrost",
|
||||
clusters.MicrowaveOvenMode.Enums.ModeTag.kUnknownEnumValue: "unknown",
|
||||
}
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
|
@ -462,4 +468,19 @@ DISCOVERY_SCHEMAS = [
|
|||
required_attributes=(clusters.Switch.Attributes.CurrentPosition,),
|
||||
allow_multi=True, # also used for event entity
|
||||
),
|
||||
MatterDiscoverySchema(
|
||||
platform=Platform.SENSOR,
|
||||
entity_description=MatterSensorEntityDescription(
|
||||
key="MicrowaveOvenMode",
|
||||
translation_key="microwave_oven_mode",
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
state_class=None,
|
||||
# convert to set first to remove the duplicate unknown value
|
||||
options=list(set(MICROWAVE_OVEN_MODE_MAP.values())),
|
||||
measurement_to_ha=lambda x: MICROWAVE_OVEN_MODE_MAP[x],
|
||||
icon="mdi:microwave",
|
||||
),
|
||||
entity_class=MatterSensor,
|
||||
required_attributes=(clusters.MicrowaveOvenMode.Attributes.CurrentMode,),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -163,6 +163,14 @@
|
|||
},
|
||||
"switch_current_position": {
|
||||
"name": "Current switch position"
|
||||
},
|
||||
"microwave_oven_mode": {
|
||||
"name": "Mode",
|
||||
"state": {
|
||||
"normal": "Normal",
|
||||
"defrost": "Defrost",
|
||||
"unknown": "Unknown"
|
||||
}
|
||||
}
|
||||
},
|
||||
"switch": {
|
||||
|
|
|
@ -356,7 +356,7 @@
|
|||
]
|
||||
}
|
||||
],
|
||||
"1/94/1": 0,
|
||||
"1/94/1": 16384,
|
||||
"1/94/65532": 0,
|
||||
"1/94/65533": 1,
|
||||
"1/94/65528": [],
|
||||
|
|
|
@ -25,16 +25,6 @@ async def dimmable_light_node_fixture(
|
|||
)
|
||||
|
||||
|
||||
@pytest.fixture(name="microwave_oven_node")
|
||||
async def microwave_oven_node_fixture(
|
||||
hass: HomeAssistant, matter_client: MagicMock
|
||||
) -> MatterNode:
|
||||
"""Fixture for a microwave oven node."""
|
||||
return await setup_integration_with_node_fixture(
|
||||
hass, "microwave-oven", matter_client
|
||||
)
|
||||
|
||||
|
||||
# This tests needs to be adjusted to remove lingering tasks
|
||||
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
||||
async def test_mode_select_entities(
|
||||
|
@ -87,28 +77,6 @@ async def test_mode_select_entities(
|
|||
|
||||
|
||||
# This tests needs to be adjusted to remove lingering tasks
|
||||
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
||||
async def test_microwave_select_entities(
|
||||
hass: HomeAssistant,
|
||||
matter_client: MagicMock,
|
||||
microwave_oven_node: MatterNode,
|
||||
) -> None:
|
||||
"""Test select entities are created for the MicrowaveOvenMode cluster attributes."""
|
||||
state = hass.states.get("select.microwave_oven_mode")
|
||||
assert state
|
||||
assert state.state == "Normal"
|
||||
assert state.attributes["options"] == [
|
||||
"Normal",
|
||||
"Defrost",
|
||||
]
|
||||
# name should just be Mode (from the translation key)
|
||||
assert state.attributes["friendly_name"] == "Microwave Oven Mode"
|
||||
set_node_attribute(microwave_oven_node, 1, 94, 1, 1)
|
||||
await trigger_subscription_callback(hass, matter_client)
|
||||
state = hass.states.get("select.microwave_oven_mode")
|
||||
assert state.state == "Defrost"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
||||
async def test_attribute_select_entities(
|
||||
hass: HomeAssistant,
|
||||
|
|
|
@ -94,6 +94,16 @@ async def air_purifier_node_fixture(
|
|||
)
|
||||
|
||||
|
||||
@pytest.fixture(name="microwave_oven_mode_node")
|
||||
async def microwave_oven_mode_node_fixture(
|
||||
hass: HomeAssistant, matter_client: MagicMock
|
||||
) -> MatterNode:
|
||||
"""Fixture for an Microwave Oven mode sensor node."""
|
||||
return await setup_integration_with_node_fixture(
|
||||
hass, "microwave-oven", matter_client
|
||||
)
|
||||
|
||||
|
||||
# This tests needs to be adjusted to remove lingering tasks
|
||||
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
||||
async def test_sensor_null_value(
|
||||
|
@ -450,3 +460,23 @@ async def test_air_purifier_sensor(
|
|||
assert state.state == "100"
|
||||
assert state.attributes["state_class"] == "measurement"
|
||||
assert state.attributes["unit_of_measurement"] == "%"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
||||
async def test_microwave_oven_mode_sensor(
|
||||
hass: HomeAssistant,
|
||||
matter_client: MagicMock,
|
||||
microwave_oven_mode_node: MatterNode,
|
||||
) -> None:
|
||||
"""Test Microwave Oven mode sensor is created and shows the correct mode."""
|
||||
# Carbon Dioxide
|
||||
state = hass.states.get("sensor.microwave_oven_mode")
|
||||
assert state
|
||||
assert state.state == "normal"
|
||||
expected_options = [
|
||||
"normal",
|
||||
"defrost",
|
||||
"unknown",
|
||||
]
|
||||
assert set(state.attributes["options"]) == set(expected_options)
|
||||
assert state.attributes["device_class"] == "enum"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue