core/tests/components/mqtt/test_fan.py

2034 lines
81 KiB
Python
Raw Normal View History

"""Test MQTT fans."""
2021-01-01 21:31:56 +00:00
from unittest.mock import patch
import pytest
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
from voluptuous.error import MultipleInvalid
from homeassistant.components import fan
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
from homeassistant.components.fan import NotValidPresetModeError
from homeassistant.const import (
ATTR_ASSUMED_STATE,
ATTR_SUPPORTED_FEATURES,
STATE_OFF,
STATE_ON,
)
from homeassistant.setup import async_setup_component
from .test_common import (
help_test_availability_when_connection_lost,
2020-03-17 07:09:19 +00:00
help_test_availability_without_topic,
help_test_custom_availability_payload,
help_test_default_availability_payload,
help_test_discovery_broken,
help_test_discovery_removal,
help_test_discovery_update,
help_test_discovery_update_attr,
help_test_discovery_update_unchanged,
help_test_entity_debug_info_message,
help_test_entity_device_info_remove,
help_test_entity_device_info_update,
2020-03-17 07:09:19 +00:00
help_test_entity_device_info_with_connection,
help_test_entity_device_info_with_identifier,
help_test_entity_id_update_discovery_update,
help_test_entity_id_update_subscriptions,
help_test_setting_attribute_via_mqtt_json_message,
2020-03-17 07:09:19 +00:00
help_test_setting_attribute_with_template,
help_test_unique_id,
help_test_update_with_json_attrs_bad_JSON,
help_test_update_with_json_attrs_not_dict,
2019-07-31 19:25:30 +00:00
)
from tests.common import async_fire_mqtt_message
from tests.components.fan import common
2018-10-28 22:49:55 +00:00
2020-03-17 07:09:19 +00:00
DEFAULT_CONFIG = {
fan.DOMAIN: {
"platform": "mqtt",
"name": "test",
2020-03-17 07:09:19 +00:00
"state_topic": "state-topic",
"command_topic": "command-topic",
}
}
2018-10-28 22:49:55 +00:00
async def test_fail_setup_if_no_command_topic(hass, mqtt_mock):
"""Test if command fails with command topic."""
2019-07-31 19:25:30 +00:00
assert await async_setup_component(
hass, fan.DOMAIN, {fan.DOMAIN: {"platform": "mqtt", "name": "test"}}
)
await hass.async_block_till_done()
2019-07-31 19:25:30 +00:00
assert hass.states.get("fan.test") is None
2018-10-28 22:49:55 +00:00
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
async def test_controlling_state_via_topic(hass, mqtt_mock, caplog):
"""Test the controlling state via topic."""
2019-07-31 19:25:30 +00:00
assert await async_setup_component(
hass,
fan.DOMAIN,
{
fan.DOMAIN: {
"platform": "mqtt",
"name": "test",
"state_topic": "state-topic",
"command_topic": "command-topic",
"payload_off": "StAtE_OfF",
"payload_on": "StAtE_On",
"oscillation_state_topic": "oscillation-state-topic",
"oscillation_command_topic": "oscillation-command-topic",
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
2019-07-31 19:25:30 +00:00
"speed_state_topic": "speed-state-topic",
"speed_command_topic": "speed-command-topic",
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
"payload_oscillation_off": "OsC_OfF",
"payload_oscillation_on": "OsC_On",
"percentage_state_topic": "percentage-state-topic",
"percentage_command_topic": "percentage-command-topic",
"preset_mode_state_topic": "preset-mode-state-topic",
"preset_mode_command_topic": "preset-mode-command-topic",
"preset_modes": [
"auto",
"smart",
"whoosh",
"eco",
"breeze",
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
"silent",
],
"speed_range_min": 1,
"speed_range_max": 200,
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
"speeds": ["off", "low"],
2019-07-31 19:25:30 +00:00
"payload_off_speed": "speed_OfF",
"payload_low_speed": "speed_lOw",
"payload_medium_speed": "speed_mEdium",
"payload_high_speed": "speed_High",
}
},
)
await hass.async_block_till_done()
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert not state.attributes.get(ATTR_ASSUMED_STATE)
2019-07-31 19:25:30 +00:00
async_fire_mqtt_message(hass, "state-topic", "StAtE_On")
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_ON
2019-07-31 19:25:30 +00:00
async_fire_mqtt_message(hass, "state-topic", "StAtE_OfF")
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
2019-07-31 19:25:30 +00:00
assert state.attributes.get("oscillating") is False
2019-07-31 19:25:30 +00:00
async_fire_mqtt_message(hass, "oscillation-state-topic", "OsC_On")
state = hass.states.get("fan.test")
assert state.attributes.get("oscillating") is True
2019-07-31 19:25:30 +00:00
async_fire_mqtt_message(hass, "oscillation-state-topic", "OsC_OfF")
state = hass.states.get("fan.test")
assert state.attributes.get("oscillating") is False
assert state.attributes.get("percentage_step") == 1.0
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
async_fire_mqtt_message(hass, "percentage-state-topic", "0")
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 0
async_fire_mqtt_message(hass, "percentage-state-topic", "50")
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 25
async_fire_mqtt_message(hass, "percentage-state-topic", "100")
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 50
async_fire_mqtt_message(hass, "percentage-state-topic", "200")
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 100
async_fire_mqtt_message(hass, "percentage-state-topic", "202")
assert "not a valid speed within the speed range" in caplog.text
caplog.clear()
async_fire_mqtt_message(hass, "percentage-state-topic", "invalid")
assert "not a valid speed within the speed range" in caplog.text
caplog.clear()
async_fire_mqtt_message(hass, "preset-mode-state-topic", "low")
assert "not a valid preset mode" in caplog.text
caplog.clear()
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
async_fire_mqtt_message(hass, "preset-mode-state-topic", "auto")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
state = hass.states.get("fan.test")
assert state.attributes.get("preset_mode") == "auto"
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
async_fire_mqtt_message(hass, "preset-mode-state-topic", "eco")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
state = hass.states.get("fan.test")
assert state.attributes.get("preset_mode") == "eco"
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
async_fire_mqtt_message(hass, "preset-mode-state-topic", "silent")
state = hass.states.get("fan.test")
assert state.attributes.get("preset_mode") == "silent"
async_fire_mqtt_message(hass, "preset-mode-state-topic", "ModeUnknown")
assert "not a valid preset mode" in caplog.text
caplog.clear()
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
2019-07-31 19:25:30 +00:00
assert state.attributes.get("speed") == fan.SPEED_OFF
2019-07-31 19:25:30 +00:00
async_fire_mqtt_message(hass, "speed-state-topic", "speed_lOw")
state = hass.states.get("fan.test")
assert state.attributes.get("speed") == fan.SPEED_LOW
2019-07-31 19:25:30 +00:00
async_fire_mqtt_message(hass, "speed-state-topic", "speed_mEdium")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert "not a valid speed" in caplog.text
caplog.clear()
async_fire_mqtt_message(hass, "speed-state-topic", "speed_High")
assert "not a valid speed" in caplog.text
caplog.clear()
async_fire_mqtt_message(hass, "speed-state-topic", "speed_OfF")
state = hass.states.get("fan.test")
assert state.attributes.get("speed") == fan.SPEED_OFF
async_fire_mqtt_message(hass, "speed-state-topic", "speed_very_high")
assert "not a valid speed" in caplog.text
caplog.clear()
async def test_controlling_state_via_topic_with_different_speed_range(
hass, mqtt_mock, caplog
):
"""Test the controlling state via topic using an alternate speed range."""
assert await async_setup_component(
hass,
fan.DOMAIN,
{
fan.DOMAIN: [
{
"platform": "mqtt",
"name": "test1",
"command_topic": "command-topic",
"percentage_state_topic": "percentage-state-topic1",
"percentage_command_topic": "percentage-command-topic1",
"speed_range_min": 1,
"speed_range_max": 100,
},
{
"platform": "mqtt",
"name": "test2",
"command_topic": "command-topic",
"percentage_state_topic": "percentage-state-topic2",
"percentage_command_topic": "percentage-command-topic2",
"speed_range_min": 1,
"speed_range_max": 200,
},
{
"platform": "mqtt",
"name": "test3",
"command_topic": "command-topic",
"percentage_state_topic": "percentage-state-topic3",
"percentage_command_topic": "percentage-command-topic3",
"speed_range_min": 81,
"speed_range_max": 1023,
},
]
},
)
await hass.async_block_till_done()
async_fire_mqtt_message(hass, "percentage-state-topic1", "100")
state = hass.states.get("fan.test1")
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 100
async_fire_mqtt_message(hass, "percentage-state-topic2", "100")
state = hass.states.get("fan.test2")
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 50
async_fire_mqtt_message(hass, "percentage-state-topic3", "1023")
state = hass.states.get("fan.test3")
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 100
async_fire_mqtt_message(hass, "percentage-state-topic3", "80")
state = hass.states.get("fan.test3")
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 0
state = hass.states.get("fan.test3")
async_fire_mqtt_message(hass, "percentage-state-topic3", "79")
assert "not a valid speed within the speed range" in caplog.text
caplog.clear()
async def test_controlling_state_via_topic_no_percentage_topics(
hass, mqtt_mock, caplog
):
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
"""Test the controlling state via topic without percentage topics."""
assert await async_setup_component(
hass,
fan.DOMAIN,
{
fan.DOMAIN: {
"platform": "mqtt",
"name": "test",
"state_topic": "state-topic",
"command_topic": "command-topic",
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
"speed_state_topic": "speed-state-topic",
"speed_command_topic": "speed-command-topic",
"preset_mode_state_topic": "preset-mode-state-topic",
"preset_mode_command_topic": "preset-mode-command-topic",
"preset_modes": [
"auto",
"smart",
"whoosh",
"eco",
"breeze",
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
],
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
"speeds": ["off", "low", "medium"],
}
},
)
await hass.async_block_till_done()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert not state.attributes.get(ATTR_ASSUMED_STATE)
async_fire_mqtt_message(hass, "preset-mode-state-topic", "smart")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
state = hass.states.get("fan.test")
assert state.attributes.get("preset_mode") == "smart"
assert state.attributes.get(fan.ATTR_PERCENTAGE) is None
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
assert state.attributes.get("speed") == fan.SPEED_OFF
async_fire_mqtt_message(hass, "preset-mode-state-topic", "auto")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
state = hass.states.get("fan.test")
assert state.attributes.get("preset_mode") == "auto"
assert state.attributes.get(fan.ATTR_PERCENTAGE) is None
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
assert state.attributes.get("speed") == fan.SPEED_OFF
async_fire_mqtt_message(hass, "preset-mode-state-topic", "whoosh")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
state = hass.states.get("fan.test")
assert state.attributes.get("preset_mode") == "whoosh"
assert state.attributes.get(fan.ATTR_PERCENTAGE) is None
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
assert state.attributes.get("speed") == fan.SPEED_OFF
async_fire_mqtt_message(hass, "preset-mode-state-topic", "medium")
assert "not a valid preset mode" in caplog.text
caplog.clear()
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
async_fire_mqtt_message(hass, "preset-mode-state-topic", "low")
assert "not a valid preset mode" in caplog.text
caplog.clear()
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
async_fire_mqtt_message(hass, "speed-state-topic", "medium")
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
assert state.attributes.get("preset_mode") == "whoosh"
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 100
2019-07-31 19:25:30 +00:00
assert state.attributes.get("speed") == fan.SPEED_MEDIUM
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
async_fire_mqtt_message(hass, "speed-state-topic", "low")
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
assert state.attributes.get("preset_mode") == "whoosh"
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 50
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.attributes.get("speed") == fan.SPEED_LOW
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
async_fire_mqtt_message(hass, "speed-state-topic", "off")
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
assert state.attributes.get("preset_mode") == "whoosh"
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 0
2019-07-31 19:25:30 +00:00
assert state.attributes.get("speed") == fan.SPEED_OFF
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
async def test_controlling_state_via_topic_and_json_message(hass, mqtt_mock, caplog):
"""Test the controlling state via topic and JSON message (percentage mode)."""
2019-07-31 19:25:30 +00:00
assert await async_setup_component(
hass,
fan.DOMAIN,
{
fan.DOMAIN: {
"platform": "mqtt",
"name": "test",
"state_topic": "state-topic",
"command_topic": "command-topic",
"oscillation_state_topic": "oscillation-state-topic",
"oscillation_command_topic": "oscillation-command-topic",
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
"percentage_state_topic": "percentage-state-topic",
"percentage_command_topic": "percentage-command-topic",
"preset_mode_state_topic": "preset-mode-state-topic",
"preset_mode_command_topic": "preset-mode-command-topic",
"preset_modes": [
"auto",
"smart",
"whoosh",
"eco",
"breeze",
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
"silent",
],
2019-07-31 19:25:30 +00:00
"state_value_template": "{{ value_json.val }}",
"oscillation_value_template": "{{ value_json.val }}",
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
"percentage_value_template": "{{ value_json.val }}",
"preset_mode_value_template": "{{ value_json.val }}",
"speed_range_min": 1,
"speed_range_max": 100,
2019-07-31 19:25:30 +00:00
}
},
)
await hass.async_block_till_done()
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert not state.attributes.get(ATTR_ASSUMED_STATE)
2019-07-31 19:25:30 +00:00
async_fire_mqtt_message(hass, "state-topic", '{"val":"ON"}')
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_ON
2019-07-31 19:25:30 +00:00
async_fire_mqtt_message(hass, "state-topic", '{"val":"OFF"}')
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
2019-07-31 19:25:30 +00:00
assert state.attributes.get("oscillating") is False
2019-07-31 19:25:30 +00:00
async_fire_mqtt_message(hass, "oscillation-state-topic", '{"val":"oscillate_on"}')
state = hass.states.get("fan.test")
assert state.attributes.get("oscillating") is True
2019-07-31 19:25:30 +00:00
async_fire_mqtt_message(hass, "oscillation-state-topic", '{"val":"oscillate_off"}')
state = hass.states.get("fan.test")
assert state.attributes.get("oscillating") is False
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
async_fire_mqtt_message(hass, "percentage-state-topic", '{"val": 1}')
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 1
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
async_fire_mqtt_message(hass, "percentage-state-topic", '{"val": 100}')
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 100
async_fire_mqtt_message(hass, "preset-mode-state-topic", '{"val": "low"}')
assert "not a valid preset mode" in caplog.text
caplog.clear()
async_fire_mqtt_message(hass, "preset-mode-state-topic", '{"val": "auto"}')
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
assert state.attributes.get("preset_mode") == "auto"
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
async_fire_mqtt_message(hass, "preset-mode-state-topic", '{"val": "breeze"}')
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
state = hass.states.get("fan.test")
assert state.attributes.get("preset_mode") == "breeze"
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
async_fire_mqtt_message(hass, "preset-mode-state-topic", '{"val": "silent"}')
state = hass.states.get("fan.test")
assert state.attributes.get("preset_mode") == "silent"
async def test_sending_mqtt_commands_and_optimistic(hass, mqtt_mock, caplog):
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
"""Test optimistic mode without state topic."""
assert await async_setup_component(
hass,
fan.DOMAIN,
{
fan.DOMAIN: {
"platform": "mqtt",
"name": "test",
"command_topic": "command-topic",
"payload_off": "StAtE_OfF",
"payload_on": "StAtE_On",
"oscillation_command_topic": "oscillation-command-topic",
"payload_oscillation_off": "OsC_OfF",
"payload_oscillation_on": "OsC_On",
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
"speed_command_topic": "speed-command-topic",
"percentage_command_topic": "percentage-command-topic",
"preset_mode_command_topic": "preset-mode-command-topic",
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
"speeds": ["off", "low", "medium"],
"preset_modes": [
"whoosh",
"breeze",
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
"silent",
],
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
"payload_off_speed": "speed_OfF",
"payload_low_speed": "speed_lOw",
"payload_medium_speed": "speed_mEdium",
"payload_high_speed": "speed_High",
}
},
)
await hass.async_block_till_done()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_turn_on(hass, "fan.test")
mqtt_mock.async_publish.assert_called_once_with(
"command-topic", "StAtE_On", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_ON
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_turn_off(hass, "fan.test")
mqtt_mock.async_publish.assert_called_once_with(
"command-topic", "StAtE_OfF", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_oscillate(hass, "fan.test", True)
mqtt_mock.async_publish.assert_called_once_with(
"oscillation-command-topic", "OsC_On", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_oscillate(hass, "fan.test", False)
mqtt_mock.async_publish.assert_called_once_with(
"oscillation-command-topic", "OsC_OfF", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
with pytest.raises(MultipleInvalid):
await common.async_set_percentage(hass, "fan.test", -1)
with pytest.raises(MultipleInvalid):
await common.async_set_percentage(hass, "fan.test", 101)
await common.async_set_percentage(hass, "fan.test", 100)
assert mqtt_mock.async_publish.call_count == 2
mqtt_mock.async_publish.assert_any_call("percentage-command-topic", "100", 0, False)
mqtt_mock.async_publish.assert_any_call(
"speed-command-topic", "speed_mEdium", 0, False
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 100
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_percentage(hass, "fan.test", 0)
assert mqtt_mock.async_publish.call_count == 2
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
mqtt_mock.async_publish.assert_any_call("percentage-command-topic", "0", 0, False)
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
mqtt_mock.async_publish.assert_any_call(
"speed-command-topic", "speed_OfF", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 0
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
assert state.attributes.get(fan.ATTR_SPEED) == fan.SPEED_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
await common.async_set_preset_mode(hass, "fan.test", "low")
assert "not a valid preset mode" in caplog.text
caplog.clear()
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
await common.async_set_preset_mode(hass, "fan.test", "medium")
assert "not a valid preset mode" in caplog.text
caplog.clear()
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_set_preset_mode(hass, "fan.test", "whoosh")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
mqtt_mock.async_publish.assert_called_once_with(
"preset-mode-command-topic", "whoosh", 0, False
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PRESET_MODE) == "whoosh"
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_preset_mode(hass, "fan.test", "breeze")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
mqtt_mock.async_publish.assert_called_once_with(
"preset-mode-command-topic", "breeze", 0, False
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PRESET_MODE) == "breeze"
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_preset_mode(hass, "fan.test", "silent")
mqtt_mock.async_publish.assert_called_once_with(
"preset-mode-command-topic", "silent", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PRESET_MODE) == "silent"
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
await common.async_set_speed(hass, "fan.test", fan.SPEED_LOW)
mqtt_mock.async_publish.assert_called_once_with(
"speed-command-topic", "speed_lOw", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
await common.async_set_speed(hass, "fan.test", fan.SPEED_MEDIUM)
mqtt_mock.async_publish.assert_called_once_with(
"speed-command-topic", "speed_mEdium", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
await common.async_set_speed(hass, "fan.test", fan.SPEED_HIGH)
assert "not a valid speed" in caplog.text
caplog.clear()
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
await common.async_set_speed(hass, "fan.test", fan.SPEED_OFF)
mqtt_mock.async_publish.assert_called_once_with(
"speed-command-topic", "speed_OfF", 0, False
)
mqtt_mock.async_publish.reset_mock()
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
async def test_sending_mqtt_commands_with_alternate_speed_range(hass, mqtt_mock):
"""Test the controlling state via topic using an alternate speed range."""
assert await async_setup_component(
hass,
fan.DOMAIN,
{
fan.DOMAIN: [
{
"platform": "mqtt",
"name": "test1",
"command_topic": "command-topic",
"percentage_state_topic": "percentage-state-topic1",
"percentage_command_topic": "percentage-command-topic1",
"speed_range_min": 1,
"speed_range_max": 3,
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
},
{
"platform": "mqtt",
"name": "test2",
"command_topic": "command-topic",
"percentage_state_topic": "percentage-state-topic2",
"percentage_command_topic": "percentage-command-topic2",
"speed_range_min": 1,
"speed_range_max": 200,
},
{
"platform": "mqtt",
"name": "test3",
"command_topic": "command-topic",
"percentage_state_topic": "percentage-state-topic3",
"percentage_command_topic": "percentage-command-topic3",
"speed_range_min": 81,
"speed_range_max": 1023,
},
]
},
)
await hass.async_block_till_done()
await common.async_set_percentage(hass, "fan.test1", 0)
mqtt_mock.async_publish.assert_called_once_with(
"percentage-command-topic1", "0", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test1")
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_percentage(hass, "fan.test1", 33)
mqtt_mock.async_publish.assert_called_once_with(
"percentage-command-topic1", "1", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test1")
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_percentage(hass, "fan.test1", 66)
mqtt_mock.async_publish.assert_called_once_with(
"percentage-command-topic1", "2", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test1")
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_set_percentage(hass, "fan.test1", 100)
mqtt_mock.async_publish.assert_called_once_with(
"percentage-command-topic1", "3", 0, False
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test1")
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_percentage(hass, "fan.test2", 0)
mqtt_mock.async_publish.assert_called_once_with(
"percentage-command-topic2", "0", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test2")
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_percentage(hass, "fan.test2", 100)
mqtt_mock.async_publish.assert_called_once_with(
"percentage-command-topic2", "200", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test2")
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_percentage(hass, "fan.test3", 0)
mqtt_mock.async_publish.assert_called_once_with(
"percentage-command-topic3", "80", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test3")
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_percentage(hass, "fan.test3", 100)
mqtt_mock.async_publish.assert_called_once_with(
"percentage-command-topic3", "1023", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test3")
assert state.attributes.get(ATTR_ASSUMED_STATE)
async def test_sending_mqtt_commands_and_optimistic_no_legacy(hass, mqtt_mock, caplog):
"""Test optimistic mode without state topic without legacy speed command topic."""
assert await async_setup_component(
hass,
fan.DOMAIN,
{
fan.DOMAIN: {
"platform": "mqtt",
"name": "test",
"command_topic": "command-topic",
"percentage_command_topic": "percentage-command-topic",
"preset_mode_command_topic": "preset-mode-command-topic",
"preset_modes": [
"whoosh",
"breeze",
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
"silent",
],
}
},
)
await hass.async_block_till_done()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_turn_on(hass, "fan.test")
mqtt_mock.async_publish.assert_called_once_with("command-topic", "ON", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_ON
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_turn_off(hass, "fan.test")
mqtt_mock.async_publish.assert_called_once_with("command-topic", "OFF", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
with pytest.raises(MultipleInvalid):
await common.async_set_percentage(hass, "fan.test", -1)
with pytest.raises(MultipleInvalid):
await common.async_set_percentage(hass, "fan.test", 101)
await common.async_set_percentage(hass, "fan.test", 100)
mqtt_mock.async_publish.assert_called_once_with(
"percentage-command-topic", "100", 0, False
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 100
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_percentage(hass, "fan.test", 0)
mqtt_mock.async_publish.assert_called_once_with(
"percentage-command-topic", "0", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 0
assert state.attributes.get(fan.ATTR_SPEED) is None
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_preset_mode(hass, "fan.test", "low")
assert "not a valid preset mode" in caplog.text
caplog.clear()
await common.async_set_preset_mode(hass, "fan.test", "auto")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert "not a valid preset mode" in caplog.text
caplog.clear()
await common.async_set_preset_mode(hass, "fan.test", "whoosh")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
mqtt_mock.async_publish.assert_called_once_with(
"preset-mode-command-topic", "whoosh", 0, False
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PRESET_MODE) == "whoosh"
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_preset_mode(hass, "fan.test", "breeze")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
mqtt_mock.async_publish.assert_called_once_with(
"preset-mode-command-topic", "breeze", 0, False
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PRESET_MODE) == "breeze"
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_preset_mode(hass, "fan.test", "silent")
mqtt_mock.async_publish.assert_called_once_with(
"preset-mode-command-topic", "silent", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PRESET_MODE) == "silent"
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_turn_on(hass, "fan.test", percentage=25)
assert mqtt_mock.async_publish.call_count == 2
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
mqtt_mock.async_publish.assert_any_call("command-topic", "ON", 0, False)
mqtt_mock.async_publish.assert_any_call("percentage-command-topic", "25", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_ON
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_turn_off(hass, "fan.test")
mqtt_mock.async_publish.assert_any_call("command-topic", "OFF", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_turn_on(hass, "fan.test", preset_mode="whoosh")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert mqtt_mock.async_publish.call_count == 2
mqtt_mock.async_publish.assert_any_call("command-topic", "ON", 0, False)
mqtt_mock.async_publish.assert_any_call(
"preset-mode-command-topic", "whoosh", 0, False
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_ON
assert state.attributes.get(ATTR_ASSUMED_STATE)
with pytest.raises(NotValidPresetModeError):
await common.async_turn_on(hass, "fan.test", preset_mode="freaking-high")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
async def test_sending_mqtt_command_templates_(hass, mqtt_mock, caplog):
"""Test optimistic mode without state topic without legacy speed command topic."""
assert await async_setup_component(
hass,
fan.DOMAIN,
{
fan.DOMAIN: {
"platform": "mqtt",
"name": "test",
"command_topic": "command-topic",
"command_template": "state: {{ value }}",
"oscillation_command_topic": "oscillation-command-topic",
"oscillation_command_template": "oscillation: {{ value }}",
"percentage_command_topic": "percentage-command-topic",
"percentage_command_template": "percentage: {{ value }}",
"preset_mode_command_topic": "preset-mode-command-topic",
"preset_mode_command_template": "preset_mode: {{ value }}",
"preset_modes": [
"whoosh",
"breeze",
"silent",
],
}
},
)
await hass.async_block_till_done()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_turn_on(hass, "fan.test")
mqtt_mock.async_publish.assert_called_once_with(
"command-topic", "state: ON", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_ON
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_turn_off(hass, "fan.test")
mqtt_mock.async_publish.assert_called_once_with(
"command-topic", "state: OFF", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
with pytest.raises(MultipleInvalid):
await common.async_set_percentage(hass, "fan.test", -1)
with pytest.raises(MultipleInvalid):
await common.async_set_percentage(hass, "fan.test", 101)
await common.async_set_percentage(hass, "fan.test", 100)
mqtt_mock.async_publish.assert_called_once_with(
"percentage-command-topic", "percentage: 100", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 100
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_percentage(hass, "fan.test", 0)
mqtt_mock.async_publish.assert_called_once_with(
"percentage-command-topic", "percentage: 0", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 0
assert state.attributes.get(fan.ATTR_SPEED) is None
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_preset_mode(hass, "fan.test", "low")
assert "not a valid preset mode" in caplog.text
caplog.clear()
await common.async_set_preset_mode(hass, "fan.test", "medium")
assert "not a valid preset mode" in caplog.text
caplog.clear()
await common.async_set_preset_mode(hass, "fan.test", "whoosh")
mqtt_mock.async_publish.assert_called_once_with(
"preset-mode-command-topic", "preset_mode: whoosh", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PRESET_MODE) == "whoosh"
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_preset_mode(hass, "fan.test", "breeze")
mqtt_mock.async_publish.assert_called_once_with(
"preset-mode-command-topic", "preset_mode: breeze", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PRESET_MODE) == "breeze"
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_preset_mode(hass, "fan.test", "silent")
mqtt_mock.async_publish.assert_called_once_with(
"preset-mode-command-topic", "preset_mode: silent", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PRESET_MODE) == "silent"
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_turn_on(hass, "fan.test", percentage=25)
assert mqtt_mock.async_publish.call_count == 2
mqtt_mock.async_publish.assert_any_call("command-topic", "state: ON", 0, False)
mqtt_mock.async_publish.assert_any_call(
"percentage-command-topic", "percentage: 25", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_ON
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_turn_off(hass, "fan.test")
mqtt_mock.async_publish.assert_any_call("command-topic", "state: OFF", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_turn_on(hass, "fan.test", preset_mode="whoosh")
assert mqtt_mock.async_publish.call_count == 2
mqtt_mock.async_publish.assert_any_call("command-topic", "state: ON", 0, False)
mqtt_mock.async_publish.assert_any_call(
"preset-mode-command-topic", "preset_mode: whoosh", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_ON
assert state.attributes.get(ATTR_ASSUMED_STATE)
with pytest.raises(NotValidPresetModeError):
await common.async_turn_on(hass, "fan.test", preset_mode="low")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
async def test_sending_mqtt_commands_and_optimistic_no_percentage_topic(
hass, mqtt_mock, caplog
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
):
"""Test optimistic mode without state topic without percentage command topic."""
assert await async_setup_component(
hass,
fan.DOMAIN,
{
fan.DOMAIN: {
"platform": "mqtt",
"name": "test",
"command_topic": "command-topic",
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
"speed_state_topic": "speed-state-topic",
"speed_command_topic": "speed-command-topic",
"preset_mode_command_topic": "preset-mode-command-topic",
"preset_mode_state_topic": "preset-mode-state-topic",
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
"speeds": ["off", "low", "medium"],
"preset_modes": [
"whoosh",
"breeze",
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
"silent",
"high",
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
],
}
},
)
await hass.async_block_till_done()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
with pytest.raises(MultipleInvalid):
await common.async_set_percentage(hass, "fan.test", -1)
with pytest.raises(MultipleInvalid):
await common.async_set_percentage(hass, "fan.test", 101)
await common.async_set_percentage(hass, "fan.test", 100)
mqtt_mock.async_publish.assert_any_call("speed-command-topic", "medium", 0, False)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 100
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_percentage(hass, "fan.test", 0)
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
mqtt_mock.async_publish.assert_any_call("speed-command-topic", "off", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 0
assert state.attributes.get(ATTR_ASSUMED_STATE)
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
await common.async_set_preset_mode(hass, "fan.test", "low")
assert "not a valid preset mode" in caplog.text
caplog.clear()
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_set_preset_mode(hass, "fan.test", "medium")
assert "not a valid preset mode" in caplog.text
caplog.clear()
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_set_preset_mode(hass, "fan.test", "whoosh")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
mqtt_mock.async_publish.assert_called_once_with(
"preset-mode-command-topic", "whoosh", 0, False
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PRESET_MODE) is None
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_preset_mode(hass, "fan.test", "breeze")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
mqtt_mock.async_publish.assert_called_once_with(
"preset-mode-command-topic", "breeze", 0, False
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PRESET_MODE) is None
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_preset_mode(hass, "fan.test", "silent")
mqtt_mock.async_publish.assert_called_once_with(
"preset-mode-command-topic", "silent", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PRESET_MODE) is None
assert state.attributes.get(ATTR_ASSUMED_STATE)
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
await common.async_set_speed(hass, "fan.test", fan.SPEED_LOW)
mqtt_mock.async_publish.assert_called_once_with(
"speed-command-topic", "low", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_speed(hass, "fan.test", fan.SPEED_MEDIUM)
mqtt_mock.async_publish.assert_called_once_with(
"speed-command-topic", "medium", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_speed(hass, "fan.test", fan.SPEED_HIGH)
assert "not a valid speed" in caplog.text
caplog.clear()
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_set_speed(hass, "fan.test", fan.SPEED_OFF)
mqtt_mock.async_publish.assert_any_call("speed-command-topic", "off", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_turn_on(hass, "fan.test", speed="medium")
assert mqtt_mock.async_publish.call_count == 2
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
mqtt_mock.async_publish.assert_any_call("command-topic", "ON", 0, False)
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
mqtt_mock.async_publish.assert_any_call("speed-command-topic", "medium", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_ON
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_turn_off(hass, "fan.test")
mqtt_mock.async_publish.assert_called_once_with("command-topic", "OFF", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
await common.async_turn_on(hass, "fan.test", speed="high")
assert mqtt_mock.async_publish.call_count == 2
mqtt_mock.async_publish.assert_any_call("command-topic", "ON", 0, False)
mqtt_mock.async_publish.assert_any_call(
"preset-mode-command-topic", "high", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_ON
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_turn_off(hass, "fan.test")
mqtt_mock.async_publish.assert_called_once_with("command-topic", "OFF", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
async def test_sending_mqtt_commands_and_optimistic_legacy_speeds_only(
hass, mqtt_mock, caplog
):
"""Test optimistic mode without state topics with legacy speeds."""
assert await async_setup_component(
hass,
fan.DOMAIN,
{
fan.DOMAIN: {
"platform": "mqtt",
"name": "test",
"command_topic": "command-topic",
"speed_state_topic": "speed-state-topic",
"speed_command_topic": "speed-command-topic",
"speeds": ["off", "low", "medium", "high"],
}
},
)
await hass.async_block_till_done()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_percentage(hass, "fan.test", 100)
mqtt_mock.async_publish.assert_any_call("speed-command-topic", "high", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 100
assert state.attributes.get(fan.ATTR_SPEED) == "off"
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_percentage(hass, "fan.test", 0)
mqtt_mock.async_publish.assert_any_call("speed-command-topic", "off", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.attributes.get(fan.ATTR_PERCENTAGE) == 0
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_preset_mode(hass, "fan.test", "low")
assert "not a valid preset mode" in caplog.text
caplog.clear()
await common.async_set_speed(hass, "fan.test", fan.SPEED_LOW)
mqtt_mock.async_publish.assert_called_once_with(
"speed-command-topic", "low", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_speed(hass, "fan.test", fan.SPEED_MEDIUM)
mqtt_mock.async_publish.assert_called_once_with(
"speed-command-topic", "medium", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_speed(hass, "fan.test", fan.SPEED_HIGH)
mqtt_mock.async_publish.assert_called_once_with(
"speed-command-topic", "high", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_speed(hass, "fan.test", fan.SPEED_OFF)
mqtt_mock.async_publish.assert_called_once_with(
"speed-command-topic", "off", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_turn_on(hass, "fan.test", speed="medium")
assert mqtt_mock.async_publish.call_count == 2
mqtt_mock.async_publish.assert_any_call("command-topic", "ON", 0, False)
mqtt_mock.async_publish.assert_any_call("speed-command-topic", "medium", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_ON
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_turn_off(hass, "fan.test")
mqtt_mock.async_publish.assert_called_once_with("command-topic", "OFF", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_turn_on(hass, "fan.test", speed="off")
assert mqtt_mock.async_publish.call_count == 2
mqtt_mock.async_publish.assert_any_call("command-topic", "ON", 0, False)
mqtt_mock.async_publish.assert_any_call("speed-command-topic", "off", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_ON
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_turn_off(hass, "fan.test")
mqtt_mock.async_publish.assert_called_once_with("command-topic", "OFF", 0, False)
mqtt_mock.async_publish.reset_mock()
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
async def test_sending_mqtt_commands_and_explicit_optimistic(hass, mqtt_mock, caplog):
"""Test optimistic mode with state topic and turn on attributes."""
2019-07-31 19:25:30 +00:00
assert await async_setup_component(
hass,
fan.DOMAIN,
{
fan.DOMAIN: {
"platform": "mqtt",
"name": "test",
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
"state_topic": "state-topic",
2019-07-31 19:25:30 +00:00
"command_topic": "command-topic",
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
"speed_state_topic": "speed-state-topic",
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
"speed_command_topic": "speed-command-topic",
"oscillation_state_topic": "oscillation-state-topic",
"oscillation_command_topic": "oscillation-command-topic",
"percentage_state_topic": "percentage-state-topic",
"percentage_command_topic": "percentage-command-topic",
"preset_mode_command_topic": "preset-mode-command-topic",
"preset_mode_state_topic": "preset-mode-state-topic",
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
"speeds": ["off", "low", "medium"],
"preset_modes": [
"whoosh",
"breeze",
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
"silent",
],
"optimistic": True,
2019-07-31 19:25:30 +00:00
}
},
)
await hass.async_block_till_done()
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
2019-07-31 19:25:30 +00:00
await common.async_turn_on(hass, "fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
mqtt_mock.async_publish.assert_called_once_with("command-topic", "ON", 0, False)
mqtt_mock.async_publish.reset_mock()
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_ON
assert state.attributes.get(ATTR_ASSUMED_STATE)
2019-07-31 19:25:30 +00:00
await common.async_turn_off(hass, "fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
mqtt_mock.async_publish.assert_called_once_with("command-topic", "OFF", 0, False)
mqtt_mock.async_publish.reset_mock()
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_turn_on(hass, "fan.test", speed=fan.SPEED_MEDIUM)
assert mqtt_mock.async_publish.call_count == 3
mqtt_mock.async_publish.assert_any_call("command-topic", "ON", 0, False)
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
mqtt_mock.async_publish.assert_any_call("speed-command-topic", "medium", 0, False)
mqtt_mock.async_publish.assert_any_call("percentage-command-topic", "100", 0, False)
mqtt_mock.async_publish.reset_mock()
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_ON
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_turn_off(hass, "fan.test")
mqtt_mock.async_publish.assert_called_once_with("command-topic", "OFF", 0, False)
mqtt_mock.async_publish.reset_mock()
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_turn_on(hass, "fan.test", percentage=25)
assert mqtt_mock.async_publish.call_count == 3
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
mqtt_mock.async_publish.assert_any_call("command-topic", "ON", 0, False)
mqtt_mock.async_publish.assert_any_call("percentage-command-topic", "25", 0, False)
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
mqtt_mock.async_publish.assert_any_call("speed-command-topic", "low", 0, False)
mqtt_mock.async_publish.reset_mock()
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_ON
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_turn_off(hass, "fan.test")
mqtt_mock.async_publish.assert_any_call("command-topic", "OFF", 0, False)
mqtt_mock.async_publish.reset_mock()
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
with pytest.raises(NotValidPresetModeError):
await common.async_turn_on(hass, "fan.test", preset_mode="auto")
await common.async_turn_on(hass, "fan.test", preset_mode="whoosh")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert mqtt_mock.async_publish.call_count == 2
mqtt_mock.async_publish.assert_any_call("command-topic", "ON", 0, False)
mqtt_mock.async_publish.assert_any_call(
"preset-mode-command-topic", "whoosh", 0, False
2019-07-31 19:25:30 +00:00
)
mqtt_mock.async_publish.reset_mock()
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_ON
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_turn_off(hass, "fan.test")
mqtt_mock.async_publish.assert_any_call("command-topic", "OFF", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_turn_on(hass, "fan.test", preset_mode="silent")
assert mqtt_mock.async_publish.call_count == 2
mqtt_mock.async_publish.assert_any_call("command-topic", "ON", 0, False)
mqtt_mock.async_publish.assert_any_call(
"preset-mode-command-topic", "silent", 0, False
)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_ON
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_turn_off(hass, "fan.test")
mqtt_mock.async_publish.assert_called_once_with("command-topic", "OFF", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_turn_on(hass, "fan.test", preset_mode="silent")
assert mqtt_mock.async_publish.call_count == 2
mqtt_mock.async_publish.assert_any_call("command-topic", "ON", 0, False)
mqtt_mock.async_publish.assert_any_call(
"preset-mode-command-topic", "silent", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_ON
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_turn_off(hass, "fan.test")
mqtt_mock.async_publish.assert_called_once_with("command-topic", "OFF", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_oscillate(hass, "fan.test", True)
mqtt_mock.async_publish.assert_called_once_with(
"oscillation-command-topic", "oscillate_on", 0, False
)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_turn_on(hass, "fan.test", percentage=50)
assert mqtt_mock.async_publish.call_count == 3
mqtt_mock.async_publish.assert_any_call("command-topic", "ON", 0, False)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
mqtt_mock.async_publish.assert_any_call("percentage-command-topic", "50", 0, False)
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
mqtt_mock.async_publish.assert_any_call("speed-command-topic", "low", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_ON
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_turn_off(hass, "fan.test")
mqtt_mock.async_publish.assert_any_call("command-topic", "OFF", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_oscillate(hass, "fan.test", False)
mqtt_mock.async_publish.assert_called_once_with(
"oscillation-command-topic", "oscillate_off", 0, False
2019-07-31 19:25:30 +00:00
)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_set_percentage(hass, "fan.test", 33)
assert mqtt_mock.async_publish.call_count == 2
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
mqtt_mock.async_publish.assert_any_call("percentage-command-topic", "33", 0, False)
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
mqtt_mock.async_publish.assert_any_call("speed-command-topic", "low", 0, False)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
mqtt_mock.async_publish.reset_mock()
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_set_percentage(hass, "fan.test", 50)
assert mqtt_mock.async_publish.call_count == 2
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
mqtt_mock.async_publish.assert_any_call("percentage-command-topic", "50", 0, False)
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
mqtt_mock.async_publish.assert_any_call("speed-command-topic", "low", 0, False)
mqtt_mock.async_publish.reset_mock()
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_set_percentage(hass, "fan.test", 100)
assert mqtt_mock.async_publish.call_count == 2
mqtt_mock.async_publish.assert_any_call("percentage-command-topic", "100", 0, False)
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
mqtt_mock.async_publish.assert_any_call("speed-command-topic", "medium", 0, False)
mqtt_mock.async_publish.reset_mock()
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_set_percentage(hass, "fan.test", 0)
assert mqtt_mock.async_publish.call_count == 2
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
mqtt_mock.async_publish.assert_any_call("percentage-command-topic", "0", 0, False)
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
mqtt_mock.async_publish.assert_any_call("speed-command-topic", "off", 0, False)
mqtt_mock.async_publish.reset_mock()
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
with pytest.raises(MultipleInvalid):
await common.async_set_percentage(hass, "fan.test", 101)
await common.async_set_preset_mode(hass, "fan.test", "low")
assert "not a valid preset mode" in caplog.text
caplog.clear()
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_set_preset_mode(hass, "fan.test", "medium")
assert "not a valid preset mode" in caplog.text
caplog.clear()
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_set_preset_mode(hass, "fan.test", "whoosh")
mqtt_mock.async_publish.assert_called_once_with(
"preset-mode-command-topic", "whoosh", 0, False
2019-07-31 19:25:30 +00:00
)
mqtt_mock.async_publish.reset_mock()
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_set_preset_mode(hass, "fan.test", "silent")
mqtt_mock.async_publish.assert_called_once_with(
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
"preset-mode-command-topic", "silent", 0, False
2019-07-31 19:25:30 +00:00
)
mqtt_mock.async_publish.reset_mock()
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
await common.async_set_preset_mode(hass, "fan.test", "freaking-high")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert "not a valid preset mode" in caplog.text
caplog.clear()
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("fan.test")
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
2019-07-31 19:25:30 +00:00
await common.async_set_speed(hass, "fan.test", fan.SPEED_MEDIUM)
mqtt_mock.async_publish.assert_called_once_with(
2019-07-31 19:25:30 +00:00
"speed-command-topic", "medium", 0, False
)
mqtt_mock.async_publish.reset_mock()
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
2019-07-31 19:25:30 +00:00
await common.async_set_speed(hass, "fan.test", fan.SPEED_HIGH)
assert "not a valid speed" in caplog.text
caplog.clear()
2019-07-31 19:25:30 +00:00
await common.async_set_speed(hass, "fan.test", fan.SPEED_OFF)
mqtt_mock.async_publish.assert_called_once_with(
2019-07-31 19:25:30 +00:00
"speed-command-topic", "off", 0, False
)
mqtt_mock.async_publish.reset_mock()
2019-07-31 19:25:30 +00:00
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_set_speed(hass, "fan.test", "cUsToM")
assert "not a valid speed" in caplog.text
caplog.clear()
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
async def test_attributes(hass, mqtt_mock, caplog):
"""Test attributes."""
assert await async_setup_component(
hass,
fan.DOMAIN,
{
fan.DOMAIN: {
"platform": "mqtt",
"name": "test",
"command_topic": "command-topic",
"oscillation_command_topic": "oscillation-command-topic",
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
"speed_command_topic": "speed-command-topic",
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
"preset_mode_command_topic": "preset-mode-command-topic",
"percentage_command_topic": "percentage-command-topic",
"preset_modes": [
"breeze",
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
"silent",
],
}
},
)
await hass.async_block_till_done()
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(fan.ATTR_SPEED_LIST) == [
"low",
"medium",
"high",
]
await common.async_turn_on(hass, "fan.test")
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_ON
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
assert state.attributes.get(fan.ATTR_SPEED) is None
assert state.attributes.get(fan.ATTR_OSCILLATING) is None
await common.async_turn_off(hass, "fan.test")
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
assert state.attributes.get(fan.ATTR_SPEED) is None
assert state.attributes.get(fan.ATTR_OSCILLATING) is None
await common.async_oscillate(hass, "fan.test", True)
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
assert state.attributes.get(fan.ATTR_SPEED) is None
assert state.attributes.get(fan.ATTR_OSCILLATING) is True
await common.async_oscillate(hass, "fan.test", False)
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
assert state.attributes.get(fan.ATTR_SPEED) is None
assert state.attributes.get(fan.ATTR_OSCILLATING) is False
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
await common.async_set_speed(hass, "fan.test", fan.SPEED_LOW)
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
assert state.attributes.get(fan.ATTR_SPEED) == "low"
assert state.attributes.get(fan.ATTR_OSCILLATING) is False
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
await common.async_set_speed(hass, "fan.test", fan.SPEED_MEDIUM)
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
assert state.attributes.get(fan.ATTR_SPEED) == "medium"
assert state.attributes.get(fan.ATTR_OSCILLATING) is False
await common.async_set_speed(hass, "fan.test", fan.SPEED_HIGH)
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
assert state.attributes.get(fan.ATTR_SPEED) == "high"
assert state.attributes.get(fan.ATTR_OSCILLATING) is False
await common.async_set_speed(hass, "fan.test", fan.SPEED_OFF)
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(ATTR_ASSUMED_STATE)
assert state.attributes.get(fan.ATTR_SPEED) == "off"
assert state.attributes.get(fan.ATTR_OSCILLATING) is False
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
await common.async_set_speed(hass, "fan.test", "cUsToM")
assert "not a valid speed" in caplog.text
caplog.clear()
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
async def test_custom_speed_list(hass, mqtt_mock):
"""Test optimistic mode without state topic."""
assert await async_setup_component(
hass,
fan.DOMAIN,
{
fan.DOMAIN: {
"platform": "mqtt",
"name": "test",
"command_topic": "command-topic",
"oscillation_command_topic": "oscillation-command-topic",
"oscillation_state_topic": "oscillation-state-topic",
"speed_command_topic": "speed-command-topic",
"speed_state_topic": "speed-state-topic",
"speeds": ["off", "high"],
}
},
)
await hass.async_block_till_done()
state = hass.states.get("fan.test")
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
assert state.state == STATE_OFF
assert state.attributes.get(fan.ATTR_SPEED_LIST) == ["high"]
async def test_supported_features(hass, mqtt_mock):
"""Test optimistic mode without state topic."""
assert await async_setup_component(
hass,
fan.DOMAIN,
{
fan.DOMAIN: [
{
"platform": "mqtt",
"name": "test1",
"command_topic": "command-topic",
},
{
"platform": "mqtt",
"name": "test2",
"command_topic": "command-topic",
"oscillation_command_topic": "oscillation-command-topic",
},
{
"platform": "mqtt",
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
"name": "test3a1",
"command_topic": "command-topic",
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
"speed_command_topic": "speed-command-topic",
},
{
"platform": "mqtt",
"name": "test3a2",
"command_topic": "command-topic",
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
"speed_command_topic": "speed-command-topic",
"speeds": ["low"],
},
{
"platform": "mqtt",
"name": "test3a3",
"command_topic": "command-topic",
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
"speed_command_topic": "speed-command-topic",
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
"speeds": ["off"],
},
{
"platform": "mqtt",
"name": "test3b",
"command_topic": "command-topic",
"percentage_command_topic": "percentage-command-topic",
},
{
"platform": "mqtt",
"name": "test3c1",
"command_topic": "command-topic",
"preset_mode_command_topic": "preset-mode-command-topic",
},
{
"platform": "mqtt",
"name": "test3c2",
"command_topic": "command-topic",
"preset_mode_command_topic": "preset-mode-command-topic",
"preset_modes": ["eco", "auto"],
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
},
{
"platform": "mqtt",
"name": "test3c3",
"command_topic": "command-topic",
"preset_mode_command_topic": "preset-mode-command-topic",
"preset_modes": ["eco", "smart", "auto"],
},
{
"platform": "mqtt",
"name": "test4",
"command_topic": "command-topic",
"oscillation_command_topic": "oscillation-command-topic",
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
# use of speeds is deprecated, support will be removed after a quarter (2021.7)
"speed_command_topic": "speed-command-topic",
},
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
{
"platform": "mqtt",
"name": "test4pcta",
"command_topic": "command-topic",
"percentage_command_topic": "percentage-command-topic",
},
{
"platform": "mqtt",
"name": "test4pctb",
"command_topic": "command-topic",
"oscillation_command_topic": "oscillation-command-topic",
"percentage_command_topic": "percentage-command-topic",
},
{
"platform": "mqtt",
"name": "test5pr_ma",
"command_topic": "command-topic",
"preset_mode_command_topic": "preset-mode-command-topic",
"preset_modes": ["Mode1", "Mode2", "Mode3"],
},
{
"platform": "mqtt",
"name": "test5pr_mb",
"command_topic": "command-topic",
"preset_mode_command_topic": "preset-mode-command-topic",
"preset_modes": ["whoosh", "silent", "auto"],
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
},
{
"platform": "mqtt",
"name": "test5pr_mc",
"command_topic": "command-topic",
"oscillation_command_topic": "oscillation-command-topic",
"preset_mode_command_topic": "preset-mode-command-topic",
"preset_modes": ["Mode1", "Mode2", "Mode3"],
},
{
"platform": "mqtt",
"name": "test6spd_range_a",
"command_topic": "command-topic",
"percentage_command_topic": "percentage-command-topic",
"speed_range_min": 1,
"speed_range_max": 40,
},
{
"platform": "mqtt",
"name": "test6spd_range_b",
"command_topic": "command-topic",
"percentage_command_topic": "percentage-command-topic",
"speed_range_min": 50,
"speed_range_max": 40,
},
{
"platform": "mqtt",
"name": "test6spd_range_c",
"command_topic": "command-topic",
"percentage_command_topic": "percentage-command-topic",
"speed_range_min": 0,
"speed_range_max": 40,
},
]
},
)
await hass.async_block_till_done()
state = hass.states.get("fan.test1")
assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == 0
state = hass.states.get("fan.test2")
assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == fan.SUPPORT_OSCILLATE
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
state = hass.states.get("fan.test3a1")
assert (
state.attributes.get(ATTR_SUPPORTED_FEATURES)
and fan.SUPPORT_SET_SPEED == fan.SUPPORT_SET_SPEED
)
state = hass.states.get("fan.test3a2")
assert (
state.attributes.get(ATTR_SUPPORTED_FEATURES)
and fan.SUPPORT_SET_SPEED == fan.SUPPORT_SET_SPEED
)
state = hass.states.get("fan.test3a3")
assert state is None
state = hass.states.get("fan.test3b")
assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == fan.SUPPORT_SET_SPEED
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
state = hass.states.get("fan.test3c1")
assert state is None
state = hass.states.get("fan.test3c2")
assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == fan.SUPPORT_PRESET_MODE
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
state = hass.states.get("fan.test3c3")
assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == fan.SUPPORT_PRESET_MODE
state = hass.states.get("fan.test4")
assert (
state.attributes.get(ATTR_SUPPORTED_FEATURES)
== fan.SUPPORT_OSCILLATE | fan.SUPPORT_SET_SPEED
)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
state = hass.states.get("fan.test4pcta")
assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == fan.SUPPORT_SET_SPEED
state = hass.states.get("fan.test4pctb")
assert (
state.attributes.get(ATTR_SUPPORTED_FEATURES)
== fan.SUPPORT_OSCILLATE | fan.SUPPORT_SET_SPEED
)
state = hass.states.get("fan.test5pr_ma")
assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == fan.SUPPORT_PRESET_MODE
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
state = hass.states.get("fan.test5pr_mb")
assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == fan.SUPPORT_PRESET_MODE
state = hass.states.get("fan.test5pr_mc")
assert (
state.attributes.get(ATTR_SUPPORTED_FEATURES)
== fan.SUPPORT_OSCILLATE | fan.SUPPORT_PRESET_MODE
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
)
state = hass.states.get("fan.test6spd_range_a")
assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == fan.SUPPORT_SET_SPEED
assert state.attributes.get("percentage_step") == 2.5
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
state = hass.states.get("fan.test6spd_range_b")
assert state is None
state = hass.states.get("fan.test6spd_range_c")
assert state is None
async def test_availability_when_connection_lost(hass, mqtt_mock):
"""Test availability after MQTT disconnection."""
await help_test_availability_when_connection_lost(
hass, mqtt_mock, fan.DOMAIN, DEFAULT_CONFIG
)
2020-03-17 07:09:19 +00:00
async def test_availability_without_topic(hass, mqtt_mock):
"""Test availability without defined availability topic."""
await help_test_availability_without_topic(
hass, mqtt_mock, fan.DOMAIN, DEFAULT_CONFIG
2019-07-31 19:25:30 +00:00
)
2018-10-28 22:49:55 +00:00
2020-03-17 07:09:19 +00:00
async def test_default_availability_payload(hass, mqtt_mock):
"""Test availability by default payload with defined topic."""
await help_test_default_availability_payload(
hass, mqtt_mock, fan.DOMAIN, DEFAULT_CONFIG, True, "state-topic", "1"
)
2018-10-28 22:49:55 +00:00
async def test_custom_availability_payload(hass, mqtt_mock):
2020-03-17 07:09:19 +00:00
"""Test availability by custom payload with defined topic."""
await help_test_custom_availability_payload(
hass, mqtt_mock, fan.DOMAIN, DEFAULT_CONFIG, True, "state-topic", "1"
2019-07-31 19:25:30 +00:00
)
async def test_setting_attribute_via_mqtt_json_message(hass, mqtt_mock):
"""Test the setting of attribute via MQTT with JSON payload."""
await help_test_setting_attribute_via_mqtt_json_message(
2020-03-17 07:09:19 +00:00
hass, mqtt_mock, fan.DOMAIN, DEFAULT_CONFIG
)
async def test_setting_attribute_with_template(hass, mqtt_mock):
"""Test the setting of attribute via MQTT with JSON payload."""
await help_test_setting_attribute_with_template(
hass, mqtt_mock, fan.DOMAIN, DEFAULT_CONFIG
2019-07-31 19:25:30 +00:00
)
async def test_update_with_json_attrs_not_dict(hass, mqtt_mock, caplog):
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_not_dict(
2020-03-17 07:09:19 +00:00
hass, mqtt_mock, caplog, fan.DOMAIN, DEFAULT_CONFIG
2019-07-31 19:25:30 +00:00
)
Percentage and preset mode support for MQTT fan (#47944) * git push --all origin * Fix percentage to ordered list conversion * Tests for mqtt fan and fixes * Improve tests and error handling base config * Additional tests * Tests completed, small fixes * Allow preset mode and percentages combined * Remove raise in setup and update tests * Alignment with fan entity mode * Fix pylint for len-as-condition * Remove python binary cache file from PR * Additional tests on async_turn_on and fix * Added comments for deprecation of speeds * Schema checks before init * Optimize pre schema checks * Correct schema checks * Update homeassistant/components/mqtt/abbreviations.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Comment speeds for mqtt fan are deprecated not needed here Co-authored-by: Erik Montnemery <erik@montnemery.com> * Warnings for exceptions - testing speed_range * Update homeassistant/components/mqtt/abbreviations.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/fan.py * Save with black Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-26 07:37:47 +00:00
async def test_update_with_json_attrs_bad_json(hass, mqtt_mock, caplog):
"""Test attributes get extracted from a JSON result."""
await help_test_update_with_json_attrs_bad_JSON(
2020-03-17 07:09:19 +00:00
hass, mqtt_mock, caplog, fan.DOMAIN, DEFAULT_CONFIG
2019-07-31 19:25:30 +00:00
)
async def test_discovery_update_attr(hass, mqtt_mock, caplog):
"""Test update of discovered MQTTAttributes."""
await help_test_discovery_update_attr(
2020-03-17 07:09:19 +00:00
hass, mqtt_mock, caplog, fan.DOMAIN, DEFAULT_CONFIG
)
async def test_unique_id(hass, mqtt_mock):
"""Test unique_id option only creates one fan per id."""
config = {
fan.DOMAIN: [
{
"platform": "mqtt",
"name": "Test 1",
"state_topic": "test-topic",
"command_topic": "test_topic",
"unique_id": "TOTALLY_UNIQUE",
},
{
"platform": "mqtt",
"name": "Test 2",
"state_topic": "test-topic",
"command_topic": "test_topic",
"unique_id": "TOTALLY_UNIQUE",
},
]
}
await help_test_unique_id(hass, mqtt_mock, fan.DOMAIN, config)
async def test_discovery_removal_fan(hass, mqtt_mock, caplog):
"""Test removal of discovered fan."""
data = '{ "name": "test", "command_topic": "test_topic" }'
await help_test_discovery_removal(hass, mqtt_mock, caplog, fan.DOMAIN, data)
2019-07-31 19:25:30 +00:00
async def test_discovery_update_fan(hass, mqtt_mock, caplog):
"""Test update of discovered fan."""
data1 = '{ "name": "Beer", "command_topic": "test_topic" }'
data2 = '{ "name": "Milk", "command_topic": "test_topic" }'
await help_test_discovery_update(hass, mqtt_mock, caplog, fan.DOMAIN, data1, data2)
2018-09-29 19:22:57 +00:00
async def test_discovery_update_unchanged_fan(hass, mqtt_mock, caplog):
"""Test update of discovered fan."""
data1 = '{ "name": "Beer", "command_topic": "test_topic" }'
with patch(
"homeassistant.components.mqtt.fan.MqttFan.discovery_update"
) as discovery_update:
await help_test_discovery_update_unchanged(
hass, mqtt_mock, caplog, fan.DOMAIN, data1, discovery_update
)
@pytest.mark.no_fail_on_log_exception
async def test_discovery_broken(hass, mqtt_mock, caplog):
"""Test handling of bad discovery message."""
data1 = '{ "name": "Beer" }'
data2 = '{ "name": "Milk", "command_topic": "test_topic" }'
await help_test_discovery_broken(hass, mqtt_mock, caplog, fan.DOMAIN, data1, data2)
2020-03-17 07:09:19 +00:00
async def test_entity_device_info_with_connection(hass, mqtt_mock):
"""Test MQTT fan device registry integration."""
await help_test_entity_device_info_with_connection(
hass, mqtt_mock, fan.DOMAIN, DEFAULT_CONFIG
)
async def test_entity_device_info_with_identifier(hass, mqtt_mock):
"""Test MQTT fan device registry integration."""
await help_test_entity_device_info_with_identifier(
2020-03-17 07:09:19 +00:00
hass, mqtt_mock, fan.DOMAIN, DEFAULT_CONFIG
)
async def test_entity_device_info_update(hass, mqtt_mock):
"""Test device registry update."""
await help_test_entity_device_info_update(
2020-03-17 07:09:19 +00:00
hass, mqtt_mock, fan.DOMAIN, DEFAULT_CONFIG
)
async def test_entity_device_info_remove(hass, mqtt_mock):
"""Test device registry remove."""
2020-03-17 07:09:19 +00:00
await help_test_entity_device_info_remove(
hass, mqtt_mock, fan.DOMAIN, DEFAULT_CONFIG
)
async def test_entity_id_update_subscriptions(hass, mqtt_mock):
"""Test MQTT subscriptions are managed when entity_id is updated."""
await help_test_entity_id_update_subscriptions(
hass, mqtt_mock, fan.DOMAIN, DEFAULT_CONFIG
)
async def test_entity_id_update_discovery_update(hass, mqtt_mock):
"""Test MQTT discovery update when entity_id is updated."""
await help_test_entity_id_update_discovery_update(
hass, mqtt_mock, fan.DOMAIN, DEFAULT_CONFIG
)
async def test_entity_debug_info_message(hass, mqtt_mock):
"""Test MQTT debug info."""
await help_test_entity_debug_info_message(
hass, mqtt_mock, fan.DOMAIN, DEFAULT_CONFIG
)