Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/airos/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"documentation": "https://www.home-assistant.io/integrations/airos",
"iot_class": "local_polling",
"quality_scale": "bronze",
"requirements": ["airos==0.2.6"]
"requirements": ["airos==0.2.7"]
}
9 changes: 9 additions & 0 deletions homeassistant/components/airos/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class AirOSSensorEntityDescription(SensorEntityDescription):
translation_key="host_cpuload",
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=1,
value_fn=lambda data: data.host.cpuload,
entity_registry_enabled_default=False,
),
Expand Down Expand Up @@ -83,6 +84,8 @@ class AirOSSensorEntityDescription(SensorEntityDescription):
native_unit_of_measurement=UnitOfDataRate.KILOBITS_PER_SECOND,
device_class=SensorDeviceClass.DATA_RATE,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=0,
suggested_unit_of_measurement=UnitOfDataRate.MEGABITS_PER_SECOND,
value_fn=lambda data: data.wireless.throughput.tx,
),
AirOSSensorEntityDescription(
Expand All @@ -91,6 +94,8 @@ class AirOSSensorEntityDescription(SensorEntityDescription):
native_unit_of_measurement=UnitOfDataRate.KILOBITS_PER_SECOND,
device_class=SensorDeviceClass.DATA_RATE,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=0,
suggested_unit_of_measurement=UnitOfDataRate.MEGABITS_PER_SECOND,
value_fn=lambda data: data.wireless.throughput.rx,
),
AirOSSensorEntityDescription(
Expand All @@ -99,6 +104,8 @@ class AirOSSensorEntityDescription(SensorEntityDescription):
native_unit_of_measurement=UnitOfDataRate.KILOBITS_PER_SECOND,
device_class=SensorDeviceClass.DATA_RATE,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=0,
suggested_unit_of_measurement=UnitOfDataRate.MEGABITS_PER_SECOND,
value_fn=lambda data: data.wireless.polling.dl_capacity,
),
AirOSSensorEntityDescription(
Expand All @@ -107,6 +114,8 @@ class AirOSSensorEntityDescription(SensorEntityDescription):
native_unit_of_measurement=UnitOfDataRate.KILOBITS_PER_SECOND,
device_class=SensorDeviceClass.DATA_RATE,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=0,
suggested_unit_of_measurement=UnitOfDataRate.MEGABITS_PER_SECOND,
value_fn=lambda data: data.wireless.polling.ul_capacity,
),
)
Expand Down
4 changes: 4 additions & 0 deletions homeassistant/components/playstation_network/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,17 @@ async def async_step_user(
}
)

if not self.friends_list:
return self.async_abort(reason="no_friends")

options = [
SelectOptionDict(
value=friend.account_id,
label=friend.online_id,
)
for friend in self.friends_list.values()
]

