1 """Services for the Tado integration."""
5 import voluptuous
as vol
16 SERVICE_ADD_METER_READING,
19 _LOGGER = logging.getLogger(__name__)
20 SCHEMA_ADD_METER_READING = vol.Schema(
22 vol.Required(CONF_CONFIG_ENTRY): selector.ConfigEntrySelector(
24 "integration": DOMAIN,
27 vol.Required(CONF_READING): vol.Coerce(int),
34 """Set up the services for the Tado integration."""
36 async
def add_meter_reading(call: ServiceCall) ->
None:
37 """Send meter reading to Tado."""
38 entry_id: str = call.data[CONF_CONFIG_ENTRY]
39 reading: int = call.data[CONF_READING]
40 _LOGGER.debug(
"Add meter reading %s", reading)
42 entry = hass.config_entries.async_get_entry(entry_id)
46 tadoconnector = entry.runtime_data
48 response: dict = await hass.async_add_executor_job(
49 tadoconnector.set_meter_reading, call.data[CONF_READING]
52 if ATTR_MESSAGE
in response:
55 hass.services.async_register(
56 DOMAIN, SERVICE_ADD_METER_READING, add_meter_reading, SCHEMA_ADD_METER_READING
None setup_services(HomeAssistant hass)