mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 07:37:34 +00:00
Add device class to gardena (#149144)
This commit is contained in:
parent
eca80a1645
commit
bc9ad5eac6
@ -13,6 +13,7 @@ from gardena_bluetooth.parse import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from homeassistant.components.number import (
|
from homeassistant.components.number import (
|
||||||
|
NumberDeviceClass,
|
||||||
NumberEntity,
|
NumberEntity,
|
||||||
NumberEntityDescription,
|
NumberEntityDescription,
|
||||||
NumberMode,
|
NumberMode,
|
||||||
@ -54,6 +55,7 @@ DESCRIPTIONS = (
|
|||||||
native_step=60,
|
native_step=60,
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
char=Valve.manual_watering_time,
|
char=Valve.manual_watering_time,
|
||||||
|
device_class=NumberDeviceClass.DURATION,
|
||||||
),
|
),
|
||||||
GardenaBluetoothNumberEntityDescription(
|
GardenaBluetoothNumberEntityDescription(
|
||||||
key=Valve.remaining_open_time.uuid,
|
key=Valve.remaining_open_time.uuid,
|
||||||
@ -64,6 +66,7 @@ DESCRIPTIONS = (
|
|||||||
native_step=60.0,
|
native_step=60.0,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
char=Valve.remaining_open_time,
|
char=Valve.remaining_open_time,
|
||||||
|
device_class=NumberDeviceClass.DURATION,
|
||||||
),
|
),
|
||||||
GardenaBluetoothNumberEntityDescription(
|
GardenaBluetoothNumberEntityDescription(
|
||||||
key=DeviceConfiguration.rain_pause.uuid,
|
key=DeviceConfiguration.rain_pause.uuid,
|
||||||
@ -75,6 +78,7 @@ DESCRIPTIONS = (
|
|||||||
native_step=6 * 60.0,
|
native_step=6 * 60.0,
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
char=DeviceConfiguration.rain_pause,
|
char=DeviceConfiguration.rain_pause,
|
||||||
|
device_class=NumberDeviceClass.DURATION,
|
||||||
),
|
),
|
||||||
GardenaBluetoothNumberEntityDescription(
|
GardenaBluetoothNumberEntityDescription(
|
||||||
key=DeviceConfiguration.seasonal_adjust.uuid,
|
key=DeviceConfiguration.seasonal_adjust.uuid,
|
||||||
@ -86,6 +90,7 @@ DESCRIPTIONS = (
|
|||||||
native_step=1.0,
|
native_step=1.0,
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
char=DeviceConfiguration.seasonal_adjust,
|
char=DeviceConfiguration.seasonal_adjust,
|
||||||
|
device_class=NumberDeviceClass.DURATION,
|
||||||
),
|
),
|
||||||
GardenaBluetoothNumberEntityDescription(
|
GardenaBluetoothNumberEntityDescription(
|
||||||
key=Sensor.threshold.uuid,
|
key=Sensor.threshold.uuid,
|
||||||
@ -153,6 +158,7 @@ class GardenaBluetoothRemainingOpenSetNumber(GardenaBluetoothEntity, NumberEntit
|
|||||||
_attr_native_min_value = 0.0
|
_attr_native_min_value = 0.0
|
||||||
_attr_native_max_value = 24 * 60
|
_attr_native_max_value = 24 * 60
|
||||||
_attr_native_step = 1.0
|
_attr_native_step = 1.0
|
||||||
|
_attr_device_class = NumberDeviceClass.DURATION
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -6,7 +6,11 @@ from typing import Any
|
|||||||
|
|
||||||
from gardena_bluetooth.const import Valve
|
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.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
@ -37,6 +41,7 @@ class GardenaBluetoothValve(GardenaBluetoothEntity, ValveEntity):
|
|||||||
_attr_is_closed: bool | None = None
|
_attr_is_closed: bool | None = None
|
||||||
_attr_reports_position = False
|
_attr_reports_position = False
|
||||||
_attr_supported_features = ValveEntityFeature.OPEN | ValveEntityFeature.CLOSE
|
_attr_supported_features = ValveEntityFeature.OPEN | ValveEntityFeature.CLOSE
|
||||||
|
_attr_device_class = ValveDeviceClass.WATER
|
||||||
|
|
||||||
characteristics = {
|
characteristics = {
|
||||||
Valve.state.uuid,
|
Valve.state.uuid,
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# name: test_bluetooth_error_unavailable
|
# name: test_bluetooth_error_unavailable
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'device_class': 'duration',
|
||||||
'friendly_name': 'Mock Title Remaining open time',
|
'friendly_name': 'Mock Title Remaining open time',
|
||||||
'max': 86400,
|
'max': 86400,
|
||||||
'min': 0.0,
|
'min': 0.0,
|
||||||
@ -20,6 +21,7 @@
|
|||||||
# name: test_bluetooth_error_unavailable.1
|
# name: test_bluetooth_error_unavailable.1
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'device_class': 'duration',
|
||||||
'friendly_name': 'Mock Title Manual watering time',
|
'friendly_name': 'Mock Title Manual watering time',
|
||||||
'max': 86400,
|
'max': 86400,
|
||||||
'min': 0.0,
|
'min': 0.0,
|
||||||
@ -38,6 +40,7 @@
|
|||||||
# name: test_bluetooth_error_unavailable.2
|
# name: test_bluetooth_error_unavailable.2
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'device_class': 'duration',
|
||||||
'friendly_name': 'Mock Title Remaining open time',
|
'friendly_name': 'Mock Title Remaining open time',
|
||||||
'max': 86400,
|
'max': 86400,
|
||||||
'min': 0.0,
|
'min': 0.0,
|
||||||
@ -56,6 +59,7 @@
|
|||||||
# name: test_bluetooth_error_unavailable.3
|
# name: test_bluetooth_error_unavailable.3
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'device_class': 'duration',
|
||||||
'friendly_name': 'Mock Title Manual watering time',
|
'friendly_name': 'Mock Title Manual watering time',
|
||||||
'max': 86400,
|
'max': 86400,
|
||||||
'min': 0.0,
|
'min': 0.0,
|
||||||
@ -110,6 +114,7 @@
|
|||||||
# name: test_setup[98bd0f13-0b0e-421a-84e5-ddbf75dc6de4-raw1-number.mock_title_remaining_open_time]
|
# name: test_setup[98bd0f13-0b0e-421a-84e5-ddbf75dc6de4-raw1-number.mock_title_remaining_open_time]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'device_class': 'duration',
|
||||||
'friendly_name': 'Mock Title Remaining open time',
|
'friendly_name': 'Mock Title Remaining open time',
|
||||||
'max': 86400,
|
'max': 86400,
|
||||||
'min': 0.0,
|
'min': 0.0,
|
||||||
@ -128,6 +133,7 @@
|
|||||||
# name: test_setup[98bd0f13-0b0e-421a-84e5-ddbf75dc6de4-raw1-number.mock_title_remaining_open_time].1
|
# name: test_setup[98bd0f13-0b0e-421a-84e5-ddbf75dc6de4-raw1-number.mock_title_remaining_open_time].1
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'device_class': 'duration',
|
||||||
'friendly_name': 'Mock Title Remaining open time',
|
'friendly_name': 'Mock Title Remaining open time',
|
||||||
'max': 86400,
|
'max': 86400,
|
||||||
'min': 0.0,
|
'min': 0.0,
|
||||||
@ -146,6 +152,7 @@
|
|||||||
# name: test_setup[98bd0f13-0b0e-421a-84e5-ddbf75dc6de4-raw1-number.mock_title_remaining_open_time].2
|
# name: test_setup[98bd0f13-0b0e-421a-84e5-ddbf75dc6de4-raw1-number.mock_title_remaining_open_time].2
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'device_class': 'duration',
|
||||||
'friendly_name': 'Mock Title Remaining open time',
|
'friendly_name': 'Mock Title Remaining open time',
|
||||||
'max': 86400,
|
'max': 86400,
|
||||||
'min': 0.0,
|
'min': 0.0,
|
||||||
@ -164,6 +171,7 @@
|
|||||||
# name: test_setup[98bd0f13-0b0e-421a-84e5-ddbf75dc6de4-raw1-number.mock_title_remaining_open_time].3
|
# name: test_setup[98bd0f13-0b0e-421a-84e5-ddbf75dc6de4-raw1-number.mock_title_remaining_open_time].3
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'device_class': 'duration',
|
||||||
'friendly_name': 'Mock Title Remaining open time',
|
'friendly_name': 'Mock Title Remaining open time',
|
||||||
'max': 86400,
|
'max': 86400,
|
||||||
'min': 0.0,
|
'min': 0.0,
|
||||||
@ -182,6 +190,7 @@
|
|||||||
# name: test_setup[98bd0f13-0b0e-421a-84e5-ddbf75dc6de4-raw2-number.mock_title_open_for]
|
# name: test_setup[98bd0f13-0b0e-421a-84e5-ddbf75dc6de4-raw2-number.mock_title_open_for]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'device_class': 'duration',
|
||||||
'friendly_name': 'Mock Title Open for',
|
'friendly_name': 'Mock Title Open for',
|
||||||
'max': 1440,
|
'max': 1440,
|
||||||
'min': 0.0,
|
'min': 0.0,
|
||||||
@ -200,6 +209,7 @@
|
|||||||
# name: test_setup[98bd0f14-0b0e-421a-84e5-ddbf75dc6de4-raw0-number.mock_title_manual_watering_time]
|
# name: test_setup[98bd0f14-0b0e-421a-84e5-ddbf75dc6de4-raw0-number.mock_title_manual_watering_time]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'device_class': 'duration',
|
||||||
'friendly_name': 'Mock Title Manual watering time',
|
'friendly_name': 'Mock Title Manual watering time',
|
||||||
'max': 86400,
|
'max': 86400,
|
||||||
'min': 0.0,
|
'min': 0.0,
|
||||||
@ -218,6 +228,7 @@
|
|||||||
# name: test_setup[98bd0f14-0b0e-421a-84e5-ddbf75dc6de4-raw0-number.mock_title_manual_watering_time].1
|
# name: test_setup[98bd0f14-0b0e-421a-84e5-ddbf75dc6de4-raw0-number.mock_title_manual_watering_time].1
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'device_class': 'duration',
|
||||||
'friendly_name': 'Mock Title Manual watering time',
|
'friendly_name': 'Mock Title Manual watering time',
|
||||||
'max': 86400,
|
'max': 86400,
|
||||||
'min': 0.0,
|
'min': 0.0,
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# name: test_setup
|
# name: test_setup
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'device_class': 'water',
|
||||||
'friendly_name': 'Mock Title',
|
'friendly_name': 'Mock Title',
|
||||||
'supported_features': <ValveEntityFeature: 3>,
|
'supported_features': <ValveEntityFeature: 3>,
|
||||||
}),
|
}),
|
||||||
@ -16,6 +17,7 @@
|
|||||||
# name: test_setup.1
|
# name: test_setup.1
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'device_class': 'water',
|
||||||
'friendly_name': 'Mock Title',
|
'friendly_name': 'Mock Title',
|
||||||
'supported_features': <ValveEntityFeature: 3>,
|
'supported_features': <ValveEntityFeature: 3>,
|
||||||
}),
|
}),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user