Code styling tweaks to the tests - Part 2 (#86662)

Co-authored-by: jjlawren <jjlawren@users.noreply.github.com>
This commit is contained in:
Franck Nijhof 2023-01-26 01:23:53 +01:00 committed by GitHub
parent 7ab88fa713
commit e50a531cd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
54 changed files with 734 additions and 360 deletions

View File

@ -108,7 +108,9 @@ async def test_brightness_level_set(hass, mock_config_entry_data, mock_config_en
number.DOMAIN,
SERVICE_SET_VALUE,
{
ATTR_ENTITY_ID: "number.product_name_aabbccddeeff_status_light_brightness",
ATTR_ENTITY_ID: (
"number.product_name_aabbccddeeff_status_light_brightness"
),
ATTR_VALUE: 50,
},
blocking=True,
@ -128,7 +130,9 @@ async def test_brightness_level_set(hass, mock_config_entry_data, mock_config_en
number.DOMAIN,
SERVICE_SET_VALUE,
{
ATTR_ENTITY_ID: "number.product_name_aabbccddeeff_status_light_brightness",
ATTR_ENTITY_ID: (
"number.product_name_aabbccddeeff_status_light_brightness"
),
ATTR_VALUE: 0,
},
blocking=True,
@ -171,7 +175,9 @@ async def test_brightness_level_set_catches_requesterror(
number.DOMAIN,
SERVICE_SET_VALUE,
{
ATTR_ENTITY_ID: "number.product_name_aabbccddeeff_status_light_brightness",
ATTR_ENTITY_ID: (
"number.product_name_aabbccddeeff_status_light_brightness"
),
ATTR_VALUE: 50,
},
blocking=True,
@ -205,7 +211,9 @@ async def test_brightness_level_set_catches_disablederror(
number.DOMAIN,
SERVICE_SET_VALUE,
{
ATTR_ENTITY_ID: "number.product_name_aabbccddeeff_status_light_brightness",
ATTR_ENTITY_ID: (
"number.product_name_aabbccddeeff_status_light_brightness"
),
ATTR_VALUE: 50,
},
blocking=True,
@ -241,7 +249,9 @@ async def test_brightness_level_set_catches_invalid_value(
number.DOMAIN,
SERVICE_SET_VALUE,
{
ATTR_ENTITY_ID: "number.product_name_aabbccddeeff_status_light_brightness",
ATTR_ENTITY_ID: (
"number.product_name_aabbccddeeff_status_light_brightness"
),
ATTR_VALUE: -1,
},
blocking=True,
@ -252,7 +262,9 @@ async def test_brightness_level_set_catches_invalid_value(
number.DOMAIN,
SERVICE_SET_VALUE,
{
ATTR_ENTITY_ID: "number.product_name_aabbccddeeff_status_light_brightness",
ATTR_ENTITY_ID: (
"number.product_name_aabbccddeeff_status_light_brightness"
),
ATTR_VALUE: 101,
},
blocking=True,

View File

@ -115,7 +115,9 @@ async def test_ignore_no_name_but_create_if_set_later(hass):
BLUECHARM_BEACON_SERVICE_INFO,
service_data={
"00002080-0000-1000-8000-00805f9b34fb": b"j\x0c\x0e\xfe\x13U",
"0000feaa-0000-1000-8000-00805f9b34fb": b" \x00\x0c\x00\x1c\x00\x00\x00\x06h\x00\x008\x10",
"0000feaa-0000-1000-8000-00805f9b34fb": (
b" \x00\x0c\x00\x1c\x00\x00\x00\x06h\x00\x008\x10"
),
},
),
)

View File

@ -134,8 +134,7 @@ async def test_face_event_call(hass, aioclient_mock):
@patch(
"homeassistant.components.demo.image_processing."
"DemoImageProcessingFace.confidence",
"homeassistant.components.demo.image_processing.DemoImageProcessingFace.confidence",
new_callable=PropertyMock(return_value=None),
)
async def test_face_event_call_no_confidence(mock_config, hass, aioclient_mock):

View File

@ -180,7 +180,9 @@ async def test_entry_diagnostics(hass, config_entry, hass_client, setup_iqvia):
"LGID": 1,
"Name": "OZONE",
"PPM": 42,
"Description": "Ozone (O3) is a odorless, colorless ....",
"Description": (
"Ozone (O3) is a odorless, colorless ...."
),
},
{
"LGID": 1,
@ -192,7 +194,9 @@ async def test_entry_diagnostics(hass, config_entry, hass_client, setup_iqvia):
"LGID": 1,
"Name": "PM10",
"PPM": 19,
"Description": "Coarse dust particles (PM10) are 2.5 ...",
"Description": (
"Coarse dust particles (PM10) are 2.5 ..."
),
},
],
"Period": "0001-01-01T00:00:00",
@ -212,13 +216,17 @@ async def test_entry_diagnostics(hass, config_entry, hass_client, setup_iqvia):
"LGID": 2,
"Name": "PM10",
"PPM": 65,
"Description": "Coarse dust particles (PM10) are 2.5 ...",
"Description": (
"Coarse dust particles (PM10) are 2.5 ..."
),
},
{
"LGID": 1,
"Name": "OZONE",
"PPM": 42,
"Description": "Ozone (O3) is a odorless, colorless ...",
"Description": (
"Ozone (O3) is a odorless, colorless ..."
),
},
],
"Period": "0001-01-01T00:00:00",

View File

@ -60,6 +60,6 @@ async def test_callrate_limit(hass, caplog):
await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
assert (
"Exceeded the Kraken.com call rate limit. Increase the update interval to prevent this error"
in caplog.text
"Exceeded the Kraken.com call rate limit. Increase the update interval to"
" prevent this error" in caplog.text
)

View File

@ -1297,7 +1297,7 @@ async def test_subscribe_unsubscribe_logbook_stream(
"context_entity_id": "automation.alarm",
"context_event_type": "automation_triggered",
"context_id": "ac5bd62de45711eaaeb351041eec8dd9",
"context_message": "triggered by state of " "binary_sensor.dog_food_ready",
"context_message": "triggered by state of binary_sensor.dog_food_ready",
"context_name": "Mock automation",
"context_source": "state of binary_sensor.dog_food_ready",
"context_user_id": "b400facee45711eaa9308bfd3d19e474",
@ -1311,7 +1311,7 @@ async def test_subscribe_unsubscribe_logbook_stream(
"context_domain": "automation",
"context_entity_id": "automation.alarm",
"context_event_type": "automation_triggered",
"context_message": "triggered by state of " "binary_sensor.dog_food_ready",
"context_message": "triggered by state of binary_sensor.dog_food_ready",
"context_name": "Mock automation",
"context_source": "state of binary_sensor.dog_food_ready",
"context_user_id": "b400facee45711eaa9308bfd3d19e474",
@ -1323,7 +1323,7 @@ async def test_subscribe_unsubscribe_logbook_stream(
"context_domain": "automation",
"context_entity_id": "automation.alarm",
"context_event_type": "automation_triggered",
"context_message": "triggered by state of " "binary_sensor.dog_food_ready",
"context_message": "triggered by state of binary_sensor.dog_food_ready",
"context_name": "Mock automation",
"context_source": "state of binary_sensor.dog_food_ready",
"context_user_id": "b400facee45711eaa9308bfd3d19e474",

View File

@ -200,7 +200,7 @@ async def test_diagnostics(hass, hass_client) -> None:
"parent_keypad": "9",
},
"1372": {
"button_name": "Kitchen " "Pendants",
"button_name": "Kitchen Pendants",
"leap_button_number": 3,
"led_device_id": "1362",
"lutron_device_id": "1372",
@ -214,16 +214,16 @@ async def test_diagnostics(hass, hass_client) -> None:
"buttons": ["1372"],
"device_info": {
"identifiers": [["lutron_caseta", 66286451]],
"manufacturer": "Lutron " "Electronics " "Co., " "Inc",
"model": "RRST-W3RL-XX " "(SunnataKeypad)",
"name": "Hallway " "Main " "Stairs " "Position 1 " "Keypad",
"manufacturer": "Lutron Electronics Co., Inc",
"model": "RRST-W3RL-XX (SunnataKeypad)",
"name": "Hallway Main Stairs Position 1 Keypad",
"suggested_area": "Hallway",
"via_device": ["lutron_caseta", 1234],
},
"dr_device_id": ANY,
"lutron_device_id": "1355",
"model": "RRST-W3RL-XX",
"name": "Main Stairs Position 1 " "Keypad",
"name": "Main Stairs Position 1 Keypad",
"serial": 66286451,
"type": "SunnataKeypad",
},
@ -233,10 +233,10 @@ async def test_diagnostics(hass, hass_client) -> None:
"buttons": ["111"],
"device_info": {
"identifiers": [["lutron_caseta", 68551522]],
"manufacturer": "Lutron " "Electronics " "Co., " "Inc",
"model": "PJ2-3BRL-GXX-X01 " "(Pico3ButtonRaiseLower)",
"name": "Dining Room " "Pico",
"suggested_area": "Dining " "Room",
"manufacturer": "Lutron Electronics Co., Inc",
"model": "PJ2-3BRL-GXX-X01 (Pico3ButtonRaiseLower)",
"name": "Dining Room Pico",
"suggested_area": "Dining Room",
"via_device": ["lutron_caseta", 1234],
},
"dr_device_id": ANY,

View File

@ -171,7 +171,7 @@ async def test_with_pending(hass, service, expected_state):
future = dt_util.utcnow() + timedelta(seconds=1)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
"homeassistant.components.manual.alarm_control_panel.dt_util.utcnow",
return_value=future,
):
async_fire_time_changed(hass, future)
@ -313,7 +313,7 @@ async def test_with_specific_pending(hass, service, expected_state):
future = dt_util.utcnow() + timedelta(seconds=2)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
"homeassistant.components.manual.alarm_control_panel.dt_util.utcnow",
return_value=future,
):
async_fire_time_changed(hass, future)
@ -348,7 +348,7 @@ async def test_trigger_no_pending(hass):
future = dt_util.utcnow() + timedelta(seconds=60)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
"homeassistant.components.manual.alarm_control_panel.dt_util.utcnow",
return_value=future,
):
async_fire_time_changed(hass, future)
@ -393,7 +393,7 @@ async def test_trigger_with_delay(hass):
future = dt_util.utcnow() + timedelta(seconds=1)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
"homeassistant.components.manual.alarm_control_panel.dt_util.utcnow",
return_value=future,
):
async_fire_time_changed(hass, future)
@ -486,7 +486,7 @@ async def test_trigger_with_pending(hass):
future = dt_util.utcnow() + timedelta(seconds=2)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
"homeassistant.components.manual.alarm_control_panel.dt_util.utcnow",
return_value=future,
):
async_fire_time_changed(hass, future)
@ -498,7 +498,7 @@ async def test_trigger_with_pending(hass):
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
"homeassistant.components.manual.alarm_control_panel.dt_util.utcnow",
return_value=future,
):
async_fire_time_changed(hass, future)
@ -543,7 +543,7 @@ async def test_trigger_with_unused_specific_delay(hass):
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
"homeassistant.components.manual.alarm_control_panel.dt_util.utcnow",
return_value=future,
):
async_fire_time_changed(hass, future)
@ -589,7 +589,7 @@ async def test_trigger_with_specific_delay(hass):
future = dt_util.utcnow() + timedelta(seconds=1)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
"homeassistant.components.manual.alarm_control_panel.dt_util.utcnow",
return_value=future,
):
async_fire_time_changed(hass, future)
@ -634,7 +634,7 @@ async def test_trigger_with_pending_and_delay(hass):
future = dt_util.utcnow() + timedelta(seconds=1)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
"homeassistant.components.manual.alarm_control_panel.dt_util.utcnow",
return_value=future,
):
async_fire_time_changed(hass, future)
@ -646,7 +646,7 @@ async def test_trigger_with_pending_and_delay(hass):
future += timedelta(seconds=1)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
"homeassistant.components.manual.alarm_control_panel.dt_util.utcnow",
return_value=future,
):
async_fire_time_changed(hass, future)
@ -692,7 +692,7 @@ async def test_trigger_with_pending_and_specific_delay(hass):
future = dt_util.utcnow() + timedelta(seconds=1)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
"homeassistant.components.manual.alarm_control_panel.dt_util.utcnow",
return_value=future,
):
async_fire_time_changed(hass, future)
@ -704,7 +704,7 @@ async def test_trigger_with_pending_and_specific_delay(hass):
future += timedelta(seconds=1)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
"homeassistant.components.manual.alarm_control_panel.dt_util.utcnow",
return_value=future,
):
async_fire_time_changed(hass, future)
@ -741,7 +741,7 @@ async def test_trigger_with_specific_pending(hass):
future = dt_util.utcnow() + timedelta(seconds=2)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
"homeassistant.components.manual.alarm_control_panel.dt_util.utcnow",
return_value=future,
):
async_fire_time_changed(hass, future)
@ -753,7 +753,7 @@ async def test_trigger_with_specific_pending(hass):
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
"homeassistant.components.manual.alarm_control_panel.dt_util.utcnow",
return_value=future,
):
async_fire_time_changed(hass, future)
@ -791,7 +791,7 @@ async def test_trigger_with_disarm_after_trigger(hass):
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
"homeassistant.components.manual.alarm_control_panel.dt_util.utcnow",
return_value=future,
):
async_fire_time_changed(hass, future)
@ -857,7 +857,7 @@ async def test_trigger_with_unused_zero_specific_trigger_time(hass):
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
"homeassistant.components.manual.alarm_control_panel.dt_util.utcnow",
return_value=future,
):
async_fire_time_changed(hass, future)
@ -895,7 +895,7 @@ async def test_trigger_with_specific_trigger_time(hass):
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
"homeassistant.components.manual.alarm_control_panel.dt_util.utcnow",
return_value=future,
):
async_fire_time_changed(hass, future)
@ -938,7 +938,7 @@ async def test_trigger_with_no_disarm_after_trigger(hass):
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
"homeassistant.components.manual.alarm_control_panel.dt_util.utcnow",
return_value=future,
):
async_fire_time_changed(hass, future)
@ -981,7 +981,7 @@ async def test_back_to_back_trigger_with_no_disarm_after_trigger(hass):
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
"homeassistant.components.manual.alarm_control_panel.dt_util.utcnow",
return_value=future,
):
async_fire_time_changed(hass, future)
@ -997,7 +997,7 @@ async def test_back_to_back_trigger_with_no_disarm_after_trigger(hass):
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
"homeassistant.components.manual.alarm_control_panel.dt_util.utcnow",
return_value=future,
):
async_fire_time_changed(hass, future)
@ -1036,7 +1036,7 @@ async def test_disarm_while_pending_trigger(hass):
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
"homeassistant.components.manual.alarm_control_panel.dt_util.utcnow",
return_value=future,
):
async_fire_time_changed(hass, future)
@ -1080,7 +1080,7 @@ async def test_disarm_during_trigger_with_invalid_code(hass):
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
"homeassistant.components.manual.alarm_control_panel.dt_util.utcnow",
return_value=future,
):
async_fire_time_changed(hass, future)

