Bump aioautomower to 2024.3.3 (#113430)

This commit is contained in:
Thomas55555 2024-03-14 17:51:24 +01:00 committed by GitHub
parent 8a8546579c
commit f1374503c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 35 additions and 8 deletions

View file

@ -7,5 +7,5 @@
"documentation": "https://www.home-assistant.io/integrations/husqvarna_automower",
"iot_class": "cloud_push",
"loggers": ["aioautomower"],
"requirements": ["aioautomower==2024.3.2"]
"requirements": ["aioautomower==2024.3.3"]
}

View file

@ -70,6 +70,7 @@ SENSOR_TYPES: tuple[AutomowerSensorEntityDescription, ...] = (
device_class=SensorDeviceClass.DURATION,
native_unit_of_measurement=UnitOfTime.SECONDS,
suggested_unit_of_measurement=UnitOfTime.HOURS,
exists_fn=lambda data: data.statistics.total_charging_time is not None,
value_fn=lambda data: data.statistics.total_charging_time,
),
AutomowerSensorEntityDescription(
@ -80,6 +81,7 @@ SENSOR_TYPES: tuple[AutomowerSensorEntityDescription, ...] = (
device_class=SensorDeviceClass.DURATION,
native_unit_of_measurement=UnitOfTime.SECONDS,
suggested_unit_of_measurement=UnitOfTime.HOURS,
exists_fn=lambda data: data.statistics.total_cutting_time is not None,
value_fn=lambda data: data.statistics.total_cutting_time,
),
AutomowerSensorEntityDescription(
@ -90,6 +92,7 @@ SENSOR_TYPES: tuple[AutomowerSensorEntityDescription, ...] = (
device_class=SensorDeviceClass.DURATION,
native_unit_of_measurement=UnitOfTime.SECONDS,
suggested_unit_of_measurement=UnitOfTime.HOURS,
exists_fn=lambda data: data.statistics.total_running_time is not None,
value_fn=lambda data: data.statistics.total_running_time,
),
AutomowerSensorEntityDescription(
@ -100,6 +103,7 @@ SENSOR_TYPES: tuple[AutomowerSensorEntityDescription, ...] = (
device_class=SensorDeviceClass.DURATION,
native_unit_of_measurement=UnitOfTime.SECONDS,
suggested_unit_of_measurement=UnitOfTime.HOURS,
exists_fn=lambda data: data.statistics.total_searching_time is not None,
value_fn=lambda data: data.statistics.total_searching_time,
),
AutomowerSensorEntityDescription(
@ -107,6 +111,7 @@ SENSOR_TYPES: tuple[AutomowerSensorEntityDescription, ...] = (
translation_key="number_of_charging_cycles",
entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.TOTAL,
exists_fn=lambda data: data.statistics.number_of_charging_cycles is not None,
value_fn=lambda data: data.statistics.number_of_charging_cycles,
),
AutomowerSensorEntityDescription(
@ -114,6 +119,7 @@ SENSOR_TYPES: tuple[AutomowerSensorEntityDescription, ...] = (
translation_key="number_of_collisions",
entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.TOTAL,
exists_fn=lambda data: data.statistics.number_of_collisions is not None,
value_fn=lambda data: data.statistics.number_of_collisions,
),
AutomowerSensorEntityDescription(
@ -124,6 +130,7 @@ SENSOR_TYPES: tuple[AutomowerSensorEntityDescription, ...] = (
device_class=SensorDeviceClass.DISTANCE,
native_unit_of_measurement=UnitOfLength.METERS,
suggested_unit_of_measurement=UnitOfLength.KILOMETERS,
exists_fn=lambda data: data.statistics.total_drive_distance is not None,
value_fn=lambda data: data.statistics.total_drive_distance,
),
AutomowerSensorEntityDescription(

View file

@ -203,7 +203,7 @@ aioaseko==0.1.1
aioasuswrt==1.4.0
# homeassistant.components.husqvarna_automower
aioautomower==2024.3.2
aioautomower==2024.3.3
# homeassistant.components.azure_devops
aioazuredevops==1.3.5

View file

@ -182,7 +182,7 @@ aioaseko==0.1.1
aioasuswrt==1.4.0
# homeassistant.components.husqvarna_automower
aioautomower==2024.3.2
aioautomower==2024.3.3
# homeassistant.components.azure_devops
aioazuredevops==1.3.5

View file

@ -6,6 +6,7 @@ from unittest.mock import AsyncMock, patch
from aioautomower.model import MowerModes
from aioautomower.utils import mower_list_to_dictionary_dataclass
from freezegun.api import FrozenDateTimeFactory
import pytest
from syrupy import SnapshotAssertion
from homeassistant.components.husqvarna_automower.const import DOMAIN
@ -60,17 +61,36 @@ async def test_cutting_blade_usage_time_sensor(
assert state is not None
assert state.state == "0.034"
entry = hass.config_entries.async_entries(DOMAIN)[0]
await hass.config_entries.async_remove(entry.entry_id)
await hass.async_block_till_done()
@pytest.mark.parametrize(
("sensor_to_test"),
[
("cutting_blade_usage_time"),
("number_of_charging_cycles"),
("number_of_collisions"),
("total_charging_time"),
("total_cutting_time"),
("total_running_time"),
("total_searching_time"),
("total_drive_distance"),
],
)
async def test_statistics_not_available(
hass: HomeAssistant,
mock_automower_client: AsyncMock,
mock_config_entry: MockConfigEntry,
sensor_to_test: str,
) -> None:
"""Test if this sensor is only added, if data is available."""
values = mower_list_to_dictionary_dataclass(
load_json_value_fixture("mower.json", DOMAIN)
)
delattr(values[TEST_MOWER_ID].statistics, "cutting_blade_usage_time")
delattr(values[TEST_MOWER_ID].statistics, sensor_to_test)
mock_automower_client.get_status.return_value = values
await setup_integration(hass, mock_config_entry)
state = hass.states.get("sensor.test_mower_1_cutting_blade_usage_time")
state = hass.states.get(f"sensor.test_mower_1_{sensor_to_test}")
assert state is None