Add Ohme voltage and slot list sensor (#139203)

* Bump ohmepy to 1.3.1

* Bump ohmepy to 1.3.2

* Add voltage and slot list sensor

* CI fixes

* Change slot list sensor name

* Fix snapshot tests
pull/139246/head
Dan Raper 2025-02-25 11:36:08 +00:00 committed by GitHub
parent 051cc41d4f
commit 48d3dd88a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 120 additions and 0 deletions

View File

@ -31,6 +31,9 @@
},
"ct_current": {
"default": "mdi:gauge"
},
"slot_list": {
"default": "mdi:calendar-clock"
}
},
"switch": {

View File

@ -15,7 +15,9 @@ from homeassistant.components.sensor import (
)
from homeassistant.const import (
PERCENTAGE,
STATE_UNKNOWN,
UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfEnergy,
UnitOfPower,
)
@ -66,6 +68,13 @@ SENSOR_CHARGE_SESSION = [
state_class=SensorStateClass.TOTAL_INCREASING,
value_fn=lambda client: client.energy,
),
OhmeSensorDescription(
key="voltage",
device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda client: client.power.volts,
),
OhmeSensorDescription(
key="battery",
translation_key="vehicle_battery",
@ -74,6 +83,12 @@ SENSOR_CHARGE_SESSION = [
suggested_display_precision=0,
value_fn=lambda client: client.battery,
),
OhmeSensorDescription(
key="slot_list",
translation_key="slot_list",
value_fn=lambda client: ", ".join(str(x) for x in client.slots)
or STATE_UNKNOWN,
),
]
SENSOR_ADVANCED_SETTINGS = [

View File

@ -85,6 +85,9 @@
},
"vehicle_battery": {
"name": "Vehicle battery"
},
"slot_list": {
"name": "Charge slots"
}
},
"switch": {

View File

@ -1,4 +1,51 @@
# serializer version: 1
# name: test_sensors[sensor.ohme_home_pro_charge_slots-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'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.ohme_home_pro_charge_slots',
'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': 'Charge slots',
'platform': 'ohme',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'slot_list',
'unique_id': 'chargerid_slot_list',
'unit_of_measurement': None,
})
# ---
# name: test_sensors[sensor.ohme_home_pro_charge_slots-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Ohme Home Pro Charge slots',
}),
'context': <ANY>,
'entity_id': 'sensor.ohme_home_pro_charge_slots',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_sensors[sensor.ohme_home_pro_ct_current-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
@ -327,3 +374,55 @@
'state': '80',
})
# ---
# name: test_sensors[sensor.ohme_home_pro_voltage-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'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.ohme_home_pro_voltage',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SensorDeviceClass.VOLTAGE: 'voltage'>,
'original_icon': None,
'original_name': 'Voltage',
'platform': 'ohme',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': 'chargerid_voltage',
'unit_of_measurement': <UnitOfElectricPotential.VOLT: 'V'>,
})
# ---
# name: test_sensors[sensor.ohme_home_pro_voltage-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'voltage',
'friendly_name': 'Ohme Home Pro Voltage',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': <UnitOfElectricPotential.VOLT: 'V'>,
}),
'context': <ANY>,
'entity_id': 'sensor.ohme_home_pro_voltage',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '0',
})
# ---