mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 13:47:35 +00:00
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
This commit is contained in:
parent
051cc41d4f
commit
48d3dd88a1
@ -31,6 +31,9 @@
|
|||||||
},
|
},
|
||||||
"ct_current": {
|
"ct_current": {
|
||||||
"default": "mdi:gauge"
|
"default": "mdi:gauge"
|
||||||
|
},
|
||||||
|
"slot_list": {
|
||||||
|
"default": "mdi:calendar-clock"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"switch": {
|
"switch": {
|
||||||
|
@ -15,7 +15,9 @@ from homeassistant.components.sensor import (
|
|||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
|
STATE_UNKNOWN,
|
||||||
UnitOfElectricCurrent,
|
UnitOfElectricCurrent,
|
||||||
|
UnitOfElectricPotential,
|
||||||
UnitOfEnergy,
|
UnitOfEnergy,
|
||||||
UnitOfPower,
|
UnitOfPower,
|
||||||
)
|
)
|
||||||
@ -66,6 +68,13 @@ SENSOR_CHARGE_SESSION = [
|
|||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
value_fn=lambda client: client.energy,
|
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(
|
OhmeSensorDescription(
|
||||||
key="battery",
|
key="battery",
|
||||||
translation_key="vehicle_battery",
|
translation_key="vehicle_battery",
|
||||||
@ -74,6 +83,12 @@ SENSOR_CHARGE_SESSION = [
|
|||||||
suggested_display_precision=0,
|
suggested_display_precision=0,
|
||||||
value_fn=lambda client: client.battery,
|
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 = [
|
SENSOR_ADVANCED_SETTINGS = [
|
||||||
|
@ -85,6 +85,9 @@
|
|||||||
},
|
},
|
||||||
"vehicle_battery": {
|
"vehicle_battery": {
|
||||||
"name": "Vehicle battery"
|
"name": "Vehicle battery"
|
||||||
|
},
|
||||||
|
"slot_list": {
|
||||||
|
"name": "Charge slots"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"switch": {
|
"switch": {
|
||||||
|
@ -1,4 +1,51 @@
|
|||||||
# serializer version: 1
|
# 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]
|
# name: test_sensors[sensor.ohme_home_pro_ct_current-entry]
|
||||||
EntityRegistryEntrySnapshot({
|
EntityRegistryEntrySnapshot({
|
||||||
'aliases': set({
|
'aliases': set({
|
||||||
@ -327,3 +374,55 @@
|
|||||||
'state': '80',
|
'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',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
Loading…
x
Reference in New Issue
Block a user