return self.async_show_form(
step_id="user",
data_schema=self.add_suggested_values_to_schema(
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/playstation_network/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
},
"abort": {
"already_configured_as_entry": "Already configured as a service. This account cannot be added as a friend.",
"already_configured": "Already configured as a friend in this or another account."
"already_configured": "Already configured as a friend in this or another account.",
"no_friends": "Looks like your friend list is empty right now. Add friends on PlayStation Network first."
}
}
},
Expand Down
5 changes: 5 additions & 0 deletions homeassistant/components/volvo/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,34 +114,39 @@ def _charging_power_status_value(field: VolvoCarsValue) -> str | None:
api_field="averageEnergyConsumption",
native_unit_of_measurement=UnitOfEnergyDistance.KILO_WATT_HOUR_PER_100_KM,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=1,
),
# statistics endpoint
VolvoSensorDescription(
key="average_energy_consumption_automatic",
api_field="averageEnergyConsumptionAutomatic",
native_unit_of_measurement=UnitOfEnergyDistance.KILO_WATT_HOUR_PER_100_KM,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=1,
),
# statistics endpoint
VolvoSensorDescription(
key="average_energy_consumption_charge",
api_field="averageEnergyConsumptionSinceCharge",
native_unit_of_measurement=UnitOfEnergyDistance.KILO_WATT_HOUR_PER_100_KM,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=1,
),
# statistics endpoint
VolvoSensorDescription(
key="average_fuel_consumption",
api_field="averageFuelConsumption",
native_unit_of_measurement="L/100 km",
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=1,
),
# statistics endpoint
VolvoSensorDescription(
key="average_fuel_consumption_automatic",
api_field="averageFuelConsumptionAutomatic",
native_unit_of_measurement="L/100 km",
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=1,
),
# statistics endpoint
VolvoSensorDescription(
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion requirements_test_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 27 additions & 12 deletions tests/components/airos/snapshots/test_sensor.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
}),
'name': None,
'options': dict({
'sensor': dict({
'suggested_display_precision': 1,
}),
}),
'original_device_class': None,
'original_icon': None,
Expand Down Expand Up @@ -131,6 +134,9 @@
'sensor': dict({
'suggested_display_precision': 0,
}),
'sensor.private': dict({
'suggested_unit_of_measurement': <UnitOfDataRate.MEGABITS_PER_SECOND: 'Mbit/s'>,
}),
}),
'original_device_class': <SensorDeviceClass.DATA_RATE: 'data_rate'>,
'original_icon': None,
Expand All @@ -141,7 +147,7 @@
'supported_features': 0,
'translation_key': 'wireless_polling_dl_capacity',
'unique_id': '01:23:45:67:89:AB_wireless_polling_dl_capacity',
'unit_of_measurement': <UnitOfDataRate.KILOBITS_PER_SECOND: 'kbit/s'>,
'unit_of_measurement': <UnitOfDataRate.MEGABITS_PER_SECOND: 'Mbit/s'>,
})
# ---
# name: test_all_entities[sensor.nanostation_5ac_ap_name_download_capacity-state]
Expand All @@ -150,14 +156,14 @@
'device_class': 'data_rate',
'friendly_name': 'NanoStation 5AC ap name Download capacity',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': <UnitOfDataRate.KILOBITS_PER_SECOND: 'kbit/s'>,
'unit_of_measurement': <UnitOfDataRate.MEGABITS_PER_SECOND: 'Mbit/s'>,
}),
'context': <ANY>,
'entity_id': 'sensor.nanostation_5ac_ap_name_download_capacity',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '647400',
'state': '647.4',
})
# ---
# name: test_all_entities[sensor.nanostation_5ac_ap_name_network_role-entry]
Expand Down Expand Up @@ -245,6 +251,9 @@
'sensor': dict({
'suggested_display_precision': 0,
}),
'sensor.private': dict({
'suggested_unit_of_measurement': <UnitOfDataRate.MEGABITS_PER_SECOND: 'Mbit/s'>,
}),
}),
'original_device_class': <SensorDeviceClass.DATA_RATE: 'data_rate'>,
'original_icon': None,
Expand All @@ -255,7 +264,7 @@
'supported_features': 0,
'translation_key': 'wireless_throughput_rx',
'unique_id': '01:23:45:67:89:AB_wireless_throughput_rx',
'unit_of_measurement': <UnitOfDataRate.KILOBITS_PER_SECOND: 'kbit/s'>,
'unit_of_measurement': <UnitOfDataRate.MEGABITS_PER_SECOND: 'Mbit/s'>,
})
# ---
# name: test_all_entities[sensor.nanostation_5ac_ap_name_throughput_receive_actual-state]
Expand All @@ -264,14 +273,14 @@
'device_class': 'data_rate',
'friendly_name': 'NanoStation 5AC ap name Throughput receive (actual)',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': <UnitOfDataRate.KILOBITS_PER_SECOND: 'kbit/s'>,
'unit_of_measurement': <UnitOfDataRate.MEGABITS_PER_SECOND: 'Mbit/s'>,
}),
'context': <ANY>,
'entity_id': 'sensor.nanostation_5ac_ap_name_throughput_receive_actual',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '9907',
'state': '9.907',
})
# ---
# name: test_all_entities[sensor.nanostation_5ac_ap_name_throughput_transmit_actual-entry]
Expand Down Expand Up @@ -301,6 +310,9 @@
'sensor': dict({
'suggested_display_precision': 0,
}),
'sensor.private': dict({
'suggested_unit_of_measurement': <UnitOfDataRate.MEGABITS_PER_SECOND: 'Mbit/s'>,
}),
}),
'original_device_class': <SensorDeviceClass.DATA_RATE: 'data_rate'>,
'original_icon': None,
Expand All @@ -311,7 +323,7 @@
'supported_features': 0,
'translation_key': 'wireless_throughput_tx',
'unique_id': '01:23:45:67:89:AB_wireless_throughput_tx',
'unit_of_measurement': <UnitOfDataRate.KILOBITS_PER_SECOND: 'kbit/s'>,
'unit_of_measurement': <UnitOfDataRate.MEGABITS_PER_SECOND: 'Mbit/s'>,
})
# ---
# name: test_all_entities[sensor.nanostation_5ac_ap_name_throughput_transmit_actual-state]
Expand All @@ -320,14 +332,14 @@
'device_class': 'data_rate',
'friendly_name': 'NanoStation 5AC ap name Throughput transmit (actual)',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': <UnitOfDataRate.KILOBITS_PER_SECOND: 'kbit/s'>,
'unit_of_measurement': <UnitOfDataRate.MEGABITS_PER_SECOND: 'Mbit/s'>,
}),
'context': <ANY>,
'entity_id': 'sensor.nanostation_5ac_ap_name_throughput_transmit_actual',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '222',
'state': '0.222',
})
# ---
# name: test_all_entities[sensor.nanostation_5ac_ap_name_upload_capacity-entry]
Expand Down Expand Up @@ -357,6 +369,9 @@
'sensor': dict({
'suggested_display_precision': 0,
}),
'sensor.private': dict({
'suggested_unit_of_measurement': <UnitOfDataRate.MEGABITS_PER_SECOND: 'Mbit/s'>,
}),
}),
'original_device_class': <SensorDeviceClass.DATA_RATE: 'data_rate'>,
'original_icon': None,
Expand All @@ -367,7 +382,7 @@
'supported_features': 0,
'translation_key': 'wireless_polling_ul_capacity',
'unique_id': '01:23:45:67:89:AB_wireless_polling_ul_capacity',
'unit_of_measurement': <UnitOfDataRate.KILOBITS_PER_SECOND: 'kbit/s'>,
'unit_of_measurement': <UnitOfDataRate.MEGABITS_PER_SECOND: 'Mbit/s'>,
})
# ---
# name: test_all_entities[sensor.nanostation_5ac_ap_name_upload_capacity-state]
Expand All @@ -376,14 +391,14 @@
'device_class': 'data_rate',
'friendly_name': 'NanoStation 5AC ap name Upload capacity',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': <UnitOfDataRate.KILOBITS_PER_SECOND: 'kbit/s'>,
'unit_of_measurement': <UnitOfDataRate.MEGABITS_PER_SECOND: 'Mbit/s'>,
}),
'context': <ANY>,
'entity_id': 'sensor.nanostation_5ac_ap_name_upload_capacity',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '540540',
'state': '540.54',
})
# ---
# name: test_all_entities[sensor.nanostation_5ac_ap_name_wireless_frequency-entry]
Expand Down
24 changes: 24 additions & 0 deletions tests/components/playstation_network/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,3 +493,27 @@ async def test_add_friend_flow_already_configured_as_entry(

assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured_as_entry"


async def test_add_friend_flow_no_friends(
hass: HomeAssistant,
config_entry: MockConfigEntry,
mock_psnawpapi: MagicMock,
) -> None:
"""Test we abort add friend subentry flow when the user has no friends."""

config_entry.add_to_hass(hass)
assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()

assert config_entry.state is ConfigEntryState.LOADED

mock_psnawpapi.user.return_value.friends_list.return_value = []

result = await hass.config_entries.subentries.async_init(
(config_entry.entry_id, "friend"),
context={"source": SOURCE_USER},
)

assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_friends"
9 changes: 5 additions & 4 deletions tests/components/tuya/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,13 +532,14 @@ async def initialize_entry(
hass: HomeAssistant,
mock_manager: ManagerCompat,
mock_config_entry: MockConfigEntry,
mock_device: CustomerDevice,
mock_devices: CustomerDevice | list[CustomerDevice],
) -> None:
"""Initialize the Tuya component with a mock manager and config entry."""
if not isinstance(mock_devices, list):
mock_devices = [mock_devices]
mock_manager.device_map = {device.id: device for device in mock_devices}

# Setup
mock_manager.device_map = {
mock_device.id: mock_device,
}
mock_config_entry.add_to_hass(hass)

# Initialize the component
Expand Down
19 changes: 18 additions & 1 deletion tests/components/tuya/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from homeassistant.helpers.json import json_dumps
from homeassistant.util import dt as dt_util

from . import MockDeviceListener
from . import DEVICE_MOCKS, MockDeviceListener

from tests.common import MockConfigEntry, async_load_json_object_fixture

Expand Down Expand Up @@ -138,8 +138,25 @@ def mock_device_code() -> str:
return None


@pytest.fixture
async def mock_devices(hass: HomeAssistant) -> list[CustomerDevice]:
"""Load all Tuya CustomerDevice fixtures.

Use this to generate global snapshots for each platform.
"""
return [await _create_device(hass, key) for key in DEVICE_MOCKS]


@pytest.fixture
async def mock_device(hass: HomeAssistant, mock_device_code: str) -> CustomerDevice:
"""Load a single Tuya CustomerDevice fixture.

Use this for testing behavior on a specific device.
"""
return await _create_device(hass, mock_device_code)


async def _create_device(hass: HomeAssistant, mock_device_code: str) -> CustomerDevice:
"""Mock a Tuya CustomerDevice."""
details = await async_load_json_object_fixture(
hass, f"{mock_device_code}.json", DOMAIN
Expand Down
4 changes: 2 additions & 2 deletions tests/components/tuya/snapshots/test_alarm_control_panel.ambr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# serializer version: 1
# name: test_platform_setup_and_discovery[mal_gyitctrjj1kefxp2][alarm_control_panel.multifunction_alarm-entry]
# name: test_platform_setup_and_discovery[alarm_control_panel.multifunction_alarm-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
Expand Down Expand Up @@ -34,7 +34,7 @@
'unit_of_measurement': None,
})
# ---
# name: test_platform_setup_and_discovery[mal_gyitctrjj1kefxp2][alarm_control_panel.multifunction_alarm-state]
# name: test_platform_setup_and_discovery[alarm_control_panel.multifunction_alarm-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'changed_by': None,
Expand Down
Loading
Loading