mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Remove the ability for mqtt to set speeds that are not in the speed_list (#45445)
This commit is contained in:
parent
011d5208fd
commit
954ad854fb
@ -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,
|
||||
|
@ -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)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
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)
|
||||
|
||||
|
||||
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
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
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
|
||||
|
||||
|
||||
async def test_custom_speed_list(hass, mqtt_mock):
|
||||
|
Loading…
x
Reference in New Issue
Block a user