mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Add inactive reason sensor to Husqvarna Automower (#147684)
This commit is contained in:
parent
033d8b3dfb
commit
8a73511b02
@ -24,6 +24,9 @@
|
|||||||
"error": {
|
"error": {
|
||||||
"default": "mdi:alert-circle-outline"
|
"default": "mdi:alert-circle-outline"
|
||||||
},
|
},
|
||||||
|
"inactive_reason": {
|
||||||
|
"default": "mdi:sleep"
|
||||||
|
},
|
||||||
"my_lawn_last_time_completed": {
|
"my_lawn_last_time_completed": {
|
||||||
"default": "mdi:clock-outline"
|
"default": "mdi:clock-outline"
|
||||||
},
|
},
|
||||||
|
@ -7,7 +7,13 @@ import logging
|
|||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
from aioautomower.model import MowerAttributes, MowerModes, RestrictedReasons, WorkArea
|
from aioautomower.model import (
|
||||||
|
InactiveReasons,
|
||||||
|
MowerAttributes,
|
||||||
|
MowerModes,
|
||||||
|
RestrictedReasons,
|
||||||
|
WorkArea,
|
||||||
|
)
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
SensorDeviceClass,
|
SensorDeviceClass,
|
||||||
@ -166,6 +172,13 @@ ERROR_KEY_LIST = list(
|
|||||||
dict.fromkeys(ERROR_KEYS + [state.lower() for state in ERROR_STATES])
|
dict.fromkeys(ERROR_KEYS + [state.lower() for state in ERROR_STATES])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
INACTIVE_REASONS: list = [
|
||||||
|
InactiveReasons.NONE,
|
||||||
|
InactiveReasons.PLANNING,
|
||||||
|
InactiveReasons.SEARCHING_FOR_SATELLITES,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
RESTRICTED_REASONS: list = [
|
RESTRICTED_REASONS: list = [
|
||||||
RestrictedReasons.ALL_WORK_AREAS_COMPLETED,
|
RestrictedReasons.ALL_WORK_AREAS_COMPLETED,
|
||||||
RestrictedReasons.DAILY_LIMIT,
|
RestrictedReasons.DAILY_LIMIT,
|
||||||
@ -389,6 +402,14 @@ MOWER_SENSOR_TYPES: tuple[AutomowerSensorEntityDescription, ...] = (
|
|||||||
option_fn=lambda data: RESTRICTED_REASONS,
|
option_fn=lambda data: RESTRICTED_REASONS,
|
||||||
value_fn=attrgetter("planner.restricted_reason"),
|
value_fn=attrgetter("planner.restricted_reason"),
|
||||||
),
|
),
|
||||||
|
AutomowerSensorEntityDescription(
|
||||||
|
key="inactive_reason",
|
||||||
|
translation_key="inactive_reason",
|
||||||
|
exists_fn=lambda data: data.capabilities.work_areas,
|
||||||
|
device_class=SensorDeviceClass.ENUM,
|
||||||
|
option_fn=lambda data: INACTIVE_REASONS,
|
||||||
|
value_fn=attrgetter("mower.inactive_reason"),
|
||||||
|
),
|
||||||
AutomowerSensorEntityDescription(
|
AutomowerSensorEntityDescription(
|
||||||
key="work_area",
|
key="work_area",
|
||||||
translation_key="work_area",
|
translation_key="work_area",
|
||||||
|
@ -213,6 +213,14 @@
|
|||||||
"zone_generator_problem": "Zone generator problem"
|
"zone_generator_problem": "Zone generator problem"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"inactive_reason": {
|
||||||
|
"name": "Inactive reason",
|
||||||
|
"state": {
|
||||||
|
"none": "No inactivity",
|
||||||
|
"planning": "Planning",
|
||||||
|
"searching_for_satellites": "Searching for satellites"
|
||||||
|
}
|
||||||
|
},
|
||||||
"my_lawn_last_time_completed": {
|
"my_lawn_last_time_completed": {
|
||||||
"name": "My lawn last time completed"
|
"name": "My lawn last time completed"
|
||||||
},
|
},
|
||||||
|
@ -585,6 +585,66 @@
|
|||||||
'state': '40',
|
'state': '40',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
|
# name: test_sensor_snapshot[sensor.test_mower_1_inactive_reason-entry]
|
||||||
|
EntityRegistryEntrySnapshot({
|
||||||
|
'aliases': set({
|
||||||
|
}),
|
||||||
|
'area_id': None,
|
||||||
|
'capabilities': dict({
|
||||||
|
'options': list([
|
||||||
|
<InactiveReasons.NONE: 'none'>,
|
||||||
|
<InactiveReasons.PLANNING: 'planning'>,
|
||||||
|
<InactiveReasons.SEARCHING_FOR_SATELLITES: 'searching_for_satellites'>,
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
'config_entry_id': <ANY>,
|
||||||
|
'config_subentry_id': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'disabled_by': None,
|
||||||
|
'domain': 'sensor',
|
||||||
|
'entity_category': None,
|
||||||
|
'entity_id': 'sensor.test_mower_1_inactive_reason',
|
||||||
|
'has_entity_name': True,
|
||||||
|
'hidden_by': None,
|
||||||
|
'icon': None,
|
||||||
|
'id': <ANY>,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'name': None,
|
||||||
|
'options': dict({
|
||||||
|
}),
|
||||||
|
'original_device_class': <SensorDeviceClass.ENUM: 'enum'>,
|
||||||
|
'original_icon': None,
|
||||||
|
'original_name': 'Inactive reason',
|
||||||
|
'platform': 'husqvarna_automower',
|
||||||
|
'previous_unique_id': None,
|
||||||
|
'suggested_object_id': None,
|
||||||
|
'supported_features': 0,
|
||||||
|
'translation_key': 'inactive_reason',
|
||||||
|
'unique_id': 'c7233734-b219-4287-a173-08e3643f89f0_inactive_reason',
|
||||||
|
'unit_of_measurement': None,
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_sensor_snapshot[sensor.test_mower_1_inactive_reason-state]
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'device_class': 'enum',
|
||||||
|
'friendly_name': 'Test Mower 1 Inactive reason',
|
||||||
|
'options': list([
|
||||||
|
<InactiveReasons.NONE: 'none'>,
|
||||||
|
<InactiveReasons.PLANNING: 'planning'>,
|
||||||
|
<InactiveReasons.SEARCHING_FOR_SATELLITES: 'searching_for_satellites'>,
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'sensor.test_mower_1_inactive_reason',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'none',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
# name: test_sensor_snapshot[sensor.test_mower_1_mode-entry]
|
# name: test_sensor_snapshot[sensor.test_mower_1_mode-entry]
|
||||||
EntityRegistryEntrySnapshot({
|
EntityRegistryEntrySnapshot({
|
||||||
'aliases': set({
|
'aliases': set({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user