Ejemplo n.º 1
0
    def del_service_data(self, addon: Addon) -> None:
        """Remove the data from service object."""
        if not self.enabled:
            _LOGGER.warning("Can't remove not exists services")
            raise ServicesError()

        self._data.clear()
        self.save()
Ejemplo n.º 2
0
    def set_service_data(self, addon: Addon, data: Dict[str, Any]) -> None:
        """Write the data into service object."""
        if self.enabled:
            _LOGGER.error("It is already a MQTT in use from %s",
                          self._data[ATTR_ADDON])
            raise ServicesError()

        self._data.update(data)
        self._data[ATTR_ADDON] = addon.slug

        _LOGGER.info("Set %s as service provider for mqtt", addon.slug)
        self.save()