1 """Support for OpenERZ API for Zurich city waste disposal system."""
3 from __future__
import annotations
5 from datetime
import timedelta
7 from openerz_api.main
import OpenERZConnector
8 import voluptuous
as vol
11 PLATFORM_SCHEMA
as SENSOR_PLATFORM_SCHEMA,
22 CONF_WASTE_TYPE =
"waste_type"
25 PLATFORM_SCHEMA = SENSOR_PLATFORM_SCHEMA.extend(
27 vol.Required(CONF_ZIP): cv.positive_int,
28 vol.Required(CONF_WASTE_TYPE, default=
"waste"): cv.string,
29 vol.Optional(CONF_NAME): cv.string,
37 add_entities: AddEntitiesCallback,
38 discovery_info: DiscoveryInfoType |
None =
None,
40 """Set up the sensor platform."""
41 api_connector = OpenERZConnector(config[CONF_ZIP], config[CONF_WASTE_TYPE])
46 """Representation of a Sensor."""
49 """Initialize the sensor."""
56 """Return the name of the sensor."""
57 return self.
_name_name
61 """Return the state of the sensor."""
65 """Fetch new state data for the sensor.
67 This is the only method that should fetch new data for Home Assistant.
def __init__(self, api_connector, name)
def add_entities(account, async_add_entities, tracked)
None setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback add_entities, DiscoveryInfoType|None discovery_info=None)