Add preconditioning number entity to Ohme (#138346)
* Add preconditioning number entity * Updated test snapshots for ohme * Update test snapshotspull/137247/head
parent
ed3ca76696
commit
66d16336ea
|
@ -6,6 +6,9 @@
|
|||
}
|
||||
},
|
||||
"number": {
|
||||
"preconditioning_duration": {
|
||||
"default": "mdi:fan-clock"
|
||||
},
|
||||
"target_percentage": {
|
||||
"default": "mdi:battery-heart"
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ from dataclasses import dataclass
|
|||
from ohme import ApiException, OhmeApiClient
|
||||
|
||||
from homeassistant.components.number import NumberEntity, NumberEntityDescription
|
||||
from homeassistant.const import PERCENTAGE
|
||||
from homeassistant.const import PERCENTAGE, UnitOfTime
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
@ -37,6 +37,18 @@ NUMBER_DESCRIPTION = [
|
|||
native_step=1,
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
),
|
||||
OhmeNumberDescription(
|
||||
key="preconditioning_duration",
|
||||
translation_key="preconditioning_duration",
|
||||
value_fn=lambda client: client.preconditioning,
|
||||
set_fn=lambda client, value: client.async_set_target(
|
||||
pre_condition_length=value
|
||||
),
|
||||
native_min_value=0,
|
||||
native_max_value=60,
|
||||
native_step=5,
|
||||
native_unit_of_measurement=UnitOfTime.MINUTES,
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -51,6 +51,9 @@
|
|||
}
|
||||
},
|
||||
"number": {
|
||||
"preconditioning_duration": {
|
||||
"name": "Preconditioning duration"
|
||||
},
|
||||
"target_percentage": {
|
||||
"name": "Target percentage"
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ def mock_client():
|
|||
client.target_soc = 50
|
||||
client.target_time = (8, 0)
|
||||
client.battery = 80
|
||||
client.preconditioning = 15
|
||||
client.serial = "chargerid"
|
||||
client.ct_connected = True
|
||||
client.energy = 1000
|
||||
|
|
|
@ -1,4 +1,61 @@
|
|||
# serializer version: 1
|
||||
# name: test_numbers[number.ohme_home_pro_preconditioning_duration-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'max': 60,
|
||||
'min': 0,
|
||||
'mode': <NumberMode.AUTO: 'auto'>,
|
||||
'step': 5,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'number',
|
||||
'entity_category': None,
|
||||
'entity_id': 'number.ohme_home_pro_preconditioning_duration',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Preconditioning duration',
|
||||
'platform': 'ohme',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'preconditioning_duration',
|
||||
'unique_id': 'chargerid_preconditioning_duration',
|
||||
'unit_of_measurement': <UnitOfTime.MINUTES: 'min'>,
|
||||
})
|
||||
# ---
|
||||
# name: test_numbers[number.ohme_home_pro_preconditioning_duration-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'friendly_name': 'Ohme Home Pro Preconditioning duration',
|
||||
'max': 60,
|
||||
'min': 0,
|
||||
'mode': <NumberMode.AUTO: 'auto'>,
|
||||
'step': 5,
|
||||
'unit_of_measurement': <UnitOfTime.MINUTES: 'min'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'number.ohme_home_pro_preconditioning_duration',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '15',
|
||||
})
|
||||
# ---
|
||||
# name: test_numbers[number.ohme_home_pro_target_percentage-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
|
|
Loading…
Reference in New Issue