Add device class to gardena (#149144)

This commit is contained in:
Joakim Plate 2025-07-21 08:15:32 +02:00 committed by GitHub
parent eca80a1645
commit bc9ad5eac6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 1 deletions

View File

@ -13,6 +13,7 @@ from gardena_bluetooth.parse import (
)
from homeassistant.components.number import (
NumberDeviceClass,
NumberEntity,
NumberEntityDescription,
NumberMode,
@ -54,6 +55,7 @@ DESCRIPTIONS = (
native_step=60,
entity_category=EntityCategory.CONFIG,
char=Valve.manual_watering_time,
device_class=NumberDeviceClass.DURATION,
),
GardenaBluetoothNumberEntityDescription(
key=Valve.remaining_open_time.uuid,
@ -64,6 +66,7 @@ DESCRIPTIONS = (
native_step=60.0,
entity_category=EntityCategory.DIAGNOSTIC,
char=Valve.remaining_open_time,
device_class=NumberDeviceClass.DURATION,
),
GardenaBluetoothNumberEntityDescription(
key=DeviceConfiguration.rain_pause.uuid,
@ -75,6 +78,7 @@ DESCRIPTIONS = (
native_step=6 * 60.0,
entity_category=EntityCategory.CONFIG,
char=DeviceConfiguration.rain_pause,
device_class=NumberDeviceClass.DURATION,
),
GardenaBluetoothNumberEntityDescription(
key=DeviceConfiguration.seasonal_adjust.uuid,
@ -86,6 +90,7 @@ DESCRIPTIONS = (
native_step=1.0,
entity_category=EntityCategory.CONFIG,
char=DeviceConfiguration.seasonal_adjust,
device_class=NumberDeviceClass.DURATION,
),
GardenaBluetoothNumberEntityDescription(
key=Sensor.threshold.uuid,
@ -153,6 +158,7 @@ class GardenaBluetoothRemainingOpenSetNumber(GardenaBluetoothEntity, NumberEntit
_attr_native_min_value = 0.0
_attr_native_max_value = 24 * 60
_attr_native_step = 1.0
_attr_device_class = NumberDeviceClass.DURATION
def __init__(
self,

View File

@ -6,7 +6,11 @@ from typing import Any
from gardena_bluetooth.const import Valve
from homeassistant.components.valve import ValveEntity, ValveEntityFeature
from homeassistant.components.valve import (
ValveDeviceClass,
ValveEntity,
ValveEntityFeature,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
@ -37,6 +41,7 @@ class GardenaBluetoothValve(GardenaBluetoothEntity, ValveEntity):
_attr_is_closed: bool | None = None
_attr_reports_position = False
_attr_supported_features = ValveEntityFeature.OPEN | ValveEntityFeature.CLOSE
_attr_device_class = ValveDeviceClass.WATER
characteristics = {
Valve.state.uuid,

View File

@ -2,6 +2,7 @@
# name: test_bluetooth_error_unavailable
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'duration',
'friendly_name': 'Mock Title Remaining open time',
'max': 86400,
'min': 0.0,
@ -20,6 +21,7 @@
# name: test_bluetooth_error_unavailable.1
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'duration',
'friendly_name': 'Mock Title Manual watering time',
'max': 86400,
'min': 0.0,
@ -38,6 +40,7 @@
# name: test_bluetooth_error_unavailable.2
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'duration',
'friendly_name': 'Mock Title Remaining open time',
'max': 86400,
'min': 0.0,
@ -56,6 +59,7 @@
# name: test_bluetooth_error_unavailable.3
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'duration',
'friendly_name': 'Mock Title Manual watering time',
'max': 86400,
'min': 0.0,
@ -110,6 +114,7 @@
# name: test_setup[98bd0f13-0b0e-421a-84e5-ddbf75dc6de4-raw1-number.mock_title_remaining_open_time]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'duration',
'friendly_name': 'Mock Title Remaining open time',
'max': 86400,
'min': 0.0,
@ -128,6 +133,7 @@
# name: test_setup[98bd0f13-0b0e-421a-84e5-ddbf75dc6de4-raw1-number.mock_title_remaining_open_time].1
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'duration',
'friendly_name': 'Mock Title Remaining open time',
'max': 86400,
'min': 0.0,
@ -146,6 +152,7 @@
# name: test_setup[98bd0f13-0b0e-421a-84e5-ddbf75dc6de4-raw1-number.mock_title_remaining_open_time].2
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'duration',
'friendly_name': 'Mock Title Remaining open time',
'max': 86400,
'min': 0.0,
@ -164,6 +171,7 @@
# name: test_setup[98bd0f13-0b0e-421a-84e5-ddbf75dc6de4-raw1-number.mock_title_remaining_open_time].3
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'duration',
'friendly_name': 'Mock Title Remaining open time',
'max': 86400,
'min': 0.0,
@ -182,6 +190,7 @@
# name: test_setup[98bd0f13-0b0e-421a-84e5-ddbf75dc6de4-raw2-number.mock_title_open_for]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'duration',
'friendly_name': 'Mock Title Open for',
'max': 1440,
'min': 0.0,
@ -200,6 +209,7 @@
# name: test_setup[98bd0f14-0b0e-421a-84e5-ddbf75dc6de4-raw0-number.mock_title_manual_watering_time]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'duration',
'friendly_name': 'Mock Title Manual watering time',
'max': 86400,
'min': 0.0,
@ -218,6 +228,7 @@
# name: test_setup[98bd0f14-0b0e-421a-84e5-ddbf75dc6de4-raw0-number.mock_title_manual_watering_time].1
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'duration',
'friendly_name': 'Mock Title Manual watering time',
'max': 86400,
'min': 0.0,

View File

@ -2,6 +2,7 @@
# name: test_setup
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'water',
'friendly_name': 'Mock Title',
'supported_features': <ValveEntityFeature: 3>,
}),
@ -16,6 +17,7 @@
# name: test_setup.1
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'water',
'friendly_name': 'Mock Title',
'supported_features': <ValveEntityFeature: 3>,
}),