View File

@ -565,8 +565,10 @@ async def test_addon_running(
@pytest.mark.parametrize(
"discovery_info, discovery_info_error, client_connect_error, addon_info_error, "
"abort_reason, discovery_info_called, client_connect_called",
(
"discovery_info, discovery_info_error, client_connect_error, addon_info_error, "
"abort_reason, discovery_info_called, client_connect_called"
),
[
(
{"config": ADDON_DISCOVERY_INFO},
@ -721,8 +723,10 @@ async def test_addon_installed(
@pytest.mark.parametrize(
"discovery_info, start_addon_error, client_connect_error, "
"discovery_info_called, client_connect_called",
(
"discovery_info, start_addon_error, client_connect_error, "
"discovery_info_called, client_connect_called"
),
[
(
{"config": ADDON_DISCOVERY_INFO},

View File

@ -127,9 +127,7 @@ async def test_async_browse_media_success(hass: HomeAssistant) -> None:
"title": "http://test:8766",
"media_class": "directory",
"media_content_type": "",
"media_content_id": (
"media-source://motioneye/74565ad414754616000674c87bdc876c"
),
"media_content_id": "media-source://motioneye/74565ad414754616000674c87bdc876c",
"can_play": False,
"can_expand": True,
"children_media_class": "directory",
@ -365,10 +363,7 @@ async def test_async_resolve_media_success(hass: HomeAssistant) -> None:
client.get_movie_url = Mock(return_value="http://movie-url")
media = await async_resolve_media(
hass,
(
f"{URI_SCHEME}{DOMAIN}"
f"/{TEST_CONFIG_ENTRY_ID}#{device.id}#movies#/foo.mp4"
),
f"{URI_SCHEME}{DOMAIN}/{TEST_CONFIG_ENTRY_ID}#{device.id}#movies#/foo.mp4",
None,
)
assert media == PlayMedia(url="http://movie-url", mime_type="video/mp4")
@ -378,10 +373,7 @@ async def test_async_resolve_media_success(hass: HomeAssistant) -> None:
client.get_image_url = Mock(return_value="http://image-url")
media = await async_resolve_media(
hass,
(
f"{URI_SCHEME}{DOMAIN}"
f"/{TEST_CONFIG_ENTRY_ID}#{device.id}#images#/foo.jpg"
),
f"{URI_SCHEME}{DOMAIN}/{TEST_CONFIG_ENTRY_ID}#{device.id}#images#/foo.jpg",
None,
)
assert media == PlayMedia(url="http://image-url", mime_type="image/jpeg")
@ -460,10 +452,7 @@ async def test_async_resolve_media_failure(hass: HomeAssistant) -> None:
with pytest.raises(Unresolvable):
await async_resolve_media(
hass,
(
f"{URI_SCHEME}{DOMAIN}"
f"/{TEST_CONFIG_ENTRY_ID}#{device.id}#movies#/foo.mp4"
),
f"{URI_SCHEME}{DOMAIN}/{TEST_CONFIG_ENTRY_ID}#{device.id}#movies#/foo.mp4",
None,
)
@ -472,10 +461,7 @@ async def test_async_resolve_media_failure(hass: HomeAssistant) -> None:
with pytest.raises(MediaSourceError):
await async_resolve_media(
hass,
(
f"{URI_SCHEME}{DOMAIN}"
f"/{TEST_CONFIG_ENTRY_ID}#{device.id}#movies#foo.mp4"
),
f"{URI_SCHEME}{DOMAIN}/{TEST_CONFIG_ENTRY_ID}#{device.id}#movies#foo.mp4",
None,
)
@ -491,7 +477,7 @@ async def test_async_resolve_media_failure(hass: HomeAssistant) -> None:
"media_class": "directory",
"media_content_type": "video",
"media_content_id": (
f"media-source://motioneye"
"media-source://motioneye"
f"/74565ad414754616000674c87bdc876c#{device.id}#movies"
),
"can_play": False,

View File

@ -203,8 +203,9 @@ async def test_set_operation_bad_attr_and_state(
with pytest.raises(vol.Invalid) as excinfo:
await common.async_set_hvac_mode(hass, None, ENTITY_CLIMATE)
assert (
"expected HVACMode or one of 'off', 'heat', 'cool', 'heat_cool', 'auto', 'dry', 'fan_only' for dictionary value @ data['hvac_mode']"
) in str(excinfo.value)
"expected HVACMode or one of 'off', 'heat', 'cool', 'heat_cool', 'auto', 'dry',"
" 'fan_only' for dictionary value @ data['hvac_mode']" in str(excinfo.value)
)
state = hass.states.get(ENTITY_CLIMATE)
assert state.state == "off"
@ -915,8 +916,8 @@ async def test_set_preset_mode_pessimistic(
async_fire_mqtt_message(hass, "preset-mode-state", "nonsense")
assert (
"'nonsense' received on topic preset-mode-state. 'nonsense' is not a valid preset mode"
in caplog.text
"'nonsense' received on topic preset-mode-state."
" 'nonsense' is not a valid preset mode" in caplog.text
)
state = hass.states.get(ENTITY_CLIMATE)

View File

@ -20,8 +20,9 @@ LIGHT_AND_SIGNAL_SERVICE_INFO = BluetoothServiceInfo(
address="aa:bb:cc:dd:ee:ff",
rssi=-60,
service_data={
"0000fdcd-0000-1000-8000-00805f9b34fb": b"H\x12"
b"\xcd\xd5`4-X\x08\x04\x00\r\x00\x00\x0f\x01\xee"
"0000fdcd-0000-1000-8000-00805f9b34fb": (
b"H\x12\xcd\xd5`4-X\x08\x04\x00\r\x00\x00\x0f\x01\xee"
)
},
source="local",
)

View File

@ -44,10 +44,12 @@ def check_entities(
assert registry_entry.unique_id == expected_entity[ATTR_UNIQUE_ID]
state = hass.states.get(entity_id)
assert state, f"Expected valid state for {entity_id}, got {state}"
assert (
state.state == expected_entity[ATTR_STATE]
), f"Expected state {expected_entity[ATTR_STATE]}, got {state.state} for {entity_id}"
assert state.state == expected_entity[ATTR_STATE], (
f"Expected state {expected_entity[ATTR_STATE]}, got {state.state} for"
f" {entity_id}"
)
for attr in FIXED_ATTRIBUTES:
assert state.attributes.get(attr) == expected_entity.get(
attr
), f"Expected attribute {attr} == {expected_entity.get(attr)}, got {state.attributes.get(attr)} for {entity_id}"
assert state.attributes.get(attr) == expected_entity.get(attr), (
f"Expected attribute {attr} == {expected_entity.get(attr)}, got"
f" {state.attributes.get(attr)} for {entity_id}"
)

View File

@ -103,13 +103,13 @@ async def test_rpc_config_entry_diagnostics(
None,
{
"89": {
"__type": "<class " "'bytes'>",
"__type": "<class 'bytes'>",
"repr": "b'\\xd1\\xfb;t\\xc8\\x90'",
}
},
{
"00000d00-0000-1000-8000-00805f9b34fb": {
"__type": "<class " "'bytes'>",
"__type": "<class 'bytes'>",
"repr": "b'H\\x10a'",
}
},

View File

@ -53,7 +53,10 @@ async def test_plex_play_media(hass, async_autosetup_sonos):
# Test handling shuffle in payload
mock_lookup.reset_mock()
mock_add_to_queue.reset_mock()
shuffle_media_content_id = '{"library_name": "Music", "artist_name": "Artist", "album_name": "Album", "shuffle": 1}'
shuffle_media_content_id = (
'{"library_name": "Music", "artist_name": "Artist", '
'"album_name": "Album", "shuffle": 1}'
)
assert await hass.services.async_call(
MP_DOMAIN,
@ -109,7 +112,9 @@ async def test_plex_play_media(hass, async_autosetup_sonos):
{
ATTR_ENTITY_ID: media_player,
ATTR_MEDIA_CONTENT_TYPE: MediaType.MUSIC,
ATTR_MEDIA_CONTENT_ID: f"{PLEX_URI_SCHEME}{server_id}/{plex_item_key}?shuffle=1",
ATTR_MEDIA_CONTENT_ID: (
f"{PLEX_URI_SCHEME}{server_id}/{plex_item_key}?shuffle=1"
),
},
blocking=True,
)

View File

@ -1046,14 +1046,14 @@ async def test_state_characteristics(hass: HomeAssistant):
f"sensor.test_{characteristic['source_sensor_domain']}_{characteristic['name']}"
)
assert state is not None, (
f"no state object for characteristic "
"no state object for characteristic "
f"'{characteristic['source_sensor_domain']}/{characteristic['name']}' "
f"(buffer filled)"
"(buffer filled)"
)
assert state.state == str(characteristic["value_9"]), (
f"value mismatch for characteristic "
"value mismatch for characteristic "
f"'{characteristic['source_sensor_domain']}/{characteristic['name']}' "
f"(buffer filled) - "
"(buffer filled) - "
f"assert {state.state} == {str(characteristic['value_9'])}"
)
assert (
@ -1071,14 +1071,14 @@ async def test_state_characteristics(hass: HomeAssistant):
f"sensor.test_{characteristic['source_sensor_domain']}_{characteristic['name']}"
)
assert state is not None, (
f"no state object for characteristic "
"no state object for characteristic "
f"'{characteristic['source_sensor_domain']}/{characteristic['name']}' "
f"(one stored value)"
"(one stored value)"
)
assert state.state == str(characteristic["value_1"]), (
f"value mismatch for characteristic "
"value mismatch for characteristic "
f"'{characteristic['source_sensor_domain']}/{characteristic['name']}' "
f"(one stored value) - "
"(one stored value) - "
f"assert {state.state} == {str(characteristic['value_1'])}"
)
@ -1093,14 +1093,14 @@ async def test_state_characteristics(hass: HomeAssistant):
f"sensor.test_{characteristic['source_sensor_domain']}_{characteristic['name']}"
)
assert state is not None, (
f"no state object for characteristic "
"no state object for characteristic "
f"'{characteristic['source_sensor_domain']}/{characteristic['name']}' "
f"(buffer empty)"
"(buffer empty)"
)
assert state.state == str(characteristic["value_0"]), (
f"value mismatch for characteristic "
"value mismatch for characteristic "
f"'{characteristic['source_sensor_domain']}/{characteristic['name']}' "
f"(buffer empty) - "
"(buffer empty) - "
f"assert {state.state} == {str(characteristic['value_0'])}"
)

View File

@ -115,7 +115,10 @@ async def test_stream_audio(hass, hass_client):
response = await client.post(
"/api/stt/test",
headers={
"X-Speech-Content": "format=wav; codec=pcm; sample_rate=16000; bit_rate=16; channel=1; language=en"
"X-Speech-Content": (
"format=wav; codec=pcm; sample_rate=16000; bit_rate=16; channel=1;"
" language=en"
)
},
)
assert response.status == HTTPStatus.OK
@ -127,7 +130,10 @@ async def test_stream_audio(hass, hass_client):
(
(None, 400, "Missing X-Speech-Content header"),
(
"format=wav; codec=pcm; sample_rate=16000; bit_rate=16; channel=100; language=en",
(
"format=wav; codec=pcm; sample_rate=16000; bit_rate=16; channel=100;"
" language=en"
),
400,
"100 is not a valid AudioChannels",
),

View File

@ -3,4 +3,7 @@
MOCK_FAILED_TO_LOGIN_MSG = (
"Central Unit replied with failure: {'status': 'LOGIN_FAILED'}"
)
MOCK_INVALID_TOKEN_MGS = "Error fetching switchbee data: Error communicating with API: data Request failed due to INVALID_TOKEN, trying to re-login"
MOCK_INVALID_TOKEN_MGS = (
"Error fetching switchbee data: Error communicating with API: data Request failed"
" due to INVALID_TOKEN, trying to re-login"
)

View File

@ -31,8 +31,10 @@ async def test_diagnostics(
},
"device_type": {
"__type": "<enum 'DeviceType'>",
"repr": "<DeviceType.V4: ('Switcher V4', '0317', "
"1, <DeviceCategory.WATER_HEATER: 1>)>",
"repr": (
"<DeviceType.V4: ('Switcher V4', '0317', "
"1, <DeviceCategory.WATER_HEATER: 1>)>"
),
},
"electric_current": 12.8,
"ip_address": REDACTED,

View File

@ -1236,7 +1236,10 @@ async def test_transition(hass, mqtt_mock, setup_tasmota):
async_fire_mqtt_message(
hass,
"tasmota_49A3BC/tele/STATE",
'{"POWER":"ON","Dimmer":50, "Color":"0,255,0","HSBColor":"120,100,50","White":0}',
(
'{"POWER":"ON","Dimmer":50,'
' "Color":"0,255,0","HSBColor":"120,100,50","White":0}'
),
)
state = hass.states.get("light.test")
assert state.state == STATE_ON
@ -1247,7 +1250,10 @@ async def test_transition(hass, mqtt_mock, setup_tasmota):
await common.async_turn_on(hass, "light.test", rgb_color=[255, 0, 0], transition=6)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Fade2 1;NoDelay;Speed2 24;NoDelay;Power1 ON;NoDelay;HsbColor1 0;NoDelay;HsbColor2 100",
(
"NoDelay;Fade2 1;NoDelay;Speed2 24;NoDelay;Power1 ON;NoDelay;HsbColor1"
" 0;NoDelay;HsbColor2 100"
),
0,
False,
)
@ -1268,7 +1274,10 @@ async def test_transition(hass, mqtt_mock, setup_tasmota):
await common.async_turn_on(hass, "light.test", rgb_color=[255, 0, 0], transition=6)
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Fade2 1;NoDelay;Speed2 12;NoDelay;Power1 ON;NoDelay;HsbColor1 0;NoDelay;HsbColor2 100",
(
"NoDelay;Fade2 1;NoDelay;Speed2 12;NoDelay;Power1 ON;NoDelay;HsbColor1"
" 0;NoDelay;HsbColor2 100"
),
0,
False,
)

View File

@ -102,7 +102,9 @@ OPEN_CLOSE_COVER_CONFIG = {
"covers": {
"test_template_cover": {
**OPEN_CLOSE_COVER_CONFIG,
"position_template": "{{ states.cover.test.attributes.position }}",
"position_template": (
"{{ states.cover.test.attributes.position }}"
),
"value_template": "{{ states.cover.test_state.state }}",
}
},
@ -176,7 +178,9 @@ async def test_template_state_boolean(hass, start_ha):
"covers": {
"test_template_cover": {
**OPEN_CLOSE_COVER_CONFIG,
"position_template": "{{ states.cover.test.attributes.position }}",
"position_template": (
"{{ states.cover.test.attributes.position }}"
),
}
},
}
@ -247,11 +251,13 @@ async def test_template_tilt(hass, start_ha):
"test_template_cover": {
**OPEN_CLOSE_COVER_CONFIG,
"position_template": "{{ on }}",
"tilt_template": "{% if states.cover.test_state.state %}"
"on"
"{% else %}"
"off"
"{% endif %}",
"tilt_template": (
"{% if states.cover.test_state.state %}"
"on"
"{% else %}"
"off"
"{% endif %}"
),
},
},
}
@ -633,9 +639,9 @@ async def test_set_tilt_position_optimistic(hass, start_ha, calls):
"test_template_cover": {
**OPEN_CLOSE_COVER_CONFIG,
"value_template": "{{ states.cover.test_state.state }}",
"icon_template": "{% if states.cover.test_state.state %}"
"mdi:check"
"{% endif %}",
"icon_template": (
"{% if states.cover.test_state.state %}mdi:check{% endif %}"
),
}
},
}
@ -666,9 +672,11 @@ async def test_icon_template(hass, start_ha):
"test_template_cover": {
**OPEN_CLOSE_COVER_CONFIG,
"value_template": "{{ states.cover.test_state.state }}",
"entity_picture_template": "{% if states.cover.test_state.state %}"
"/local/cover.png"
"{% endif %}",
"entity_picture_template": (
"{% if states.cover.test_state.state %}"
"/local/cover.png"
"{% endif %}"
),
}
},
}
@ -699,7 +707,9 @@ async def test_entity_picture_template(hass, start_ha):
"test_template_cover": {
**OPEN_CLOSE_COVER_CONFIG,
"value_template": "open",
"availability_template": "{{ is_state('availability_state.state','on') }}",
"availability_template": (
"{{ is_state('availability_state.state','on') }}"
),
}
},
}
@ -765,7 +775,7 @@ async def test_invalid_availability_template_keeps_component_available(
):
"""Test that an invalid availability keeps the device available."""
assert hass.states.get("cover.test_template_cover") != STATE_UNAVAILABLE
assert ("UndefinedError: 'x' is undefined") in caplog_setup_text
assert "UndefinedError: 'x' is undefined" in caplog_setup_text
@pytest.mark.parametrize("count,domain", [(1, DOMAIN)])
@ -855,7 +865,9 @@ async def test_unique_id(hass, start_ha):
"garage_door": {
**OPEN_CLOSE_COVER_CONFIG,
"friendly_name": "Garage Door",
"value_template": "{{ is_state('binary_sensor.garage_door_sensor', 'off') }}",
"value_template": (
"{{ is_state('binary_sensor.garage_door_sensor', 'off') }}"
),
},
},
}

