Remove the ability for mqtt to set speeds that are not in the speed_list (#45445)

This commit is contained in:
J. Nick Koston
2021-01-23 06:24:06 +01:00
committed by GitHub
parent 011d5208fd
commit 954ad854fb
2 changed files with 5 additions and 15 deletions
+1 -1
View File
@@ -365,7 +365,7 @@ class MqttFan(MqttEntity, FanEntity):
elif speed == SPEED_OFF:
mqtt_payload = self._payload["SPEED_OFF"]
else:
mqtt_payload = speed
raise ValueError(f"{speed} is not a valid fan speed")
mqtt.async_publish(
self.hass,
+4 -14
View File
@@ -435,14 +435,8 @@ async def test_sending_mqtt_commands_and_explicit_optimistic(hass, mqtt_mock):
assert state.state is STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_speed(hass, "fan.test", "cUsToM")
mqtt_mock.async_publish.assert_called_once_with(
"speed-command-topic", "cUsToM", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state is STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
with pytest.raises(ValueError):
await common.async_set_speed(hass, "fan.test", "cUsToM")
async def test_attributes(hass, mqtt_mock):
@@ -522,12 +516,8 @@ async def test_attributes(hass, mqtt_mock):
assert state.attributes.get(fan.ATTR_SPEED) == "off"
assert state.attributes.get(fan.ATTR_OSCILLATING) is False
await common.async_set_speed(hass, "fan.test", "cUsToM")
state = hass.states.get("fan.test")
assert state.state is STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
assert state.attributes.get(fan.ATTR_SPEED) == "cUsToM"
assert state.attributes.get(fan.ATTR_OSCILLATING) is False
with pytest.raises(ValueError):
await common.async_set_speed(hass, "fan.test", "cUsToM")
async def test_custom_speed_list(hass, mqtt_mock):