1 """Support for Blue Current sensors."""
3 from __future__
import annotations
8 SensorEntityDescription,
13 UnitOfElectricCurrent,
14 UnitOfElectricPotential,
21 from .
import BlueCurrentConfigEntry, Connector
22 from .const
import DOMAIN
23 from .entity
import BlueCurrentEntity, ChargepointEntity
28 native_unit_of_measurement=UnitOfElectricPotential.VOLT,
29 device_class=SensorDeviceClass.VOLTAGE,
30 translation_key=
"actual_v1",
31 entity_registry_enabled_default=
False,
32 state_class=SensorStateClass.MEASUREMENT,
36 native_unit_of_measurement=UnitOfElectricPotential.VOLT,
37 device_class=SensorDeviceClass.VOLTAGE,
38 translation_key=
"actual_v2",
39 entity_registry_enabled_default=
False,
40 state_class=SensorStateClass.MEASUREMENT,
44 native_unit_of_measurement=UnitOfElectricPotential.VOLT,
45 device_class=SensorDeviceClass.VOLTAGE,
46 translation_key=
"actual_v3",
47 entity_registry_enabled_default=
False,
48 state_class=SensorStateClass.MEASUREMENT,
52 native_unit_of_measurement=UnitOfElectricPotential.VOLT,
53 device_class=SensorDeviceClass.VOLTAGE,
54 translation_key=
"avg_voltage",
55 state_class=SensorStateClass.MEASUREMENT,
59 native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
60 device_class=SensorDeviceClass.CURRENT,
61 translation_key=
"actual_p1",
62 entity_registry_enabled_default=
False,
63 state_class=SensorStateClass.MEASUREMENT,
67 native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
68 device_class=SensorDeviceClass.CURRENT,
69 translation_key=
"actual_p2",
70 entity_registry_enabled_default=
False,
71 state_class=SensorStateClass.MEASUREMENT,
75 native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
76 device_class=SensorDeviceClass.CURRENT,
77 translation_key=
"actual_p3",
78 entity_registry_enabled_default=
False,
79 state_class=SensorStateClass.MEASUREMENT,
83 native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
84 device_class=SensorDeviceClass.CURRENT,
85 translation_key=
"avg_current",
86 state_class=SensorStateClass.MEASUREMENT,
90 native_unit_of_measurement=UnitOfPower.KILO_WATT,
91 device_class=SensorDeviceClass.POWER,
92 translation_key=
"total_kw",
93 state_class=SensorStateClass.MEASUREMENT,
97 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
98 device_class=SensorDeviceClass.ENERGY,
99 translation_key=
"actual_kwh",
100 state_class=SensorStateClass.TOTAL_INCREASING,
104 native_unit_of_measurement=CURRENCY_EURO,
105 device_class=SensorDeviceClass.MONETARY,
106 translation_key=
"total_cost",
109 key=
"vehicle_status",
110 device_class=SensorDeviceClass.ENUM,
111 options=[
"standby",
"vehicle_detected",
"ready",
"no_power",
"vehicle_error"],
112 translation_key=
"vehicle_status",
116 device_class=SensorDeviceClass.ENUM,
117 options=[
"available",
"charging",
"unavailable",
"error",
"offline"],
118 translation_key=
"activity",
122 translation_key=
"max_usage",
123 native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
124 device_class=SensorDeviceClass.CURRENT,
125 state_class=SensorStateClass.MEASUREMENT,
128 key=
"smartcharging_max_usage",
129 translation_key=
"smartcharging_max_usage",
130 native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
131 entity_registry_enabled_default=
False,
132 device_class=SensorDeviceClass.CURRENT,
133 state_class=SensorStateClass.MEASUREMENT,
137 translation_key=
"max_offline",
138 native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
139 entity_registry_enabled_default=
False,
140 device_class=SensorDeviceClass.CURRENT,
141 state_class=SensorStateClass.MEASUREMENT,
145 translation_key=
"current_left",
146 native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
147 entity_registry_enabled_default=
False,
148 device_class=SensorDeviceClass.CURRENT,
149 state_class=SensorStateClass.MEASUREMENT,
153 TIMESTAMP_SENSORS = (
155 key=
"start_datetime",
156 translation_key=
"start_datetime",
160 translation_key=
"stop_datetime",
164 translation_key=
"offline_since",
170 key=
"grid_actual_p1",
171 native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
172 device_class=SensorDeviceClass.CURRENT,
173 translation_key=
"grid_actual_p1",
174 entity_registry_enabled_default=
False,
175 state_class=SensorStateClass.MEASUREMENT,
178 key=
"grid_actual_p2",
179 native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
180 device_class=SensorDeviceClass.CURRENT,
181 translation_key=
"grid_actual_p2",
182 entity_registry_enabled_default=
False,
183 state_class=SensorStateClass.MEASUREMENT,
186 key=
"grid_actual_p3",
187 native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
188 device_class=SensorDeviceClass.CURRENT,
189 translation_key=
"grid_actual_p3",
190 entity_registry_enabled_default=
False,
191 state_class=SensorStateClass.MEASUREMENT,
194 key=
"grid_avg_current",
195 native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
196 device_class=SensorDeviceClass.CURRENT,
197 translation_key=
"grid_avg_current",
198 state_class=SensorStateClass.MEASUREMENT,
201 key=
"grid_max_current",
202 native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
203 device_class=SensorDeviceClass.CURRENT,
204 translation_key=
"grid_max_current",
205 state_class=SensorStateClass.MEASUREMENT,
214 entry: BlueCurrentConfigEntry,
215 async_add_entities: AddEntitiesCallback,
217 """Set up Blue Current sensors."""
218 connector = entry.runtime_data
219 sensor_list: list[SensorEntity] = [
221 for evse_id
in connector.charge_points
222 for sensor
in SENSORS
228 for evse_id
in connector.charge_points
229 for sensor
in TIMESTAMP_SENSORS
233 sensor_list.extend(
GridSensor(connector, sensor)
for sensor
in GRID_SENSORS)
239 """Define a charge point sensor."""
243 connector: Connector,
244 sensor: SensorEntityDescription,
247 """Initialize the sensor."""
248 super().
__init__(connector, evse_id)
256 """Update the sensor from the latest data."""
260 if new_value
is not None:
269 """Define a timestamp sensor."""
271 _attr_device_class = SensorDeviceClass.TIMESTAMP
275 """Update the sensor from the latest data."""
279 if new_value
is not None and (
287 """Define a grid sensor."""
291 connector: Connector,
292 sensor: SensorEntityDescription,
294 """Initialize the sensor."""
295 super().
__init__(connector, f
"{DOMAIN}_grid_update")
303 """Update the grid sensor from the latest data."""
305 new_value = self.
connectorconnector.grid.get(self.
keykey)
307 if new_value
is not None:
None update_from_latest_data(self)
None __init__(self, Connector connector, SensorEntityDescription sensor, str evse_id)
None update_from_latest_data(self)
None update_from_latest_data(self)
None __init__(self, Connector connector, SensorEntityDescription sensor)
None async_setup_entry(HomeAssistant hass, BlueCurrentConfigEntry entry, AddEntitiesCallback async_add_entities)
web.Response get(self, web.Request request, str config_key)