1 """Support for monitoring a Smappee appliance binary sensor."""
3 from __future__
import annotations
6 BinarySensorDeviceClass,
13 from .
import SmappeeConfigEntry
14 from .const
import DOMAIN
16 BINARY_SENSOR_PREFIX =
"Appliance"
17 PRESENCE_PREFIX =
"Presence"
20 "Car Charger":
"mdi:car",
21 "Coffeemaker":
"mdi:coffee",
22 "Clothes Dryer":
"mdi:tumble-dryer",
23 "Clothes Iron":
"mdi:hanger",
24 "Dishwasher":
"mdi:dishwasher",
25 "Lights":
"mdi:lightbulb",
27 "Freezer":
"mdi:fridge",
28 "Microwave":
"mdi:microwave",
30 "Refrigerator":
"mdi:fridge",
32 "Washing Machine":
"mdi:washing-machine",
33 "Water Pump":
"mdi:water-pump",
39 config_entry: SmappeeConfigEntry,
40 async_add_entities: AddEntitiesCallback,
42 """Set up the Smappee binary sensor."""
43 smappee_base = config_entry.runtime_data
45 entities: list[BinarySensorEntity] = []
46 for service_location
in smappee_base.smappee.service_locations.values():
47 for appliance_id, appliance
in service_location.appliances.items():
48 if appliance.type !=
"Find me" and appliance.source_type ==
"NILM":
51 smappee_base=smappee_base,
52 service_location=service_location,
53 appliance_id=appliance_id,
54 appliance_name=appliance.name,
55 appliance_type=appliance.type,
59 if not smappee_base.smappee.local_polling:
67 """Implementation of a Smappee presence binary sensor."""
69 _attr_device_class = BinarySensorDeviceClass.PRESENCE
71 def __init__(self, smappee_base, service_location):
72 """Initialize the Smappee sensor."""
76 f
"{service_location.service_location_name} - {PRESENCE_PREFIX}"
79 f
"{service_location.device_serial_number}-"
80 f
"{service_location.service_location_id}-"
81 f
"{BinarySensorDeviceClass.PRESENCE}"
84 identifiers={(DOMAIN, service_location.device_serial_number)},
85 manufacturer=
"Smappee",
86 model=service_location.device_model,
87 name=service_location.service_location_name,
88 sw_version=service_location.firmware_version,
92 """Get the latest data from Smappee and update the state."""
99 """Implementation of a Smappee binary sensor."""
109 """Initialize the Smappee sensor."""
114 f
"{service_location.service_location_name} - "
115 f
"{BINARY_SENSOR_PREFIX} - "
116 f
"{appliance_name if appliance_name != '' else appliance_type}"
119 f
"{service_location.device_serial_number}-"
120 f
"{service_location.service_location_id}-"
121 f
"appliance-{appliance_id}"
124 identifiers={(DOMAIN, service_location.device_serial_number)},
125 manufacturer=
"Smappee",
126 model=service_location.device_model,
127 name=service_location.service_location_name,
128 sw_version=service_location.firmware_version,
133 """Get the latest data from Smappee and update the state."""
def __init__(self, smappee_base, service_location, appliance_id, appliance_name, appliance_type)
def __init__(self, smappee_base, service_location)
None async_setup_entry(HomeAssistant hass, SmappeeConfigEntry config_entry, AddEntitiesCallback async_add_entities)