From ff54bc75e224628a487cb594f4e354fd35c7ea7e Mon Sep 17 00:00:00 2001 From: Hudson Brendon Date: Wed, 23 Jun 2021 05:04:56 +0000 Subject: [PATCH] =?UTF-8?q?Corrige=20atualiza=C3=A7=C3=A3o=20da=20programa?= =?UTF-8?q?=C3=A7=C3=A3o.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/clarotv/manifest.json | 2 +- custom_components/clarotv/sensor.py | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/custom_components/clarotv/manifest.json b/custom_components/clarotv/manifest.json index b36beb7..4e4756c 100644 --- a/custom_components/clarotv/manifest.json +++ b/custom_components/clarotv/manifest.json @@ -1,7 +1,7 @@ { "domain": "clarotv", "name": "Claro TV", - "version": "0.3.4", + "version": "0.3.5", "documentation": "https://github.com/hudsonbrendon/sensor.claro.com.br", "dependencies": [], "codeowners": ["@hudsonbrendon"], diff --git a/custom_components/clarotv/sensor.py b/custom_components/clarotv/sensor.py index e7f173c..6788d25 100755 --- a/custom_components/clarotv/sensor.py +++ b/custom_components/clarotv/sensor.py @@ -16,6 +16,7 @@ CONF_RESOURCES, STATE_UNKNOWN, ) +from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) @@ -101,16 +102,17 @@ def setup_platform(hass, config, add_entities, discovery_info=None): ) -class ClaroTVSensor(SensorEntity): +class ClaroTVSensor(Entity): def __init__(self, hass, name, channel_id, channel_name, channel_logo, interval): """Inizialize sensor""" self._state = STATE_UNKNOWN self._hass = hass - self.interval = interval + self._interval = interval self._channel_id = channel_id self._channel_name = channel_name self._channel_logo = channel_logo self._name = name + self._programations = {} @property def name(self): @@ -128,16 +130,13 @@ def state(self): now = datetime.now(pytz.timezone("America/Sao_Paulo")) return now.strftime("%d-%m-%Y %H:%M:%S") - @property - def extra_state_attributes(self): - """Return the state attributes of the sensor.""" - return {ATTR_ATTRIBUTION: ATTRIBUTION} - @property def device_state_attributes(self): """Attributes.""" - return {"data": Throttle(self.interval)(self.update)} + return {"data": self._programations} def update(self): """Get the latest update fron the api""" - return get_data(self._channel_id, self._channel_name, self._channel_logo) + self._programations = get_data( + self._channel_id, self._channel_name, self._channel_logo + )