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:
|
elif speed == SPEED_OFF:
|
||||||
mqtt_payload = self._payload["SPEED_OFF"]
|
mqtt_payload = self._payload["SPEED_OFF"]
|
||||||
else:
|
else:
|
||||||
mqtt_payload = speed
|
raise ValueError(f"{speed} is not a valid fan speed")
|
||||||
|
|
||||||
mqtt.async_publish(
|
mqtt.async_publish(
|
||||||
self.hass,
|
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.state is STATE_OFF
|
||||||
assert state.attributes.get(ATTR_ASSUMED_STATE)
|
assert state.attributes.get(ATTR_ASSUMED_STATE)
|
||||||
|
|
||||||
await common.async_set_speed(hass, "fan.test", "cUsToM")
|
with pytest.raises(ValueError):
|
||||||
mqtt_mock.async_publish.assert_called_once_with(
|
await common.async_set_speed(hass, "fan.test", "cUsToM")
|
||||||
"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):
|
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_SPEED) == "off"
|
||||||
assert state.attributes.get(fan.ATTR_OSCILLATING) is False
|
assert state.attributes.get(fan.ATTR_OSCILLATING) is False
|
||||||
|
|
||||||
await common.async_set_speed(hass, "fan.test", "cUsToM")
|
with pytest.raises(ValueError):
|
||||||
state = hass.states.get("fan.test")
|
await common.async_set_speed(hass, "fan.test", "cUsToM")
|
||||||
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):
|
async def test_custom_speed_list(hass, mqtt_mock):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user