Skip to content

Commit

Permalink
Merge pull request #2 from hudsonbrendon/develop
Browse files Browse the repository at this point in the history
Corrige atualização da programação.
  • Loading branch information
hudsonbrendon authored Jun 23, 2021
2 parents 449e917 + ff54bc7 commit fd306a9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion custom_components/clarotv/manifest.json
Original file line number Diff line number Diff line change
@@ -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"],
Expand Down
17 changes: 8 additions & 9 deletions custom_components/clarotv/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
CONF_RESOURCES,
STATE_UNKNOWN,
)
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -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):
Expand All @@ -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
)

0 comments on commit fd306a9

Please sign in to comment.