View File

@ -139,8 +139,12 @@ async def test_wrong_template_config(hass, start_ha):
{{ 'off' }}
{% endif %}
""",
"percentage_template": "{{ states('input_number.percentage') }}",
"preset_mode_template": "{{ states('input_select.preset_mode') }}",
"percentage_template": (
"{{ states('input_number.percentage') }}"
),
"preset_mode_template": (
"{{ states('input_select.preset_mode') }}"
),
"oscillating_template": "{{ states('input_select.osc') }}",
"direction_template": "{{ states('input_select.direction') }}",
"speed_count": "3",
@ -216,7 +220,9 @@ async def test_templates_with_entities(hass, start_ha):
"test_fan": {
"value_template": "{{ 'on' }}",
"preset_modes": ["auto", "smart"],
"preset_mode_template": "{{ states('sensor.preset_mode') }}",
"preset_mode_template": (
"{{ states('sensor.preset_mode') }}"
),
"turn_on": {"service": "script.fan_on"},
"turn_off": {"service": "script.fan_off"},
},
@ -251,7 +257,9 @@ async def test_templates_with_entities2(hass, entity, tests, start_ha):
"platform": "template",
"fans": {
"test_fan": {
"availability_template": "{{ is_state('availability_boolean.state', 'on') }}",
"availability_template": (
"{{ is_state('availability_boolean.state', 'on') }}"
),
"value_template": "{{ 'on' }}",
"oscillating_template": "{{ 1 == 1 }}",
"direction_template": "{{ 'forward' }}",
@ -362,7 +370,9 @@ async def test_template_with_unavailable_entities(hass, states, start_ha):
"test_fan": {
"value_template": "{{ 'on' }}",
"availability_template": "{{ x - 12 }}",
"preset_mode_template": "{{ states('input_select.preset_mode') }}",
"preset_mode_template": (
"{{ states('input_select.preset_mode') }}"
),
"oscillating_template": "{{ states('input_select.osc') }}",
"direction_template": "{{ states('input_select.direction') }}",
"turn_on": {"service": "script.fan_on"},
@ -937,7 +947,10 @@ async def test_implemented_percentage(hass, speed_count, percentage_step):
"friendly_name": "Mechanische ventilatie",
"unique_id": "a2fd2e38-674b-4b47-b5ef-cc2362211a72",
"value_template": "{{ states('light.mv_snelheid') }}",
"percentage_template": "{{ (state_attr('light.mv_snelheid','brightness') | int / 255 * 100) | int }}",
"percentage_template": (
"{{ (state_attr('light.mv_snelheid','brightness') | int /"
" 255 * 100) | int }}"
),
"turn_on": [
{
"service": "switch.turn_off",

View File

@ -738,9 +738,9 @@ async def test_friendly_name(hass, setup_light):
**OPTIMISTIC_BRIGHTNESS_LIGHT_CONFIG,
"friendly_name": "Template light",
"value_template": "{{ 1 == 1 }}",
"icon_template": "{% if states.light.test_state.state %}"
"mdi:check"
"{% endif %}",
"icon_template": (
"{% if states.light.test_state.state %}mdi:check{% endif %}"
),
}
},
],
@ -767,9 +767,9 @@ async def test_icon_template(hass, setup_light):
**OPTIMISTIC_BRIGHTNESS_LIGHT_CONFIG,
"friendly_name": "Template light",
"value_template": "{{ 1 == 1 }}",
"entity_picture_template": "{% if states.light.test_state.state %}"
"/local/light.png"
"{% endif %}",
"entity_picture_template": (
"{% if states.light.test_state.state %}/local/light.png{% endif %}"
),
}
},
],
@ -1143,7 +1143,9 @@ async def test_effect_template(hass, expected_effect, count, effect_template):
"effect": "{{effect}}",
},
},
"effect_list_template": "{{ ['Strobe color', 'Police', 'Christmas', 'RGB', 'Random Loop'] }}",
"effect_list_template": (
"{{ ['Strobe color', 'Police', 'Christmas', 'RGB', 'Random Loop'] }}"
),
"effect_template": effect_template,
}
}
@ -1279,7 +1281,9 @@ async def test_supports_transition_template(
{
"test_template_light": {
**OPTIMISTIC_BRIGHTNESS_LIGHT_CONFIG,
"availability_template": "{{ is_state('availability_boolean.state', 'on') }}",
"availability_template": (
"{{ is_state('availability_boolean.state', 'on') }}"
),
}
},
],
@ -1318,7 +1322,7 @@ async def test_invalid_availability_template_keeps_component_available(
):
"""Test that an invalid availability keeps the device available."""
assert hass.states.get("light.test_template_light").state != STATE_UNAVAILABLE
assert ("UndefinedError: 'x' is undefined") in caplog_setup_text
assert "UndefinedError: 'x' is undefined" in caplog_setup_text
@pytest.mark.parametrize("count", [1])

View File

@ -137,9 +137,11 @@ async def test_icon_template(hass):
"test_template_switch": {
**OPTIMISTIC_SWITCH_CONFIG,
"value_template": "{{ states.switch.test_state.state }}",
"icon_template": "{% if states.switch.test_state.state %}"
"mdi:check"
"{% endif %}",
"icon_template": (
"{% if states.switch.test_state.state %}"
"mdi:check"
"{% endif %}"
),
}
},
}
@ -173,9 +175,11 @@ async def test_entity_picture_template(hass):
"test_template_switch": {
**OPTIMISTIC_SWITCH_CONFIG,
"value_template": "{{ states.switch.test_state.state }}",
"entity_picture_template": "{% if states.switch.test_state.state %}"
"/local/switch.png"
"{% endif %}",
"entity_picture_template": (
"{% if states.switch.test_state.state %}"
"/local/switch.png"
"{% endif %}"
),
}
},
}
@ -564,7 +568,9 @@ async def test_available_template_with_entities(hass):
"test_template_switch": {
**OPTIMISTIC_SWITCH_CONFIG,
"value_template": "{{ 1 == 1 }}",
"availability_template": "{{ is_state('availability_state.state', 'on') }}",
"availability_template": (
"{{ is_state('availability_state.state', 'on') }}"
),
}
},
}
@ -610,7 +616,7 @@ async def test_invalid_availability_template_keeps_component_available(hass, cap
await hass.async_block_till_done()
assert hass.states.get("switch.test_template_switch").state != STATE_UNAVAILABLE
assert ("UndefinedError: 'x' is undefined") in caplog.text
assert "UndefinedError: 'x' is undefined" in caplog.text
async def test_unique_id(hass):

View File

@ -30,7 +30,9 @@ def setup_comp(hass, calls):
automation.DOMAIN: {
"trigger": {
"platform": "template",
"value_template": '{{ states.test.entity.state == "world" and true }}',
"value_template": (
'{{ states.test.entity.state == "world" and true }}'
),
},
"action": {
"service": "test.automation",
@ -69,7 +71,9 @@ async def test_if_fires_on_change_bool(hass, start_ha, calls):
automation.DOMAIN: {
"trigger": {
"platform": "template",
"value_template": '{{ states.test.entity.state == "world" and "true" }}',
"value_template": (
'{{ states.test.entity.state == "world" and "true" }}'
),
},
"action": {"service": "test.automation"},
}
@ -81,7 +85,9 @@ async def test_if_fires_on_change_bool(hass, start_ha, calls):
automation.DOMAIN: {
"trigger": {
"platform": "template",
"value_template": '{{ states.test.entity.state == "world" and "TrUE" }}',
"value_template": (
'{{ states.test.entity.state == "world" and "TrUE" }}'
),
},
"action": {"service": "test.automation"},
}
@ -93,7 +99,9 @@ async def test_if_fires_on_change_bool(hass, start_ha, calls):
automation.DOMAIN: {
"trigger": {
"platform": "template",
"value_template": '{{ states.test.entity.state == "world" and false }}',
"value_template": (
'{{ states.test.entity.state == "world" and false }}'
),
},
"action": {"service": "test.automation"},
}
@ -175,7 +183,9 @@ async def test_if_fires_on_change_bool(hass, start_ha, calls):
"trigger_variables": {"entity": "test.entity"},
"trigger": {
"platform": "template",
"value_template": '{{ is_state(entity|default("test.entity2"), "hello") }}',
"value_template": (
'{{ is_state(entity|default("test.entity2"), "hello") }}'
),
},
"action": {"service": "test.automation"},
},
@ -272,7 +282,9 @@ async def test_general(hass, call_setup, start_ha, calls):
automation.DOMAIN: {
"trigger": {
"platform": "template",
"value_template": "{{ 84 / states.test.number.state|int == 42 }}",
"value_template": (
"{{ 84 / states.test.number.state|int == 42 }}"
),
},
"action": {"service": "test.automation"},
}

View File

@ -497,8 +497,8 @@ async def test_control_error_handling(hass, client, caplog, monkeypatch):
assert client.play.call_count == 1
assert (
f"Error calling async_media_play on entity {ENTITY_ID}, state:off, error: TimeoutError()"
in caplog.text
f"Error calling async_media_play on entity {ENTITY_ID}, state:off, error:"
" TimeoutError()" in caplog.text
)

View File

@ -1768,7 +1768,10 @@ async def test_validate_config_works(websocket_client, key, config):
"entity_id": "hello.world",
"state": "paulus",
},
"Unexpected value for condition: 'non_existing'. Expected and, device, not, numeric_state, or, state, sun, template, time, trigger, zone",
(
"Unexpected value for condition: 'non_existing'. Expected and, device,"
" not, numeric_state, or, state, sun, template, time, trigger, zone"
),
),
(
"action",

View File

@ -26,9 +26,11 @@ async def test_diagnostics(
"free_heap": 14600,
"leds": {
"__type": "<class 'wled.models.Leds'>",
"repr": "Leds(cct=False, count=30, fps=None, light_capabilities=None, "
"max_power=850, max_segments=10, power=470, rgbw=False, wv=True, "
"segment_light_capabilities=None)",
"repr": (
"Leds(cct=False, count=30, fps=None, light_capabilities=None, "
"max_power=850, max_segments=10, power=470, rgbw=False, wv=True, "
"segment_light_capabilities=None)"
),
},
"live_ip": "Unknown",
"live_mode": "Unknown",

View File

@ -27,7 +27,9 @@ LYWSDCGQ_SERVICE_INFO = BluetoothServiceInfoBleak(
rssi=-63,
manufacturer_data={},
service_data={
"0000fe95-0000-1000-8000-00805f9b34fb": b"P \xaa\x01\xda!\x9354-X\r\x10\x04\xfe\x00H\x02"
"0000fe95-0000-1000-8000-00805f9b34fb": (
b"P \xaa\x01\xda!\x9354-X\r\x10\x04\xfe\x00H\x02"
)
},
service_uuids=["0000fe95-0000-1000-8000-00805f9b34fb"],
source="local",
@ -43,7 +45,9 @@ MMC_T201_1_SERVICE_INFO = BluetoothServiceInfoBleak(
rssi=-56,
manufacturer_data={},
service_data={
"0000fe95-0000-1000-8000-00805f9b34fb": b'p"\xdb\x00o\xc1o\xdd\xf9\x81\x00\t\x00 \x05\xc6\rc\rQ'
"0000fe95-0000-1000-8000-00805f9b34fb": (
b'p"\xdb\x00o\xc1o\xdd\xf9\x81\x00\t\x00 \x05\xc6\rc\rQ'
)
},
service_uuids=["0000fe95-0000-1000-8000-00805f9b34fb"],
source="local",
@ -59,7 +63,9 @@ JTYJGD03MI_SERVICE_INFO = BluetoothServiceInfoBleak(
rssi=-56,
manufacturer_data={},
service_data={
"0000fe95-0000-1000-8000-00805f9b34fb": b'XY\x97\td\xbc\x9c\xe3D\xefT" `\x88\xfd\x00\x00\x00\x00:\x14\x8f\xb3'
"0000fe95-0000-1000-8000-00805f9b34fb": (
b'XY\x97\td\xbc\x9c\xe3D\xefT" `\x88\xfd\x00\x00\x00\x00:\x14\x8f\xb3'
)
},
service_uuids=["0000fe95-0000-1000-8000-00805f9b34fb"],
source="local",
@ -75,7 +81,9 @@ YLKG07YL_SERVICE_INFO = BluetoothServiceInfoBleak(
rssi=-56,
manufacturer_data={},
service_data={
"0000fe95-0000-1000-8000-00805f9b34fb": b"X0\xb6\x03\xd2\x8b\x98\xc5A$\xf8\xc3I\x14vu~\x00\x00\x00\x99",
"0000fe95-0000-1000-8000-00805f9b34fb": (
b"X0\xb6\x03\xd2\x8b\x98\xc5A$\xf8\xc3I\x14vu~\x00\x00\x00\x99"
),
},
service_uuids=["0000fe95-0000-1000-8000-00805f9b34fb"],
source="local",

View File

@ -964,7 +964,7 @@ async def test_async_step_reauth_v4(hass):
saved_callback(
make_advertisement(
"54:EF:44:E3:9C:BC",
b"XY\x97\tf\xbc\x9c\xe3D\xefT\x01" b"\x08\x12\x05\x00\x00\x00q^\xbe\x90",
b"XY\x97\tf\xbc\x9c\xe3D\xefT\x01\x08\x12\x05\x00\x00\x00q^\xbe\x90",
),
BluetoothChange.ADVERTISEMENT,
)
@ -1013,7 +1013,7 @@ async def test_async_step_reauth_v4_wrong_key(hass):
saved_callback(
make_advertisement(
"54:EF:44:E3:9C:BC",
b"XY\x97\tf\xbc\x9c\xe3D\xefT\x01" b"\x08\x12\x05\x00\x00\x00q^\xbe\x90",
b"XY\x97\tf\xbc\x9c\xe3D\xefT\x01\x08\x12\x05\x00\x00\x00q^\xbe\x90",
),
BluetoothChange.ADVERTISEMENT,
)

View File

@ -32,8 +32,10 @@ CAPABILITIES = {
"model": MODEL,
"fw_ver": FW_VER,
"location": f"yeelight://{IP_ADDRESS}",
"support": "get_prop set_default set_power toggle set_bright start_cf stop_cf"
" set_scene cron_add cron_get cron_del set_ct_abx set_rgb",
"support": (
"get_prop set_default set_power toggle set_bright start_cf stop_cf"
" set_scene cron_add cron_get cron_del set_ct_abx set_rgb"
),
"name": "",
}

View File

@ -645,7 +645,8 @@ async def test_state_already_set_avoid_ratelimit(hass: HomeAssistant):
mocked_bulb.async_set_rgb.reset_mock()
mocked_bulb.last_properties["flowing"] = "0"
mocked_bulb.model = "color" # color model needs a workaround (see MODELS_WITH_DELAYED_ON_TRANSITION)
# color model needs a workaround (see MODELS_WITH_DELAYED_ON_TRANSITION)
mocked_bulb.model = "color"
await hass.services.async_call(
"light",
SERVICE_TURN_ON,

View File

@ -375,8 +375,10 @@ def _ch_mock(cluster):
@mock.patch(
"homeassistant.components.zha.core.discovery.ProbeEndpoint"
".handle_on_off_output_cluster_exception",
(
"homeassistant.components.zha.core.discovery.ProbeEndpoint"
".handle_on_off_output_cluster_exception"
),
new=mock.MagicMock(),
)
@mock.patch(

View File

@ -138,9 +138,9 @@ async def test_zha_logbook_event_device_with_triggers(hass, mock_devices):
assert events[1]["name"] == "FakeManufacturer FakeModel"
assert events[1]["domain"] == "zha"
assert (
events[1]["message"]
== "Up - Remote Button Double Press event was fired with parameters: {'test': 'test'}"
assert events[1]["message"] == (
"Up - Remote Button Double Press event was fired with parameters: "
"{'test': 'test'}"
)

View File

@ -875,7 +875,10 @@ async def test_se_summation_uom(
(9, "ACTIVE_MEASUREMENT, PHASE_A_MEASUREMENT"),
(
15,
"ACTIVE_MEASUREMENT, REACTIVE_MEASUREMENT, APPARENT_MEASUREMENT, PHASE_A_MEASUREMENT",
(
"ACTIVE_MEASUREMENT, REACTIVE_MEASUREMENT, APPARENT_MEASUREMENT,"
" PHASE_A_MEASUREMENT"
),
),
),
)

View File

@ -562,7 +562,9 @@ DEVICES = [
("binary_sensor", "00:11:22:33:44:55:66:77-2-1030"): {
DEV_SIG_CHANNELS: ["occupancy"],
DEV_SIG_ENT_MAP_CLASS: "Occupancy",
DEV_SIG_ENT_MAP_ID: "binary_sensor.centralite_motion_sensor_a_occupancy",
DEV_SIG_ENT_MAP_ID: (
"binary_sensor.centralite_motion_sensor_a_occupancy"
),
},
},
},
@ -600,22 +602,30 @@ DEVICES = [
("switch", "00:11:22:33:44:55:66:77-1"): {
DEV_SIG_CHANNELS: ["on_off"],
DEV_SIG_ENT_MAP_CLASS: "Switch",
DEV_SIG_ENT_MAP_ID: "switch.climaxtechnology_psmp5_00_00_02_02tc_switch",
DEV_SIG_ENT_MAP_ID: (
"switch.climaxtechnology_psmp5_00_00_02_02tc_switch"
),
},
("button", "00:11:22:33:44:55:66:77-1-3"): {
DEV_SIG_CHANNELS: ["identify"],
DEV_SIG_ENT_MAP_CLASS: "ZHAIdentifyButton",
DEV_SIG_ENT_MAP_ID: "button.climaxtechnology_psmp5_00_00_02_02tc_identify",
DEV_SIG_ENT_MAP_ID: (
"button.climaxtechnology_psmp5_00_00_02_02tc_identify"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-1794"): {
DEV_SIG_CHANNELS: ["smartenergy_metering"],
DEV_SIG_ENT_MAP_CLASS: "SmartEnergyMetering",
DEV_SIG_ENT_MAP_ID: "sensor.climaxtechnology_psmp5_00_00_02_02tc_instantaneous_demand",
DEV_SIG_ENT_MAP_ID: (
"sensor.climaxtechnology_psmp5_00_00_02_02tc_instantaneous_demand"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-1794-summation_delivered"): {
DEV_SIG_CHANNELS: ["smartenergy_metering"],
DEV_SIG_ENT_MAP_CLASS: "SmartEnergySummation",
DEV_SIG_ENT_MAP_ID: "sensor.climaxtechnology_psmp5_00_00_02_02tc_summation_delivered",
DEV_SIG_ENT_MAP_ID: (
"sensor.climaxtechnology_psmp5_00_00_02_02tc_summation_delivered"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-0-rssi"): {
DEV_SIG_CHANNELS: ["basic"],
@ -659,12 +669,16 @@ DEVICES = [
("binary_sensor", "00:11:22:33:44:55:66:77-1-1280"): {
DEV_SIG_CHANNELS: ["ias_zone"],
DEV_SIG_ENT_MAP_CLASS: "IASZone",
DEV_SIG_ENT_MAP_ID: "binary_sensor.climaxtechnology_sd8sc_00_00_03_12tc_iaszone",
DEV_SIG_ENT_MAP_ID: (
"binary_sensor.climaxtechnology_sd8sc_00_00_03_12tc_iaszone"
),
},
("button", "00:11:22:33:44:55:66:77-1-3"): {
DEV_SIG_CHANNELS: ["identify"],
DEV_SIG_ENT_MAP_CLASS: "ZHAIdentifyButton",
DEV_SIG_ENT_MAP_ID: "button.climaxtechnology_sd8sc_00_00_03_12tc_identify",
DEV_SIG_ENT_MAP_ID: (
"button.climaxtechnology_sd8sc_00_00_03_12tc_identify"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-0-rssi"): {
DEV_SIG_CHANNELS: ["basic"],
@ -679,22 +693,30 @@ DEVICES = [
("select", "00:11:22:33:44:55:66:77-1-1282-WarningMode"): {
DEV_SIG_CHANNELS: ["ias_wd"],
DEV_SIG_ENT_MAP_CLASS: "ZHADefaultToneSelectEntity",
DEV_SIG_ENT_MAP_ID: "select.climaxtechnology_sd8sc_00_00_03_12tc_default_siren_tone",
DEV_SIG_ENT_MAP_ID: (
"select.climaxtechnology_sd8sc_00_00_03_12tc_default_siren_tone"
),
},
("select", "00:11:22:33:44:55:66:77-1-1282-SirenLevel"): {
DEV_SIG_CHANNELS: ["ias_wd"],
DEV_SIG_ENT_MAP_CLASS: "ZHADefaultSirenLevelSelectEntity",
DEV_SIG_ENT_MAP_ID: "select.climaxtechnology_sd8sc_00_00_03_12tc_default_siren_level",
DEV_SIG_ENT_MAP_ID: (
"select.climaxtechnology_sd8sc_00_00_03_12tc_default_siren_level"
),
},
("select", "00:11:22:33:44:55:66:77-1-1282-StrobeLevel"): {
DEV_SIG_CHANNELS: ["ias_wd"],
DEV_SIG_ENT_MAP_CLASS: "ZHADefaultStrobeLevelSelectEntity",
DEV_SIG_ENT_MAP_ID: "select.climaxtechnology_sd8sc_00_00_03_12tc_default_strobe_level",
DEV_SIG_ENT_MAP_ID: (
"select.climaxtechnology_sd8sc_00_00_03_12tc_default_strobe_level"
),
},
("select", "00:11:22:33:44:55:66:77-1-1282-Strobe"): {
DEV_SIG_CHANNELS: ["ias_wd"],
DEV_SIG_ENT_MAP_CLASS: "ZHADefaultStrobeSelectEntity",
DEV_SIG_ENT_MAP_ID: "select.climaxtechnology_sd8sc_00_00_03_12tc_default_strobe",
DEV_SIG_ENT_MAP_ID: (
"select.climaxtechnology_sd8sc_00_00_03_12tc_default_strobe"
),
},
("siren", "00:11:22:33:44:55:66:77-1-1282"): {
DEV_SIG_CHANNELS: ["ias_wd"],
@ -728,12 +750,16 @@ DEVICES = [
("binary_sensor", "00:11:22:33:44:55:66:77-1-1280"): {
DEV_SIG_CHANNELS: ["ias_zone"],
DEV_SIG_ENT_MAP_CLASS: "IASZone",
DEV_SIG_ENT_MAP_ID: "binary_sensor.climaxtechnology_ws15_00_00_03_03tc_iaszone",
DEV_SIG_ENT_MAP_ID: (
"binary_sensor.climaxtechnology_ws15_00_00_03_03tc_iaszone"
),
},
("button", "00:11:22:33:44:55:66:77-1-3"): {
DEV_SIG_CHANNELS: ["identify"],
DEV_SIG_ENT_MAP_CLASS: "ZHAIdentifyButton",
DEV_SIG_ENT_MAP_ID: "button.climaxtechnology_ws15_00_00_03_03tc_identify",
DEV_SIG_ENT_MAP_ID: (
"button.climaxtechnology_ws15_00_00_03_03tc_identify"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-0-rssi"): {
DEV_SIG_CHANNELS: ["basic"],
@ -1090,22 +1116,30 @@ DEVICES = [
("light", "00:11:22:33:44:55:66:77-1"): {
DEV_SIG_CHANNELS: ["on_off", "level", "light_color"],
DEV_SIG_ENT_MAP_CLASS: "Light",
DEV_SIG_ENT_MAP_ID: "light.ikea_of_sweden_tradfri_bulb_e12_ws_opal_600lm_light",
DEV_SIG_ENT_MAP_ID: (
"light.ikea_of_sweden_tradfri_bulb_e12_ws_opal_600lm_light"
),
},
("button", "00:11:22:33:44:55:66:77-1-3"): {
DEV_SIG_CHANNELS: ["identify"],
DEV_SIG_ENT_MAP_CLASS: "ZHAIdentifyButton",
DEV_SIG_ENT_MAP_ID: "button.ikea_of_sweden_tradfri_bulb_e12_ws_opal_600lm_identify",
DEV_SIG_ENT_MAP_ID: (
"button.ikea_of_sweden_tradfri_bulb_e12_ws_opal_600lm_identify"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-0-rssi"): {
DEV_SIG_CHANNELS: ["basic"],
DEV_SIG_ENT_MAP_CLASS: "RSSISensor",
DEV_SIG_ENT_MAP_ID: "sensor.ikea_of_sweden_tradfri_bulb_e12_ws_opal_600lm_rssi",
DEV_SIG_ENT_MAP_ID: (
"sensor.ikea_of_sweden_tradfri_bulb_e12_ws_opal_600lm_rssi"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-0-lqi"): {
DEV_SIG_CHANNELS: ["basic"],
DEV_SIG_ENT_MAP_CLASS: "LQISensor",
DEV_SIG_ENT_MAP_ID: "sensor.ikea_of_sweden_tradfri_bulb_e12_ws_opal_600lm_lqi",
DEV_SIG_ENT_MAP_ID: (
"sensor.ikea_of_sweden_tradfri_bulb_e12_ws_opal_600lm_lqi"
),
},
},
},
@ -1134,22 +1168,30 @@ DEVICES = [
("light", "00:11:22:33:44:55:66:77-1"): {
DEV_SIG_CHANNELS: ["on_off", "level", "light_color"],
DEV_SIG_ENT_MAP_CLASS: "Light",
DEV_SIG_ENT_MAP_ID: "light.ikea_of_sweden_tradfri_bulb_e26_cws_opal_600lm_light",
DEV_SIG_ENT_MAP_ID: (
"light.ikea_of_sweden_tradfri_bulb_e26_cws_opal_600lm_light"
),
},
("button", "00:11:22:33:44:55:66:77-1-3"): {
DEV_SIG_CHANNELS: ["identify"],
DEV_SIG_ENT_MAP_CLASS: "ZHAIdentifyButton",
DEV_SIG_ENT_MAP_ID: "button.ikea_of_sweden_tradfri_bulb_e26_cws_opal_600lm_identify",
DEV_SIG_ENT_MAP_ID: (
"button.ikea_of_sweden_tradfri_bulb_e26_cws_opal_600lm_identify"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-0-rssi"): {
DEV_SIG_CHANNELS: ["basic"],
DEV_SIG_ENT_MAP_CLASS: "RSSISensor",
DEV_SIG_ENT_MAP_ID: "sensor.ikea_of_sweden_tradfri_bulb_e26_cws_opal_600lm_rssi",
DEV_SIG_ENT_MAP_ID: (
"sensor.ikea_of_sweden_tradfri_bulb_e26_cws_opal_600lm_rssi"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-0-lqi"): {
DEV_SIG_CHANNELS: ["basic"],
DEV_SIG_ENT_MAP_CLASS: "LQISensor",
DEV_SIG_ENT_MAP_ID: "sensor.ikea_of_sweden_tradfri_bulb_e26_cws_opal_600lm_lqi",
DEV_SIG_ENT_MAP_ID: (
"sensor.ikea_of_sweden_tradfri_bulb_e26_cws_opal_600lm_lqi"
),
},
},
},
@ -1178,22 +1220,30 @@ DEVICES = [
("light", "00:11:22:33:44:55:66:77-1"): {
DEV_SIG_CHANNELS: ["on_off", "level"],
DEV_SIG_ENT_MAP_CLASS: "Light",
DEV_SIG_ENT_MAP_ID: "light.ikea_of_sweden_tradfri_bulb_e26_w_opal_1000lm_light",
DEV_SIG_ENT_MAP_ID: (
"light.ikea_of_sweden_tradfri_bulb_e26_w_opal_1000lm_light"
),
},
("button", "00:11:22:33:44:55:66:77-1-3"): {
DEV_SIG_CHANNELS: ["identify"],
DEV_SIG_ENT_MAP_CLASS: "ZHAIdentifyButton",
DEV_SIG_ENT_MAP_ID: "button.ikea_of_sweden_tradfri_bulb_e26_w_opal_1000lm_identify",
DEV_SIG_ENT_MAP_ID: (
"button.ikea_of_sweden_tradfri_bulb_e26_w_opal_1000lm_identify"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-0-rssi"): {
DEV_SIG_CHANNELS: ["basic"],
DEV_SIG_ENT_MAP_CLASS: "RSSISensor",
DEV_SIG_ENT_MAP_ID: "sensor.ikea_of_sweden_tradfri_bulb_e26_w_opal_1000lm_rssi",
DEV_SIG_ENT_MAP_ID: (
"sensor.ikea_of_sweden_tradfri_bulb_e26_w_opal_1000lm_rssi"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-0-lqi"): {
DEV_SIG_CHANNELS: ["basic"],
DEV_SIG_ENT_MAP_CLASS: "LQISensor",
DEV_SIG_ENT_MAP_ID: "sensor.ikea_of_sweden_tradfri_bulb_e26_w_opal_1000lm_lqi",
DEV_SIG_ENT_MAP_ID: (
"sensor.ikea_of_sweden_tradfri_bulb_e26_w_opal_1000lm_lqi"
),
},
},
},
@ -1222,22 +1272,30 @@ DEVICES = [
("light", "00:11:22:33:44:55:66:77-1"): {
DEV_SIG_CHANNELS: ["on_off", "level", "light_color"],
DEV_SIG_ENT_MAP_CLASS: "Light",
DEV_SIG_ENT_MAP_ID: "light.ikea_of_sweden_tradfri_bulb_e26_ws_opal_980lm_light",
DEV_SIG_ENT_MAP_ID: (
"light.ikea_of_sweden_tradfri_bulb_e26_ws_opal_980lm_light"
),
},
("button", "00:11:22:33:44:55:66:77-1-3"): {
DEV_SIG_CHANNELS: ["identify"],
DEV_SIG_ENT_MAP_CLASS: "ZHAIdentifyButton",
DEV_SIG_ENT_MAP_ID: "button.ikea_of_sweden_tradfri_bulb_e26_ws_opal_980lm_identify",
DEV_SIG_ENT_MAP_ID: (
"button.ikea_of_sweden_tradfri_bulb_e26_ws_opal_980lm_identify"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-0-rssi"): {
DEV_SIG_CHANNELS: ["basic"],
DEV_SIG_ENT_MAP_CLASS: "RSSISensor",
DEV_SIG_ENT_MAP_ID: "sensor.ikea_of_sweden_tradfri_bulb_e26_ws_opal_980lm_rssi",
DEV_SIG_ENT_MAP_ID: (
"sensor.ikea_of_sweden_tradfri_bulb_e26_ws_opal_980lm_rssi"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-0-lqi"): {
DEV_SIG_CHANNELS: ["basic"],
DEV_SIG_ENT_MAP_CLASS: "LQISensor",
DEV_SIG_ENT_MAP_ID: "sensor.ikea_of_sweden_tradfri_bulb_e26_ws_opal_980lm_lqi",
DEV_SIG_ENT_MAP_ID: (
"sensor.ikea_of_sweden_tradfri_bulb_e26_ws_opal_980lm_lqi"
),
},
},
},
@ -1266,22 +1324,30 @@ DEVICES = [
("light", "00:11:22:33:44:55:66:77-1"): {
DEV_SIG_CHANNELS: ["on_off", "level"],
DEV_SIG_ENT_MAP_CLASS: "Light",
DEV_SIG_ENT_MAP_ID: "light.ikea_of_sweden_tradfri_bulb_e26_opal_1000lm_light",
DEV_SIG_ENT_MAP_ID: (
"light.ikea_of_sweden_tradfri_bulb_e26_opal_1000lm_light"
),
},
("button", "00:11:22:33:44:55:66:77-1-3"): {
DEV_SIG_CHANNELS: ["identify"],
DEV_SIG_ENT_MAP_CLASS: "ZHAIdentifyButton",
DEV_SIG_ENT_MAP_ID: "button.ikea_of_sweden_tradfri_bulb_e26_opal_1000lm_identify",
DEV_SIG_ENT_MAP_ID: (
"button.ikea_of_sweden_tradfri_bulb_e26_opal_1000lm_identify"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-0-rssi"): {
DEV_SIG_CHANNELS: ["basic"],
DEV_SIG_ENT_MAP_CLASS: "RSSISensor",
DEV_SIG_ENT_MAP_ID: "sensor.ikea_of_sweden_tradfri_bulb_e26_opal_1000lm_rssi",
DEV_SIG_ENT_MAP_ID: (
"sensor.ikea_of_sweden_tradfri_bulb_e26_opal_1000lm_rssi"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-0-lqi"): {
DEV_SIG_CHANNELS: ["basic"],
DEV_SIG_ENT_MAP_CLASS: "LQISensor",
DEV_SIG_ENT_MAP_ID: "sensor.ikea_of_sweden_tradfri_bulb_e26_opal_1000lm_lqi",
DEV_SIG_ENT_MAP_ID: (
"sensor.ikea_of_sweden_tradfri_bulb_e26_opal_1000lm_lqi"
),
},
},
},
@ -1310,12 +1376,16 @@ DEVICES = [
("switch", "00:11:22:33:44:55:66:77-1"): {
DEV_SIG_CHANNELS: ["on_off"],
DEV_SIG_ENT_MAP_CLASS: "Switch",
DEV_SIG_ENT_MAP_ID: "switch.ikea_of_sweden_tradfri_control_outlet_switch",
DEV_SIG_ENT_MAP_ID: (
"switch.ikea_of_sweden_tradfri_control_outlet_switch"
),
},
("button", "00:11:22:33:44:55:66:77-1-3"): {
DEV_SIG_CHANNELS: ["identify"],
DEV_SIG_ENT_MAP_CLASS: "ZHAIdentifyButton",
DEV_SIG_ENT_MAP_ID: "button.ikea_of_sweden_tradfri_control_outlet_identify",
DEV_SIG_ENT_MAP_ID: (
"button.ikea_of_sweden_tradfri_control_outlet_identify"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-0-rssi"): {
DEV_SIG_CHANNELS: ["basic"],
@ -1355,12 +1425,16 @@ DEVICES = [
("button", "00:11:22:33:44:55:66:77-1-3"): {
DEV_SIG_CHANNELS: ["identify"],
DEV_SIG_ENT_MAP_CLASS: "ZHAIdentifyButton",
DEV_SIG_ENT_MAP_ID: "button.ikea_of_sweden_tradfri_motion_sensor_identify",
DEV_SIG_ENT_MAP_ID: (
"button.ikea_of_sweden_tradfri_motion_sensor_identify"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-1"): {
DEV_SIG_CHANNELS: ["power"],
DEV_SIG_ENT_MAP_CLASS: "Battery",
DEV_SIG_ENT_MAP_ID: "sensor.ikea_of_sweden_tradfri_motion_sensor_battery",
DEV_SIG_ENT_MAP_ID: (
"sensor.ikea_of_sweden_tradfri_motion_sensor_battery"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-0-rssi"): {
DEV_SIG_CHANNELS: ["basic"],
@ -1375,7 +1449,9 @@ DEVICES = [
("binary_sensor", "00:11:22:33:44:55:66:77-1-6"): {
DEV_SIG_CHANNELS: ["on_off"],
DEV_SIG_ENT_MAP_CLASS: "Motion",
DEV_SIG_ENT_MAP_ID: "binary_sensor.ikea_of_sweden_tradfri_motion_sensor_motion",
DEV_SIG_ENT_MAP_ID: (
"binary_sensor.ikea_of_sweden_tradfri_motion_sensor_motion"
),
},
},
},
@ -1404,12 +1480,16 @@ DEVICES = [
("button", "00:11:22:33:44:55:66:77-1-3"): {
DEV_SIG_CHANNELS: ["identify"],
DEV_SIG_ENT_MAP_CLASS: "ZHAIdentifyButton",
DEV_SIG_ENT_MAP_ID: "button.ikea_of_sweden_tradfri_on_off_switch_identify",
DEV_SIG_ENT_MAP_ID: (
"button.ikea_of_sweden_tradfri_on_off_switch_identify"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-1"): {
DEV_SIG_CHANNELS: ["power"],
DEV_SIG_ENT_MAP_CLASS: "Battery",
DEV_SIG_ENT_MAP_ID: "sensor.ikea_of_sweden_tradfri_on_off_switch_battery",
DEV_SIG_ENT_MAP_ID: (
"sensor.ikea_of_sweden_tradfri_on_off_switch_battery"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-0-rssi"): {
DEV_SIG_CHANNELS: ["basic"],
@ -1448,12 +1528,16 @@ DEVICES = [
("button", "00:11:22:33:44:55:66:77-1-3"): {
DEV_SIG_CHANNELS: ["identify"],
DEV_SIG_ENT_MAP_CLASS: "ZHAIdentifyButton",
DEV_SIG_ENT_MAP_ID: "button.ikea_of_sweden_tradfri_remote_control_identify",
DEV_SIG_ENT_MAP_ID: (
"button.ikea_of_sweden_tradfri_remote_control_identify"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-1"): {
DEV_SIG_CHANNELS: ["power"],
DEV_SIG_ENT_MAP_CLASS: "Battery",
DEV_SIG_ENT_MAP_ID: "sensor.ikea_of_sweden_tradfri_remote_control_battery",
DEV_SIG_ENT_MAP_ID: (
"sensor.ikea_of_sweden_tradfri_remote_control_battery"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-0-rssi"): {
DEV_SIG_CHANNELS: ["basic"],
@ -1498,12 +1582,16 @@ DEVICES = [
("button", "00:11:22:33:44:55:66:77-1-3"): {
DEV_SIG_CHANNELS: ["identify"],
DEV_SIG_ENT_MAP_CLASS: "ZHAIdentifyButton",
DEV_SIG_ENT_MAP_ID: "button.ikea_of_sweden_tradfri_signal_repeater_identify",
DEV_SIG_ENT_MAP_ID: (
"button.ikea_of_sweden_tradfri_signal_repeater_identify"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-0-rssi"): {
DEV_SIG_CHANNELS: ["basic"],
DEV_SIG_ENT_MAP_CLASS: "RSSISensor",
DEV_SIG_ENT_MAP_ID: "sensor.ikea_of_sweden_tradfri_signal_repeater_rssi",
DEV_SIG_ENT_MAP_ID: (
"sensor.ikea_of_sweden_tradfri_signal_repeater_rssi"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-0-lqi"): {
DEV_SIG_CHANNELS: ["basic"],
@ -1537,17 +1625,23 @@ DEVICES = [
("button", "00:11:22:33:44:55:66:77-1-3"): {
DEV_SIG_CHANNELS: ["identify"],
DEV_SIG_ENT_MAP_CLASS: "ZHAIdentifyButton",
DEV_SIG_ENT_MAP_ID: "button.ikea_of_sweden_tradfri_wireless_dimmer_identify",
DEV_SIG_ENT_MAP_ID: (
"button.ikea_of_sweden_tradfri_wireless_dimmer_identify"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-1"): {
DEV_SIG_CHANNELS: ["power"],
DEV_SIG_ENT_MAP_CLASS: "Battery",
DEV_SIG_ENT_MAP_ID: "sensor.ikea_of_sweden_tradfri_wireless_dimmer_battery",
DEV_SIG_ENT_MAP_ID: (
"sensor.ikea_of_sweden_tradfri_wireless_dimmer_battery"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-0-rssi"): {
DEV_SIG_CHANNELS: ["basic"],
DEV_SIG_ENT_MAP_CLASS: "RSSISensor",
DEV_SIG_ENT_MAP_ID: "sensor.ikea_of_sweden_tradfri_wireless_dimmer_rssi",
DEV_SIG_ENT_MAP_ID: (
"sensor.ikea_of_sweden_tradfri_wireless_dimmer_rssi"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-0-lqi"): {
DEV_SIG_CHANNELS: ["basic"],
@ -1962,7 +2056,9 @@ DEVICES = [
("button", "00:11:22:33:44:55:66:77-1-3"): {
DEV_SIG_CHANNELS: ["identify"],
DEV_SIG_ENT_MAP_CLASS: "ZHAIdentifyButton",
DEV_SIG_ENT_MAP_ID: "button.king_of_fans_inc_hbuniversalcfremote_identify",
DEV_SIG_ENT_MAP_ID: (
"button.king_of_fans_inc_hbuniversalcfremote_identify"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-0-rssi"): {
DEV_SIG_CHANNELS: ["basic"],
@ -3276,7 +3372,9 @@ DEVICES = [
("binary_sensor", "00:11:22:33:44:55:66:77-1-1030"): {
DEV_SIG_CHANNELS: ["occupancy"],
DEV_SIG_ENT_MAP_CLASS: "Occupancy",
DEV_SIG_ENT_MAP_ID: "binary_sensor.lumi_lumi_sensor_motion_aq2_occupancy",
DEV_SIG_ENT_MAP_ID: (
"binary_sensor.lumi_lumi_sensor_motion_aq2_occupancy"
),
},
("binary_sensor", "00:11:22:33:44:55:66:77-1-1280"): {
DEV_SIG_CHANNELS: ["ias_zone"],
@ -3512,7 +3610,9 @@ DEVICES = [
("sensor", "00:11:22:33:44:55:66:77-1-2"): {
DEV_SIG_CHANNELS: ["device_temperature"],
DEV_SIG_ENT_MAP_CLASS: "DeviceTemperature",
DEV_SIG_ENT_MAP_ID: "sensor.lumi_lumi_sensor_wleak_aq1_device_temperature",
DEV_SIG_ENT_MAP_ID: (
"sensor.lumi_lumi_sensor_wleak_aq1_device_temperature"
),
},
("button", "00:11:22:33:44:55:66:77-1-3"): {
DEV_SIG_CHANNELS: ["identify"],
@ -3977,32 +4077,44 @@ DEVICES = [
("sensor", "00:11:22:33:44:55:66:77-3-2820"): {
DEV_SIG_CHANNELS: ["electrical_measurement"],
DEV_SIG_ENT_MAP_CLASS: "ElectricalMeasurement",
DEV_SIG_ENT_MAP_ID: "sensor.osram_lightify_rt_tunable_white_active_power",
DEV_SIG_ENT_MAP_ID: (
"sensor.osram_lightify_rt_tunable_white_active_power"
),
},
("sensor", "00:11:22:33:44:55:66:77-3-2820-apparent_power"): {
DEV_SIG_CHANNELS: ["electrical_measurement"],
DEV_SIG_ENT_MAP_CLASS: "ElectricalMeasurementApparentPower",
DEV_SIG_ENT_MAP_ID: "sensor.osram_lightify_rt_tunable_white_apparent_power",
DEV_SIG_ENT_MAP_ID: (
"sensor.osram_lightify_rt_tunable_white_apparent_power"
),
},
("sensor", "00:11:22:33:44:55:66:77-3-2820-rms_current"): {
DEV_SIG_CHANNELS: ["electrical_measurement"],
DEV_SIG_ENT_MAP_CLASS: "ElectricalMeasurementRMSCurrent",
DEV_SIG_ENT_MAP_ID: "sensor.osram_lightify_rt_tunable_white_rms_current",
DEV_SIG_ENT_MAP_ID: (
"sensor.osram_lightify_rt_tunable_white_rms_current"
),
},
("sensor", "00:11:22:33:44:55:66:77-3-2820-rms_voltage"): {
DEV_SIG_CHANNELS: ["electrical_measurement"],
DEV_SIG_ENT_MAP_CLASS: "ElectricalMeasurementRMSVoltage",
DEV_SIG_ENT_MAP_ID: "sensor.osram_lightify_rt_tunable_white_rms_voltage",
DEV_SIG_ENT_MAP_ID: (
"sensor.osram_lightify_rt_tunable_white_rms_voltage"
),
},
("sensor", "00:11:22:33:44:55:66:77-3-2820-ac_frequency"): {
DEV_SIG_CHANNELS: ["electrical_measurement"],
DEV_SIG_ENT_MAP_CLASS: "ElectricalMeasurementFrequency",
DEV_SIG_ENT_MAP_ID: "sensor.osram_lightify_rt_tunable_white_ac_frequency",
DEV_SIG_ENT_MAP_ID: (
"sensor.osram_lightify_rt_tunable_white_ac_frequency"
),
},
("sensor", "00:11:22:33:44:55:66:77-3-2820-power_factor"): {
DEV_SIG_CHANNELS: ["electrical_measurement"],
DEV_SIG_ENT_MAP_CLASS: "ElectricalMeasurementPowerFactor",
DEV_SIG_ENT_MAP_ID: "sensor.osram_lightify_rt_tunable_white_power_factor",
DEV_SIG_ENT_MAP_ID: (
"sensor.osram_lightify_rt_tunable_white_power_factor"
),
},
("sensor", "00:11:22:33:44:55:66:77-3-0-rssi"): {
DEV_SIG_CHANNELS: ["basic"],
@ -4758,7 +4870,9 @@ DEVICES = [
("sensor", "00:11:22:33:44:55:66:77-1-2820-apparent_power"): {
DEV_SIG_CHANNELS: ["electrical_measurement"],
DEV_SIG_ENT_MAP_CLASS: "ElectricalMeasurementApparentPower",
DEV_SIG_ENT_MAP_ID: "sensor.sinope_technologies_rm3250zb_apparent_power",
DEV_SIG_ENT_MAP_ID: (
"sensor.sinope_technologies_rm3250zb_apparent_power"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-2820-rms_current"): {
DEV_SIG_CHANNELS: ["electrical_measurement"],
@ -4852,7 +4966,9 @@ DEVICES = [
("sensor", "00:11:22:33:44:55:66:77-1-2820-apparent_power"): {
DEV_SIG_CHANNELS: ["electrical_measurement"],
DEV_SIG_ENT_MAP_CLASS: "ElectricalMeasurementApparentPower",
DEV_SIG_ENT_MAP_ID: "sensor.sinope_technologies_th1123zb_apparent_power",
DEV_SIG_ENT_MAP_ID: (
"sensor.sinope_technologies_th1123zb_apparent_power"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-2820-rms_current"): {
DEV_SIG_CHANNELS: ["electrical_measurement"],
@ -4951,7 +5067,9 @@ DEVICES = [
("sensor", "00:11:22:33:44:55:66:77-1-2820-apparent_power"): {
DEV_SIG_CHANNELS: ["electrical_measurement"],
DEV_SIG_ENT_MAP_CLASS: "ElectricalMeasurementApparentPower",
DEV_SIG_ENT_MAP_ID: "sensor.sinope_technologies_th1124zb_apparent_power",
DEV_SIG_ENT_MAP_ID: (
"sensor.sinope_technologies_th1124zb_apparent_power"
),
},
("sensor", "00:11:22:33:44:55:66:77-1-2820-rms_current"): {
DEV_SIG_CHANNELS: ["electrical_measurement"],

View File

@ -337,8 +337,8 @@ async def test_unknown_zone(hass, calls, caplog):
)
assert (
"Automation 'My Automation' is referencing non-existing zone 'zone.no_such_zone' in a zone trigger"
not in caplog.text
"Automation 'My Automation' is referencing non-existing zone"
" 'zone.no_such_zone' in a zone trigger" not in caplog.text
)
hass.states.async_set(
@ -350,6 +350,6 @@ async def test_unknown_zone(hass, calls, caplog):
await hass.async_block_till_done()
assert (
"Automation 'My Automation' is referencing non-existing zone 'zone.no_such_zone' in a zone trigger"
in caplog.text
"Automation 'My Automation' is referencing non-existing zone"
" 'zone.no_such_zone' in a zone trigger" in caplog.text
)

View File

@ -507,7 +507,9 @@ def climate_radio_thermostat_ct101_multiple_temp_units_state_fixture():
@pytest.fixture(
name="climate_radio_thermostat_ct100_mode_and_setpoint_on_different_endpoints_state",
name=(
"climate_radio_thermostat_ct100_mode_and_setpoint_on_different_endpoints_state"
),
scope="session",
)
def climate_radio_thermostat_ct100_mode_and_setpoint_on_different_endpoints_state_fixture():

View File

@ -1064,8 +1064,10 @@ async def test_addon_running(
@pytest.mark.parametrize(
"discovery_info, discovery_info_side_effect, server_version_side_effect, "
"addon_info_side_effect, abort_reason",
(
"discovery_info, discovery_info_side_effect, server_version_side_effect, "
"addon_info_side_effect, abort_reason"
),
[
(
{"config": ADDON_DISCOVERY_INFO},
@ -1743,7 +1745,10 @@ async def test_options_not_addon(hass, client, supervisor, integration):
@pytest.mark.parametrize(
"discovery_info, entry_data, old_addon_options, new_addon_options, disconnect_calls",
(
"discovery_info, entry_data, old_addon_options, new_addon_options,"
" disconnect_calls"
),
[
(
{"config": ADDON_DISCOVERY_INFO},
@ -1984,7 +1989,10 @@ async def different_device_server_version(*args):
@pytest.mark.parametrize(
"discovery_info, entry_data, old_addon_options, new_addon_options, disconnect_calls, server_version_side_effect",
(
"discovery_info, entry_data, old_addon_options, new_addon_options,"
" disconnect_calls, server_version_side_effect"
),
[
(
{"config": ADDON_DISCOVERY_INFO},
@ -2132,7 +2140,10 @@ async def test_options_different_device(
@pytest.mark.parametrize(
"discovery_info, entry_data, old_addon_options, new_addon_options, disconnect_calls, restart_addon_side_effect",
(
"discovery_info, entry_data, old_addon_options, new_addon_options,"
" disconnect_calls, restart_addon_side_effect"
),
[
(
{"config": ADDON_DISCOVERY_INFO},
@ -2281,7 +2292,10 @@ async def test_options_addon_restart_failed(
@pytest.mark.parametrize(
"discovery_info, entry_data, old_addon_options, new_addon_options, disconnect_calls, server_version_side_effect",
(
"discovery_info, entry_data, old_addon_options, new_addon_options,"
" disconnect_calls, server_version_side_effect"
),
[
(
{"config": ADDON_DISCOVERY_INFO},
@ -2365,7 +2379,10 @@ async def test_options_addon_running_server_info_failure(
@pytest.mark.parametrize(
"discovery_info, entry_data, old_addon_options, new_addon_options, disconnect_calls",
(
"discovery_info, entry_data, old_addon_options, new_addon_options,"
" disconnect_calls"
),
[
(
{"config": ADDON_DISCOVERY_INFO},

View File

@ -116,7 +116,10 @@ async def test_node_status_state(
"action": {
"service": "test.automation",
"data_template": {
"some": "alive - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"alive - {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -134,7 +137,10 @@ async def test_node_status_state(
"action": {
"service": "test.automation",
"data_template": {
"some": "awake - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"awake - {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -152,7 +158,10 @@ async def test_node_status_state(
"action": {
"service": "test.automation",
"data_template": {
"some": "asleep - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"asleep - {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -170,7 +179,10 @@ async def test_node_status_state(
"action": {
"service": "test.automation",
"data_template": {
"some": "dead - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"dead - {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -267,7 +279,10 @@ async def test_config_parameter_state(
"action": {
"service": "test.automation",
"data_template": {
"some": "Beeper - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"Beeper - {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -287,7 +302,10 @@ async def test_config_parameter_state(
"action": {
"service": "test.automation",
"data_template": {
"some": "User Slot Status - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"User Slot Status - {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -377,7 +395,10 @@ async def test_value_state(
"action": {
"service": "test.automation",
"data_template": {
"some": "value - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"value - {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},

View File

@ -78,9 +78,9 @@ async def test_humanifying_zwave_js_notification_event(
assert events[1]["name"] == "Touchscreen Deadbolt"
assert events[1]["domain"] == "zwave_js"
assert (
events[1]["message"]
== "fired Entry Control CC 'notification' event for event type '1' with data type '2'"
assert events[1]["message"] == (
"fired Entry Control CC 'notification' event for event type '1' "
"with data type '2'"
)
assert events[2]["name"] == "Touchscreen Deadbolt"

View File

@ -67,9 +67,9 @@ async def test_unique_id_migration_dupes(
@pytest.mark.parametrize(
"id",
[
("52.52-49-00-Air temperature-00"),
("52.52-49-0-Air temperature-00-00"),
("52-49-0-Air temperature-00-00"),
"52.52-49-00-Air temperature-00",
"52.52-49-0-Air temperature-00-00",
"52-49-0-Air temperature-00-00",
],
)
async def test_unique_id_migration(hass, multisensor_6_state, client, integration, id):
@ -109,9 +109,9 @@ async def test_unique_id_migration(hass, multisensor_6_state, client, integratio
@pytest.mark.parametrize(
"id",
[
("32.32-50-00-value-W_Consumed"),
("32.32-50-0-value-66049-W_Consumed"),
("32-50-0-value-66049-W_Consumed"),
"32.32-50-00-value-W_Consumed",
"32.32-50-0-value-66049-W_Consumed",
"32-50-0-value-66049-W_Consumed",
],
)
async def test_unique_id_migration_property_key(
@ -159,7 +159,10 @@ async def test_unique_id_migration_notification_binary_sensor(
entity_name = NOTIFICATION_MOTION_BINARY_SENSOR.split(".")[1]
# Create entity RegistryEntry using old unique ID format
old_unique_id = f"{client.driver.controller.home_id}.52.52-113-00-Home Security-Motion sensor status.8"
old_unique_id = (
f"{client.driver.controller.home_id}.52.52-113-00-Home Security-Motion sensor"
" status.8"
)
entity_entry = ent_reg.async_get_or_create(
"binary_sensor",
DOMAIN,
@ -180,7 +183,10 @@ async def test_unique_id_migration_notification_binary_sensor(
# Check that new RegistryEntry is using new unique ID format
entity_entry = ent_reg.async_get(NOTIFICATION_MOTION_BINARY_SENSOR)
new_unique_id = f"{client.driver.controller.home_id}.52-113-0-Home Security-Motion sensor status.8"
new_unique_id = (
f"{client.driver.controller.home_id}.52-113-0-Home Security-Motion sensor"
" status.8"
)
assert entity_entry.unique_id == new_unique_id
assert ent_reg.async_get_entity_id("binary_sensor", DOMAIN, old_unique_id) is None

View File

@ -1296,7 +1296,9 @@ async def test_multicast_set_value_options(
],
ATTR_COMMAND_CLASS: 51,
ATTR_PROPERTY: "targetColor",
ATTR_VALUE: '{ "warmWhite": 0, "coldWhite": 0, "red": 255, "green": 0, "blue": 0 }',
ATTR_VALUE: (
'{ "warmWhite": 0, "coldWhite": 0, "red": 255, "green": 0, "blue": 0 }'
),
ATTR_OPTIONS: {"transitionDuration": 1},
},
blocking=True,

View File

@ -182,9 +182,9 @@ async def test_warning_close_session_custom(hass, caplog):
session = client.async_get_clientsession(hass)
await session.close()
assert (
"Detected integration that closes the Home Assistant aiohttp session. "
"Please report issue to the custom integration author for hue using this method at "
"custom_components/hue/light.py, line 23: await session.close()" in caplog.text
"Detected integration that closes the Home Assistant aiohttp session. Please"
" report issue to the custom integration author for hue using this method at"
" custom_components/hue/light.py, line 23: await session.close()" in caplog.text
)

View File

@ -97,7 +97,10 @@ async def test_component_requirement_not_found(hass):
assert res.keys() == {"homeassistant"}
assert res.errors[0] == CheckConfigError(
"Integration error: test_custom_component - Requirements for test_custom_component not found: ['any'].",
(
"Integration error: test_custom_component - Requirements for"
" test_custom_component not found: ['any']."
),
None,
None,
)
@ -157,9 +160,7 @@ async def test_platform_not_found_safe_mode(hass):
async def test_package_invalid(hass):
"""Test a valid platform setup."""
files = {
YAML_CONFIG_FILE: BASE_CONFIG + (" packages:\n p1:\n" ' group: ["a"]')
}
files = {YAML_CONFIG_FILE: BASE_CONFIG + ' packages:\n p1:\n group: ["a"]'}
with patch("os.path.isfile", return_value=True), patch_yaml_files(files):
res = await async_check_ha_config_file(hass)
log_ha_config(res)

View File

@ -1146,7 +1146,9 @@ async def test_state_unknown_attribute(hass):
{
"result": {
"result": False,
"message": "attribute 'model' of entity sensor.door does not exist",
"message": (
"attribute 'model' of entity sensor.door does not exist"
),
}
}
],
@ -1428,7 +1430,9 @@ async def test_numeric_state_known_non_matching(hass):
{
"result": {
"result": False,
"message": "value 'unavailable' is non-numeric and treated as False",
"message": (
"value 'unavailable' is non-numeric and treated as False"
),
}
}
],
@ -1446,7 +1450,9 @@ async def test_numeric_state_known_non_matching(hass):
{
"result": {
"result": False,
"message": "value 'unknown' is non-numeric and treated as False",
"message": (
"value 'unknown' is non-numeric and treated as False"
),
}
}
],
@ -1566,7 +1572,10 @@ async def test_numeric_state_unknown_attribute(hass):
{
"result": {
"result": False,
"message": "attribute 'temperature' of entity sensor.temperature does not exist",
"message": (
"attribute 'temperature' of entity sensor.temperature does"
" not exist"
),
}
}
],

View File

@ -152,7 +152,8 @@ async def test_warning_close_session_custom(hass, caplog):
httpx_session = client.get_async_client(hass)
await httpx_session.aclose()
assert (
"Detected integration that closes the Home Assistant httpx client. "
"Please report issue to the custom integration author for hue using this method at "
"custom_components/hue/light.py, line 23: await session.aclose()" in caplog.text
"Detected integration that closes the Home Assistant httpx client. Please"
" report issue to the custom integration author for hue using this method at"
" custom_components/hue/light.py, line 23: await session.aclose()"
in caplog.text
)

View File

@ -3049,8 +3049,8 @@ async def test_parallel(hass: HomeAssistant, caplog: pytest.LogCaptureFixture) -
assert events[1].data["what"] == "world"
assert (
"Test Name: Parallel action at step 1: Sequential group: Executing step Waiting for trigger"
in caplog.text
"Test Name: Parallel action at step 1: Sequential group: Executing step Waiting"
" for trigger" in caplog.text
)
assert (
"Parallel action at step 1: parallel 2: Executing step Don't wait at all"
@ -3659,7 +3659,10 @@ async def test_referenced_devices(hass):
{
"choose": [
{
"conditions": "{{ is_device_attr('choice-2-cond-dev-id', 'model', 'blah') }}",
"conditions": (
"{{ is_device_attr('choice-2-cond-dev-id', 'model',"
" 'blah') }}"
),
"sequence": [
{
"service": "test.script",
@ -4427,7 +4430,9 @@ async def test_embedded_wait_for_trigger_in_automation(hass):
"while": [
{
"condition": "template",
"value_template": '{{ is_state("test.value1", "trigger-while") }}',
"value_template": (
'{{ is_state("test.value1", "trigger-while") }}'
),
}
],
"sequence": [
@ -4436,7 +4441,10 @@ async def test_embedded_wait_for_trigger_in_automation(hass):
"wait_for_trigger": [
{
"platform": "template",
"value_template": '{{ is_state("test.value2", "trigger-wait") }}',
"value_template": (
'{{ is_state("test.value2",'
' "trigger-wait") }}'
),
}
]
},

View File

@ -1159,8 +1159,8 @@ async def test_entity_service_call_warn_referenced(hass, caplog):
)
await service.entity_service_call(hass, {}, "", call)
assert (
"Unable to find referenced areas non-existent-area, devices non-existent-device, entities non.existent"
in caplog.text
"Unable to find referenced areas non-existent-area, devices"
" non-existent-device, entities non.existent" in caplog.text
)
@ -1178,8 +1178,8 @@ async def test_async_extract_entities_warn_referenced(hass, caplog):
extracted = await service.async_extract_entities(hass, {}, call)
assert len(extracted) == 0
assert (
"Unable to find referenced areas non-existent-area, devices non-existent-device, entities non.existent"
in caplog.text
"Unable to find referenced areas non-existent-area, devices"
" non-existent-device, entities non.existent" in caplog.text
)

View File

@ -200,7 +200,14 @@ def test_iterating_all_states_unavailable(hass: HomeAssistant) -> None:
"""Test iterating all states unavailable."""
hass.states.async_set("test.object", "on")
tmpl_str = "{{ states | selectattr('state', 'in', ['unavailable', 'unknown', 'none']) | list | count }}"
tmpl_str = (
"{{"
" states"
" | selectattr('state', 'in', ['unavailable', 'unknown', 'none'])"
" | list"
" | count"
"}}"
)
info = render_to_info(hass, tmpl_str)
@ -1604,13 +1611,31 @@ def test_relative_time(mock_is_safe, hass):
assert result == "1 hour"
result = template.Template(
'{{relative_time(strptime("2000-01-01 09:00:00 +01:00", "%Y-%m-%d %H:%M:%S %z"))}}',
(
"{{"
" relative_time("
" strptime("
' "2000-01-01 09:00:00 +01:00",'
' "%Y-%m-%d %H:%M:%S %z"'
" )"
" )"
"}}"
),
hass,
).async_render()
assert result == "2 hours"
result = template.Template(
'{{relative_time(strptime("2000-01-01 03:00:00 -06:00", "%Y-%m-%d %H:%M:%S %z"))}}',
(
"{{"
" relative_time("
" strptime("
' "2000-01-01 03:00:00 -06:00",'
' "%Y-%m-%d %H:%M:%S %z"'
" )"
" )"
"}}"
),
hass,
).async_render()
assert result == "1 hour"
@ -1619,7 +1644,16 @@ def test_relative_time(mock_is_safe, hass):
template.strptime("2000-01-01 11:00:00 +00:00", "%Y-%m-%d %H:%M:%S %z")
)
result2 = template.Template(
'{{relative_time(strptime("2000-01-01 11:00:00 +00:00", "%Y-%m-%d %H:%M:%S %z"))}}',
(
"{{"
" relative_time("
" strptime("
' "2000-01-01 11:00:00 +00:00",'
' "%Y-%m-%d %H:%M:%S %z"'
" )"
" )"
"}}"
),
hass,
).async_render()
assert result1 == result2
@ -1959,8 +1993,9 @@ def test_pack(hass, caplog):
# "Template warning: 'pack' unable to pack object with type '%s' and format_string '%s' see https://docs.python.org/3/library/struct.html for more information"
assert tpl.async_render(variables=variables) is None
assert (
"Template warning: 'pack' unable to pack object 'None' with type 'NoneType' and format_string '>I' see https://docs.python.org/3/library/struct.html for more information"
in caplog.text
"Template warning: 'pack' unable to pack object 'None' with type 'NoneType' and"
" format_string '>I' see https://docs.python.org/3/library/struct.html for more"
" information" in caplog.text
)
# test with invalid filter
@ -1976,7 +2011,9 @@ def test_pack(hass, caplog):
# "Template warning: 'pack' unable to pack object with type '%s' and format_string '%s' see https://docs.python.org/3/library/struct.html for more information"
assert tpl.async_render(variables=variables) is None
assert (
"Template warning: 'pack' unable to pack object '3735928559' with type 'int' and format_string 'invalid filter' see https://docs.python.org/3/library/struct.html for more information"
"Template warning: 'pack' unable to pack object '3735928559' with type 'int'"
" and format_string 'invalid filter' see"
" https://docs.python.org/3/library/struct.html for more information"
in caplog.text
)
@ -2032,8 +2069,9 @@ def test_unpack(hass, caplog):
}
assert tpl.async_render(variables=variables) is None
assert (
"Template warning: 'unpack' unable to unpack object 'b''' with format_string '>I' and offset 0 see https://docs.python.org/3/library/struct.html for more information"
in caplog.text
"Template warning: 'unpack' unable to unpack object 'b''' with format_string"
" '>I' and offset 0 see https://docs.python.org/3/library/struct.html for more"
" information" in caplog.text
)
# test with invalid filter
@ -2048,7 +2086,9 @@ def test_unpack(hass, caplog):
}
assert tpl.async_render(variables=variables) is None
assert (
"Template warning: 'unpack' unable to unpack object 'b''' with format_string 'invalid filter' and offset 0 see https://docs.python.org/3/library/struct.html for more information"
"Template warning: 'unpack' unable to unpack object 'b''' with format_string"
" 'invalid filter' and offset 0 see"
" https://docs.python.org/3/library/struct.html for more information"
in caplog.text
)
@ -2109,13 +2149,13 @@ def test_distance_function_with_1_state_1_coord(hass: HomeAssistant) -> None:
{"latitude": hass.config.latitude, "longitude": hass.config.longitude},
)
tpl = template.Template(
'{{ distance("32.87336", "-117.22943", states.test.object_2) ' "| round }}",
'{{ distance("32.87336", "-117.22943", states.test.object_2) | round }}',
hass,
)
assert tpl.async_render() == 187
tpl2 = template.Template(
'{{ distance(states.test.object_2, "32.87336", "-117.22943") ' "| round }}",
'{{ distance(states.test.object_2, "32.87336", "-117.22943") | round }}',
hass,
)
assert tpl2.async_render() == 187
@ -2349,15 +2389,19 @@ async def test_expand(hass: HomeAssistant) -> None:
info = render_to_info(
hass,
"{{ expand('group.new_group', 'test.object')"
" | map(attribute='entity_id') | join(', ') }}",
(
"{{ expand('group.new_group', 'test.object')"
" | map(attribute='entity_id') | join(', ') }}"
),
)
assert_result_info(info, "test.object", {"test.object", "group.new_group"})
info = render_to_info(
hass,
"{{ ['group.new_group', 'test.object'] | expand"
" | map(attribute='entity_id') | join(', ') }}",
(
"{{ ['group.new_group', 'test.object'] | expand"
" | map(attribute='entity_id') | join(', ') }}"
),
)
assert_result_info(info, "test.object", {"test.object", "group.new_group"})
assert info.rate_limit is None
@ -2374,7 +2418,10 @@ async def test_expand(hass: HomeAssistant) -> None:
info = render_to_info(
hass,
"{{ states.group.power_sensors.attributes.entity_id | expand | map(attribute='state')|map('float')|sum }}",
(
"{{ states.group.power_sensors.attributes.entity_id | expand "
"| map(attribute='state')|map('float')|sum }}"
),
)
assert_result_info(
info,
@ -2499,7 +2546,10 @@ async def test_device_entities(hass: HomeAssistant) -> None:
assert info.rate_limit is None
info = render_to_info(
hass,
f"{{{{ device_entities('{device_entry.id}') | expand | map(attribute='entity_id') | join(', ') }}}}",
(
f"{{{{ device_entities('{device_entry.id}') | expand "
"| map(attribute='entity_id') | join(', ') }}"
),
)
assert_result_info(info, "", ["light.hue_5678"])
assert info.rate_limit is None
@ -2508,7 +2558,10 @@ async def test_device_entities(hass: HomeAssistant) -> None:
hass.states.async_set("light.hue_5678", "happy")
info = render_to_info(
hass,
f"{{{{ device_entities('{device_entry.id}') | expand | map(attribute='entity_id') | join(', ') }}}}",
(
f"{{{{ device_entities('{device_entry.id}') | expand "
"| map(attribute='entity_id') | join(', ') }}"
),
)
assert_result_info(info, "light.hue_5678", ["light.hue_5678"])
assert info.rate_limit is None
@ -2527,7 +2580,10 @@ async def test_device_entities(hass: HomeAssistant) -> None:
assert info.rate_limit is None
info = render_to_info(
hass,
f"{{{{ device_entities('{device_entry.id}') | expand | map(attribute='entity_id') | join(', ') }}}}",
(
f"{{{{ device_entities('{device_entry.id}') | expand "
"| map(attribute='entity_id') | join(', ') }}"
),
)
assert_result_info(
info, "light.hue_5678, light.hue_abcd", ["light.hue_5678", "light.hue_abcd"]
@ -2756,7 +2812,10 @@ async def test_device_attr(hass: HomeAssistant) -> None:
# Test test syntax (is_device_attr)
info = render_to_info(
hass,
f"{{{{ ['{device_entry.id}'] | select('is_device_attr', 'model', 'test') | list }}}}",
(
f"{{{{ ['{device_entry.id}'] | select('is_device_attr', 'model', 'test') "
"| list }}"
),
)
assert_result_info(info, [device_entry.id])
assert info.rate_limit is None
@ -3309,8 +3368,10 @@ def test_closest_function_to_entity_id(hass: HomeAssistant) -> None:
info = render_to_info(
hass,
"{{ ([states.test_domain, 'test_domain.closest_zone'] "
"| closest(zone)).entity_id }}",
(
"{{ ([states.test_domain, 'test_domain.closest_zone'] "
"| closest(zone)).entity_id }}"
),
{"zone": "zone.far_away"},
)
@ -3608,12 +3669,12 @@ def test_render_complex_handling_non_template_values(hass: HomeAssistant) -> Non
def test_urlencode(hass: HomeAssistant) -> None:
"""Test the urlencode method."""
tpl = template.Template(
("{% set dict = {'foo': 'x&y', 'bar': 42} %}{{ dict | urlencode }}"),
"{% set dict = {'foo': 'x&y', 'bar': 42} %}{{ dict | urlencode }}",
hass,
)
assert tpl.async_render() == "foo=x%26y&bar=42"
tpl = template.Template(
("{% set string = 'the quick brown fox = true' %}{{ string | urlencode }}"),
"{% set string = 'the quick brown fox = true' %}{{ string | urlencode }}",
hass,
)
assert tpl.async_render() == "the%20quick%20brown%20fox%20%3D%20true"
@ -3758,7 +3819,11 @@ async def test_slice_states(hass: HomeAssistant) -> None:
hass.states.async_set("sensor.test", "23")
tpl = template.Template(
"{% for states in states | slice(1) -%}{% set state = states | first %}{{ state.entity_id }}{%- endfor %}",
(
"{% for states in states | slice(1) -%}{% set state = states | first %}"
"{{ state.entity_id }}"
"{%- endfor %}"
),
hass,
)
assert tpl.async_render() == "sensor.test"
@ -3937,13 +4002,21 @@ async def test_unavailable_states(hass: HomeAssistant) -> None:
hass.states.async_set("light.none", "none")
tpl = template.Template(
"{{ states | selectattr('state', 'in', ['unavailable','unknown','none']) | map(attribute='entity_id') | list | join(', ') }}",
(
"{{ states | selectattr('state', 'in', ['unavailable','unknown','none']) "
"| map(attribute='entity_id') | list | join(', ') }}"
),
hass,
)
assert tpl.async_render() == "light.none, light.unavailable, light.unknown"
tpl = template.Template(
"{{ states.light | selectattr('state', 'in', ['unavailable','unknown','none']) | map(attribute='entity_id') | list | join(', ') }}",
(
"{{ states.light "
"| selectattr('state', 'in', ['unavailable','unknown','none']) "
"| map(attribute='entity_id') | list "
"| join(', ') }}"
),
hass,
)
assert tpl.async_render() == "light.none, light.unavailable, light.unknown"
@ -4049,8 +4122,8 @@ async def test_undefined_variable(hass, caplog):
tpl = template.Template("{{ no_such_variable }}", hass)
assert tpl.async_render() == ""
assert (
"Template variable warning: 'no_such_variable' is undefined when rendering '{{ no_such_variable }}'"
in caplog.text
"Template variable warning: 'no_such_variable' is undefined when rendering "
"'{{ no_such_variable }}'" in caplog.text
)

View File

@ -270,9 +270,9 @@ async def test_translation_merging(hass, caplog):
assert "component.sensor.state.moon__phase.first_quarter" in translations
assert (
"An integration providing translations for sensor provided invalid data: bad data"
in caplog.text
)
"An integration providing translations for sensor provided invalid data:"
" bad data"
) in caplog.text
async def test_translation_merging_loaded_apart(hass, caplog):

View File

@ -102,8 +102,8 @@ def test_secrets(mock_is_file, event_loop):
files = {
get_test_config_dir(YAML_CONFIG_FILE): BASE_CONFIG
+ ("http:\n cors_allowed_origins: !secret http_pw"),
secrets_path: ("logger: debug\nhttp_pw: http://google.com"),
+ "http:\n cors_allowed_origins: !secret http_pw",
secrets_path: "logger: debug\nhttp_pw: http://google.com",
}
with patch_yaml_files(files):
@ -129,9 +129,7 @@ def test_secrets(mock_is_file, event_loop):
def test_package_invalid(mock_is_file, event_loop):
"""Test an invalid package."""
files = {
YAML_CONFIG_FILE: BASE_CONFIG + (" packages:\n p1:\n" ' group: ["a"]')
}
files = {YAML_CONFIG_FILE: BASE_CONFIG + ' packages:\n p1:\n group: ["a"]'}
with patch_yaml_files(files):
res = check_config.check(get_test_config_dir())

View File

@ -167,11 +167,11 @@ async def test_check_loop_async_custom(caplog):
):
hasync.check_loop(banned_function)
assert (
"Detected blocking call to banned_function inside the event loop. This is "
"causing stability issues. Please report issue to the custom integration author "
"for hue doing blocking calls at custom_components/hue/light.py, line 23: "
"self.light.is_on" in caplog.text
)
"Detected blocking call to banned_function inside the event loop. This is"
" causing stability issues. Please report issue to the custom integration"
" author for hue doing blocking calls at custom_components/hue/light.py, line"
" 23: self.light.is_on"
) in caplog.text
def test_check_loop_sync(caplog):

View File

@ -336,20 +336,24 @@ class TestSecrets(unittest.TestCase):
load_yaml(
self._secret_path,
"http_pw: pwhttp\n"
"comp1_un: un1\n"
"comp1_pw: pw1\n"
"stale_pw: not_used\n"
"logger: debug\n",
(
"http_pw: pwhttp\n"
"comp1_un: un1\n"
"comp1_pw: pw1\n"
"stale_pw: not_used\n"
"logger: debug\n"
),
)
self._yaml = load_yaml(
self._yaml_path,
"http:\n"
" api_password: !secret http_pw\n"
"component:\n"
" username: !secret comp1_un\n"
" password: !secret comp1_pw\n"
"",
(
"http:\n"
" api_password: !secret http_pw\n"
"component:\n"
" username: !secret comp1_un\n"
" password: !secret comp1_pw\n"
""
),
yaml_loader.Secrets(config_dir),
)
@ -370,12 +374,14 @@ class TestSecrets(unittest.TestCase):
expected = {"api_password": "pwhttp"}
self._yaml = load_yaml(
os.path.join(self._sub_folder_path, "sub.yaml"),
"http:\n"
" api_password: !secret http_pw\n"
"component:\n"
" username: !secret comp1_un\n"
" password: !secret comp1_pw\n"
"",
(
"http:\n"
" api_password: !secret http_pw\n"
"component:\n"
" username: !secret comp1_un\n"
" password: !secret comp1_pw\n"
""
),
yaml_loader.Secrets(get_test_config_dir()),
)
@ -389,12 +395,14 @@ class TestSecrets(unittest.TestCase):
)
self._yaml = load_yaml(
os.path.join(self._sub_folder_path, "sub.yaml"),
"http:\n"
" api_password: !secret http_pw\n"
"component:\n"
" username: !secret comp1_un\n"
" password: !secret comp1_pw\n"
"",
(
"http:\n"
" api_password: !secret http_pw\n"
"component:\n"
" username: !secret comp1_un\n"
" password: !secret comp1_pw\n"
""
),
yaml_loader.Secrets(get_test_config_dir()),
)
@ -433,12 +441,14 @@ class TestSecrets(unittest.TestCase):
with pytest.raises(HomeAssistantError):
load_yaml(
self._yaml_path,
"http:\n"
" api_password: !secret http_pw\n"
"component:\n"
" username: !secret comp1_un\n"
" password: !secret comp1_pw\n"
"",
(
"http:\n"
" api_password: !secret http_pw\n"
"component:\n"
" username: !secret comp1_un\n"
" password: !secret comp1_pw\n"
""
),
)