mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
Enable Ruff FLY002 rule (#115112)
Co-authored-by: J. Nick Koston <nick@koston.org> Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
This commit is contained in:
parent
35d3f2b29b
commit
9bf87329da
@ -118,8 +118,8 @@ class AzureDevOpsEntity(CoordinatorEntity[DataUpdateCoordinator[list[DevOpsBuild
|
||||
"""Initialize the Azure DevOps entity."""
|
||||
super().__init__(coordinator)
|
||||
self.entity_description = entity_description
|
||||
self._attr_unique_id: str = "_".join(
|
||||
[entity_description.organization, entity_description.key]
|
||||
self._attr_unique_id: str = (
|
||||
f"{entity_description.organization}_{entity_description.key}"
|
||||
)
|
||||
self._organization: str = entity_description.organization
|
||||
self._project_name: str = entity_description.project.name
|
||||
|
@ -201,9 +201,9 @@ async def async_setup_platform(
|
||||
|
||||
if radius > dist or stations_list.intersection((station_id, station_uid)):
|
||||
if name:
|
||||
uid = "_".join([network.network_id, name, station_id])
|
||||
uid = f"{network.network_id}_{name}_{station_id}"
|
||||
else:
|
||||
uid = "_".join([network.network_id, station_id])
|
||||
uid = f"{network.network_id}_{station_id}"
|
||||
entity_id = async_generate_entity_id(ENTITY_ID_FORMAT, uid, hass=hass)
|
||||
devices.append(CityBikesStation(network, station_id, entity_id))
|
||||
|
||||
|
@ -268,7 +268,7 @@ async def async_start( # noqa: C901
|
||||
availability_conf[CONF_TOPIC] = f"{topic[:-1]}{base}"
|
||||
|
||||
# If present, the node_id will be included in the discovered object id
|
||||
discovery_id = " ".join((node_id, object_id)) if node_id else object_id
|
||||
discovery_id = f"{node_id} {object_id}" if node_id else object_id
|
||||
discovery_hash = (component, discovery_id)
|
||||
|
||||
if discovery_payload:
|
||||
|
@ -82,11 +82,13 @@ class NextBusDepartureSensor(
|
||||
|
||||
def _log_debug(self, message, *args):
|
||||
"""Log debug message with prefix."""
|
||||
_LOGGER.debug(":".join((self.agency, self.route, self.stop, message)), *args)
|
||||
msg = f"{self.agency}:{self.route}:{self.stop}:{message}"
|
||||
_LOGGER.debug(msg, *args)
|
||||
|
||||
def _log_err(self, message, *args):
|
||||
"""Log error message with prefix."""
|
||||
_LOGGER.error(":".join((self.agency, self.route, self.stop, message)), *args)
|
||||
msg = f"{self.agency}:{self.route}:{self.stop}:{message}"
|
||||
_LOGGER.error(msg, *args)
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Read data from coordinator after adding to hass."""
|
||||
|
@ -62,7 +62,7 @@ def _normalize_ips_and_network(hosts_str: str) -> list[str] | None:
|
||||
start, end = host.split("-", 1)
|
||||
if "." not in end:
|
||||
ip_1, ip_2, ip_3, _ = start.split(".", 3)
|
||||
end = ".".join([ip_1, ip_2, ip_3, end])
|
||||
end = f"{ip_1}.{ip_2}.{ip_3}.{end}"
|
||||
summarize_address_range(ip_address(start), ip_address(end))
|
||||
except ValueError:
|
||||
pass
|
||||
|
@ -159,13 +159,9 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]):
|
||||
)
|
||||
)
|
||||
|
||||
name_prefix = " ".join(
|
||||
(
|
||||
"Opower",
|
||||
self.api.utility.subdomain(),
|
||||
account.meter_type.name.lower(),
|
||||
account.utility_account_id,
|
||||
)
|
||||
name_prefix = (
|
||||
f"Opower {self.api.utility.subdomain()} "
|
||||
f"{account.meter_type.name.lower()} {account.utility_account_id}"
|
||||
)
|
||||
cost_metadata = StatisticMetaData(
|
||||
has_mean=False,
|
||||
|
@ -34,14 +34,8 @@ class WithingsFlowHandler(
|
||||
def extra_authorize_data(self) -> dict[str, str]:
|
||||
"""Extra data that needs to be appended to the authorize url."""
|
||||
return {
|
||||
"scope": ",".join(
|
||||
[
|
||||
AuthScope.USER_INFO,
|
||||
AuthScope.USER_METRICS,
|
||||
AuthScope.USER_ACTIVITY,
|
||||
AuthScope.USER_SLEEP_EVENTS,
|
||||
]
|
||||
)
|
||||
"scope": f"{AuthScope.USER_INFO},{AuthScope.USER_METRICS},"
|
||||
f"{AuthScope.USER_ACTIVITY},{AuthScope.USER_SLEEP_EVENTS}"
|
||||
}
|
||||
|
||||
async def async_step_reauth(
|
||||
|
@ -679,6 +679,7 @@ select = [
|
||||
"DTZ004", # Use datetime.fromtimestamp(ts, tz=) instead of datetime.utcfromtimestamp(ts)
|
||||
"E", # pycodestyle
|
||||
"F", # pyflakes/autoflake
|
||||
"FLY", # flynt
|
||||
"G", # flake8-logging-format
|
||||
"I", # isort
|
||||
"INP", # flake8-no-pep420
|
||||
|
@ -32,7 +32,7 @@ HEADER: Final = """
|
||||
|
||||
GENERAL_SETTINGS: Final[dict[str, str]] = {
|
||||
"python_version": ".".join(str(x) for x in REQUIRED_PYTHON_VER[:2]),
|
||||
"plugins": ", ".join(["pydantic.mypy"]),
|
||||
"plugins": "pydantic.mypy",
|
||||
"show_error_codes": "true",
|
||||
"follow_imports": "silent",
|
||||
# Enable some checks globally.
|
||||
@ -43,20 +43,8 @@ GENERAL_SETTINGS: Final[dict[str, str]] = {
|
||||
"warn_redundant_casts": "true",
|
||||
"warn_unused_configs": "true",
|
||||
"warn_unused_ignores": "true",
|
||||
"enable_error_code": ", ".join(
|
||||
[
|
||||
"ignore-without-code",
|
||||
"redundant-self",
|
||||
"truthy-iterable",
|
||||
]
|
||||
),
|
||||
"disable_error_code": ", ".join(
|
||||
[
|
||||
"annotation-unchecked",
|
||||
"import-not-found",
|
||||
"import-untyped",
|
||||
]
|
||||
),
|
||||
"enable_error_code": "ignore-without-code, redundant-self, truthy-iterable",
|
||||
"disable_error_code": "annotation-unchecked, import-not-found, import-untyped",
|
||||
# Impractical in real code
|
||||
# E.g. this breaks passthrough ParamSpec typing with Concatenate
|
||||
"extra_checks": "false",
|
||||
|
@ -497,15 +497,12 @@ async def test_if_fires_on_state_change_with_for(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -564,15 +561,12 @@ async def test_if_fires_on_state_change_legacy(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -275,8 +275,10 @@ async def test_if_state(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "is_on {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(("platform", "event.event_type"))
|
||||
"some": (
|
||||
"is_on {{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -294,8 +296,10 @@ async def test_if_state(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "is_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(("platform", "event.event_type"))
|
||||
"some": (
|
||||
"is_off {{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -359,8 +363,10 @@ async def test_if_state_legacy(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "is_on {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(("platform", "event.event_type"))
|
||||
"some": (
|
||||
"is_on {{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -421,9 +427,9 @@ async def test_if_fires_on_for_condition(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "is_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
("platform", "event.event_type")
|
||||
"some": (
|
||||
"is_off {{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -277,15 +277,12 @@ async def test_if_fires_on_state_change(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "bat_low {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"bat_low {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -301,15 +298,12 @@ async def test_if_fires_on_state_change(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "not_bat_low {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"not_bat_low {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -379,15 +373,12 @@ async def test_if_fires_on_state_change_with_for(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -453,15 +444,12 @@ async def test_if_fires_on_state_change_legacy(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -625,15 +625,12 @@ async def test_if_fires_on_state_change_with_for(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -219,7 +219,7 @@ async def test_services(hass: HomeAssistant) -> None:
|
||||
|
||||
async def test_set_fan_speed(hass: HomeAssistant) -> None:
|
||||
"""Test vacuum service to set the fan speed."""
|
||||
group_vacuums = ",".join([ENTITY_VACUUM_COMPLETE, ENTITY_VACUUM_MOST])
|
||||
group_vacuums = f"{ENTITY_VACUUM_COMPLETE},{ENTITY_VACUUM_MOST}"
|
||||
old_state_complete = hass.states.get(ENTITY_VACUUM_COMPLETE)
|
||||
old_state_most = hass.states.get(ENTITY_VACUUM_MOST)
|
||||
|
||||
@ -239,7 +239,7 @@ async def test_set_fan_speed(hass: HomeAssistant) -> None:
|
||||
|
||||
async def test_send_command(hass: HomeAssistant) -> None:
|
||||
"""Test vacuum service to send a command."""
|
||||
group_vacuums = ",".join([ENTITY_VACUUM_COMPLETE])
|
||||
group_vacuums = f"{ENTITY_VACUUM_COMPLETE}"
|
||||
old_state_complete = hass.states.get(ENTITY_VACUUM_COMPLETE)
|
||||
|
||||
await common.async_send_command(
|
||||
|
@ -1446,8 +1446,10 @@ async def test_automation_with_sub_condition(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "and {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(("platform", "event.event_type"))
|
||||
"some": (
|
||||
"and {{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -1477,8 +1479,10 @@ async def test_automation_with_sub_condition(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "or {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(("platform", "event.event_type"))
|
||||
"some": (
|
||||
"or {{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -64,15 +64,12 @@ async def test_if_fires_on_state_change(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_on {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_on {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -88,15 +85,12 @@ async def test_if_fires_on_state_change(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -112,15 +106,12 @@ async def test_if_fires_on_state_change(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_on_or_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_on_or_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -187,15 +178,12 @@ async def test_if_fires_on_state_change_with_for(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -385,15 +385,12 @@ async def test_if_fires_on_state_change_with_for(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -72,16 +72,13 @@ async def test_if_fires_on_zone_enter(hass: HomeAssistant, calls) -> None:
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"zone.name",
|
||||
"id",
|
||||
)
|
||||
"some": (
|
||||
"{{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.zone.name }}"
|
||||
" - {{ trigger.id }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -285,15 +282,12 @@ async def test_if_fires_on_zone_appear(hass: HomeAssistant, calls) -> None:
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"zone.name",
|
||||
)
|
||||
"some": (
|
||||
"{{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.zone.name }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -334,15 +328,12 @@ async def test_if_fires_on_zone_appear_2(hass: HomeAssistant, calls) -> None:
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"zone.name",
|
||||
)
|
||||
"some": (
|
||||
"{{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.zone.name }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -399,15 +390,12 @@ async def test_if_fires_on_zone_disappear(hass: HomeAssistant, calls) -> None:
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"zone.name",
|
||||
)
|
||||
"some": (
|
||||
"{{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.zone.name }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -980,16 +980,13 @@ async def test_template_string(hass: HomeAssistant, calls, below) -> None:
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"below",
|
||||
"above",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
)
|
||||
"some": (
|
||||
"{{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.below }}"
|
||||
" - {{ trigger.above }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -1346,9 +1343,10 @@ async def test_wait_template_with_trigger(hass: HomeAssistant, calls, above) ->
|
||||
{
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
("platform", "entity_id", "to_state.state")
|
||||
"some": (
|
||||
"{{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -55,16 +55,13 @@ async def test_if_fires_on_entity_change(hass: HomeAssistant, calls) -> None:
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
"id",
|
||||
)
|
||||
"some": (
|
||||
"{{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
" - {{ trigger.id }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -114,16 +111,13 @@ async def test_if_fires_on_entity_change_uuid(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
"id",
|
||||
)
|
||||
"some": (
|
||||
"{{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
" - {{ trigger.id }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -1079,14 +1073,11 @@ async def test_wait_template_with_trigger(hass: HomeAssistant, calls) -> None:
|
||||
{
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
)
|
||||
"some": (
|
||||
"{{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -306,7 +306,7 @@ async def setup_test_component(
|
||||
|
||||
config_entry, pairing = await setup_test_accessories(hass, [accessory], connection)
|
||||
entity = "testdevice" if suffix is None else f"testdevice_{suffix}"
|
||||
return Helper(hass, ".".join((domain, entity)), pairing, accessory, config_entry)
|
||||
return Helper(hass, f"{domain}.{entity}", pairing, accessory, config_entry)
|
||||
|
||||
|
||||
async def assert_devices_and_entities_created(
|
||||
|
@ -187,8 +187,10 @@ async def test_if_state(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "is_on {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(("platform", "event.event_type"))
|
||||
"some": (
|
||||
"is_on {{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -206,8 +208,10 @@ async def test_if_state(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "is_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(("platform", "event.event_type"))
|
||||
"some": (
|
||||
"is_off {{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -293,15 +293,12 @@ async def test_if_fires_on_state_change(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_on {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_on {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -317,15 +314,12 @@ async def test_if_fires_on_state_change(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -341,15 +335,12 @@ async def test_if_fires_on_state_change(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_on_or_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_on_or_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -219,8 +219,10 @@ async def test_if_state(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "is_on {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(("platform", "event.event_type"))
|
||||
"some": (
|
||||
"is_on {{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -238,8 +240,10 @@ async def test_if_state(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "is_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(("platform", "event.event_type"))
|
||||
"some": (
|
||||
"is_off {{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -302,8 +306,10 @@ async def test_if_state_legacy(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "is_on {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(("platform", "event.event_type"))
|
||||
"some": (
|
||||
"is_on {{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -367,9 +373,9 @@ async def test_if_fires_on_for_condition(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "is_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
("platform", "event.event_type")
|
||||
"some": (
|
||||
"is_off {{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -23,6 +23,14 @@ from tests.common import (
|
||||
async_mock_service,
|
||||
)
|
||||
|
||||
DATA_TEMPLATE_ATTRIBUTES = (
|
||||
"{{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True, name="stub_blueprint_populate")
|
||||
def stub_blueprint_populate_autouse(stub_blueprint_populate: None) -> None:
|
||||
@ -212,16 +220,7 @@ async def test_if_fires_on_state_change(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_on {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
)
|
||||
"some": "turn_on " + DATA_TEMPLATE_ATTRIBUTES
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -236,16 +235,7 @@ async def test_if_fires_on_state_change(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
)
|
||||
"some": "turn_off " + DATA_TEMPLATE_ATTRIBUTES
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -260,16 +250,7 @@ async def test_if_fires_on_state_change(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_on_or_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
)
|
||||
"some": "turn_on_or_off " + DATA_TEMPLATE_ATTRIBUTES
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -332,16 +313,7 @@ async def test_if_fires_on_state_change_legacy(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_on {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
)
|
||||
"some": "turn_on " + DATA_TEMPLATE_ATTRIBUTES
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -396,16 +368,7 @@ async def test_if_fires_on_state_change_with_for(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
)
|
||||
"some": "turn_off " + DATA_TEMPLATE_ATTRIBUTES
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -363,15 +363,12 @@ async def test_if_fires_on_state_change_with_for(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -388,15 +385,12 @@ async def test_if_fires_on_state_change_with_for(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_on {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_on {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -413,15 +407,12 @@ async def test_if_fires_on_state_change_with_for(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -438,15 +429,12 @@ async def test_if_fires_on_state_change_with_for(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_on {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_on {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -412,15 +412,12 @@ async def test_if_fires_on_state_change_with_for(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -393,13 +393,7 @@ async def test_setup_component_invalid_token_scope(hass: HomeAssistant) -> None:
|
||||
"type": "Bearer",
|
||||
"expires_in": 60,
|
||||
"expires_at": time() + 1000,
|
||||
"scope": " ".join(
|
||||
[
|
||||
"read_smokedetector",
|
||||
"read_thermostat",
|
||||
"write_thermostat",
|
||||
]
|
||||
),
|
||||
"scope": "read_smokedetector read_thermostat write_thermostat",
|
||||
},
|
||||
},
|
||||
options={},
|
||||
|
@ -217,8 +217,10 @@ async def test_if_state(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "is_on {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(("platform", "event.event_type"))
|
||||
"some": (
|
||||
"is_on {{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -236,8 +238,10 @@ async def test_if_state(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "is_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(("platform", "event.event_type"))
|
||||
"some": (
|
||||
"is_off {{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -300,8 +304,10 @@ async def test_if_state_legacy(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "is_on {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(("platform", "event.event_type"))
|
||||
"some": (
|
||||
"is_on {{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -361,9 +367,9 @@ async def test_if_fires_on_for_condition(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "is_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
("platform", "event.event_type")
|
||||
"some": (
|
||||
"is_off {{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -212,15 +212,12 @@ async def test_if_fires_on_state_change(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_on {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_on {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -236,15 +233,12 @@ async def test_if_fires_on_state_change(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -260,15 +254,12 @@ async def test_if_fires_on_state_change(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_on_or_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_on_or_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -331,15 +322,12 @@ async def test_if_fires_on_state_change_legacy(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -395,15 +383,12 @@ async def test_if_fires_on_state_change_with_for(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -545,8 +545,10 @@ async def test_if_state_above(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(("platform", "event.event_type"))
|
||||
"some": (
|
||||
"{{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -612,8 +614,10 @@ async def test_if_state_above_legacy(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(("platform", "event.event_type"))
|
||||
"some": (
|
||||
"{{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -679,8 +683,10 @@ async def test_if_state_below(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(("platform", "event.event_type"))
|
||||
"some": (
|
||||
"{{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -747,8 +753,10 @@ async def test_if_state_between(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(("platform", "event.event_type"))
|
||||
"some": (
|
||||
"{{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -496,15 +496,12 @@ async def test_if_fires_on_state_above(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "bat_low {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"bat_low {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -564,15 +561,12 @@ async def test_if_fires_on_state_below(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "bat_low {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"bat_low {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -633,15 +627,12 @@ async def test_if_fires_on_state_between(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "bat_low {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"bat_low {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -712,15 +703,12 @@ async def test_if_fires_on_state_legacy(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "bat_low {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"bat_low {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -781,15 +769,12 @@ async def test_if_fires_on_state_change_with_for(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -127,8 +127,11 @@ async def test_sunset_trigger_with_offset(hass: HomeAssistant, calls) -> None:
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(("platform", "event", "offset"))
|
||||
"some": (
|
||||
"{{ trigger.platform }}"
|
||||
" - {{ trigger.event }}"
|
||||
" - {{ trigger.offset }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -217,8 +217,10 @@ async def test_if_state(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "is_on {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(("platform", "event.event_type"))
|
||||
"some": (
|
||||
"is_on {{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -236,8 +238,10 @@ async def test_if_state(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "is_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(("platform", "event.event_type"))
|
||||
"some": (
|
||||
"is_off {{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -300,8 +304,10 @@ async def test_if_state_legacy(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "is_on {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(("platform", "event.event_type"))
|
||||
"some": (
|
||||
"is_on {{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -360,9 +366,9 @@ async def test_if_fires_on_for_condition(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "is_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
("platform", "event.event_type")
|
||||
"some": (
|
||||
"is_off {{ trigger.platform }}"
|
||||
" - {{ trigger.event.event_type }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -212,15 +212,12 @@ async def test_if_fires_on_state_change(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_on {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_on {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -236,15 +233,12 @@ async def test_if_fires_on_state_change(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -260,15 +254,12 @@ async def test_if_fires_on_state_change(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_on_or_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_on_or_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -332,15 +323,12 @@ async def test_if_fires_on_state_change_legacy(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -397,15 +385,12 @@ async def test_if_fires_on_state_change_with_for(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -329,15 +329,12 @@ async def test_if_not_fires_because_fail(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"{{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -430,15 +427,12 @@ async def test_if_fires_on_change_with_bad_template(
|
||||
{
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"{{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -502,15 +496,12 @@ async def test_if_fires_on_change_with_for(hass: HomeAssistant, calls) -> None:
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"{{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -549,15 +540,12 @@ async def test_if_fires_on_change_with_for_advanced(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"{{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -593,15 +581,12 @@ async def test_if_fires_on_change_with_for_0_advanced(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"{{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -214,15 +214,12 @@ async def test_if_fires_on_state_change(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "update_available {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"update_available {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -238,15 +235,12 @@ async def test_if_fires_on_state_change(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "no_update {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"no_update {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -314,15 +308,12 @@ async def test_if_fires_on_state_change_legacy(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "no_update {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"no_update {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -383,15 +374,12 @@ async def test_if_fires_on_state_change_with_for(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -356,15 +356,12 @@ async def test_if_fires_on_state_change_with_for(
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "turn_off {{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
"some": (
|
||||
"turn_off {{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.for }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -55,7 +55,7 @@ async def test_full_flow(
|
||||
},
|
||||
)
|
||||
|
||||
scope = "+".join(["Xboxlive.signin", "Xboxlive.offline_access"])
|
||||
scope = "Xboxlive.signin+Xboxlive.offline_access"
|
||||
|
||||
assert result["url"] == (
|
||||
f"{OAUTH2_AUTHORIZE}?response_type=code&client_id={CLIENT_ID}"
|
||||
|
@ -64,16 +64,13 @@ async def test_if_fires_on_zone_enter(hass: HomeAssistant, calls) -> None:
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"zone.name",
|
||||
"id",
|
||||
)
|
||||
"some": (
|
||||
"{{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.zone.name }}"
|
||||
" - {{ trigger.id }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
@ -143,16 +140,13 @@ async def test_if_fires_on_zone_enter_uuid(hass: HomeAssistant, calls) -> None:
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"zone.name",
|
||||
"id",
|
||||
)
|
||||
"some": (
|
||||
"{{ trigger.platform }}"
|
||||
" - {{ trigger.entity_id }}"
|
||||
" - {{ trigger.from_state.state }}"
|
||||
" - {{ trigger.to_state.state }}"
|
||||
" - {{ trigger.zone.name }}"
|
||||
" - {{ trigger.id }}"
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -42,9 +42,7 @@ async def test_list_user(hass: HomeAssistant, provider, capsys) -> None:
|
||||
|
||||
captured = capsys.readouterr()
|
||||
|
||||
assert captured.out == "\n".join(
|
||||
["test-user", "second-user", "", "Total users: 2", ""]
|
||||
)
|
||||
assert captured.out == "test-user\nsecond-user\n\nTotal users: 2\n"
|
||||
|
||||
|
||||
async def test_add_user(
|
||||
|
Loading…
x
Reference in New Issue
Block a user