1 """Amber Electric Binary Sensor definitions."""
3 from __future__
import annotations
9 BinarySensorEntityDescription,
15 from .
import AmberConfigEntry
16 from .const
import ATTRIBUTION
17 from .coordinator
import AmberUpdateCoordinator
20 "none":
"mdi:power-plug",
21 "potential":
"mdi:power-plug-outline",
22 "spike":
"mdi:power-plug-off",
27 CoordinatorEntity[AmberUpdateCoordinator], BinarySensorEntity
29 """Sensor to show single grid binary values."""
31 _attr_attribution = ATTRIBUTION
35 coordinator: AmberUpdateCoordinator,
36 description: BinarySensorEntityDescription,
38 """Initialize the Sensor."""
46 """Return true if the binary sensor is on."""
51 """Sensor to show single grid binary values."""
55 """Return the sensor icon."""
56 status = self.coordinator.data[
"grid"][
"price_spike"]
57 return PRICE_SPIKE_ICONS[status]
61 """Return true if the binary sensor is on."""
62 return self.coordinator.data[
"grid"][
"price_spike"] ==
"spike"
66 """Return additional pieces of information about the price spike."""
68 spike_status = self.coordinator.data[
"grid"][
"price_spike"]
70 "spike_status": spike_status,
75 """Sensor to show whether demand window is active."""
79 """Return true if the binary sensor is on."""
80 grid = self.coordinator.data[
"grid"]
81 if "demand_window" in grid:
82 return grid[
"demand_window"]
88 entry: AmberConfigEntry,
89 async_add_entities: AddEntitiesCallback,
91 """Set up a config entry."""
92 coordinator = entry.runtime_data
96 name=f
"{entry.title} - Price Spike",
100 name=f
"{entry.title} - Demand Window",
101 translation_key=
"demand_window",
None __init__(self, AmberUpdateCoordinator coordinator, BinarySensorEntityDescription description)
dict[str, Any] extra_state_attributes(self)
None async_setup_entry(HomeAssistant hass, AmberConfigEntry entry, AddEntitiesCallback async_add_entities)