Skip to content

Commit

Permalink
Fix sensor for 0.113
Browse files Browse the repository at this point in the history
  • Loading branch information
fondberg committed Jul 23, 2020
1 parent 83d3653 commit 77afb63
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion custom_components/spotcast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import homeassistant.helpers.config_validation as cv
from homeassistant.components.cast.media_player import KNOWN_CHROMECAST_INFO_KEY

__VERSION__ = "3.3.4"
__VERSION__ = "3.3.5"
DOMAIN = "spotcast"

_LOGGER = logging.getLogger(__name__)
Expand Down
5 changes: 2 additions & 3 deletions custom_components/spotcast/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
"requirements": [
"spotify_token==1.0.0"
],
"homeassistant": "0.111.0",
"homeassistant": "0.113.0",
"dependencies": [
],
"codeowners": [
"@fondberg",
"@kleinc80"
"@fondberg"
]
}
24 changes: 14 additions & 10 deletions custom_components/spotcast/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

_LOGGER = logging.getLogger(__name__)

SENSOR_SCAN_INTERVAL_SECS = 60
SENSOR_SCAN_INTERVAL_SECS = 180
SCAN_INTERVAL = timedelta(seconds=SENSOR_SCAN_INTERVAL_SECS)


Expand Down Expand Up @@ -45,19 +45,23 @@ def update(self):
# from cast/media_player.py but is missing cast_type
# KNOWN_CHROMECAST_INFO_KEY = 'cast_known_chromecasts'
# _LOGGER.info('KNOWN_CHROMECAST_INFO_KEY: %s', self.hass.data[KNOWN_CHROMECAST_INFO_KEY])
_LOGGER.info('getting chromecast devices')

self._chromecast_devices = pychromecast.get_chromecasts()
_LOGGER.debug('Found chromecast devices: %s', self._chromecast_devices)
chromecasts = []
for cast in self._chromecast_devices:
device = {
'name': cast.name,
'cast_type': cast.cast_type,
'model_name': cast.model_name,
'uuid': str(cast.uuid),
'manufacturer': cast.device.manufacturer
}
chromecasts.append(device)
for casts in self._chromecast_devices:
if type(casts) == list:
for cast in casts:
_LOGGER.info("NIKLAS: %s %s", type(cast), cast.device)
device = {
'name': cast.device.friendly_name,
'cast_type': cast.cast_type,
'model_name': cast.model_name,
'uuid': str(cast.uuid),
'manufacturer': cast.device.manufacturer
}
chromecasts.append(device)
self._attributes['devices_json'] = json.dumps(chromecasts, ensure_ascii=False)
self._attributes['devices'] = chromecasts
self._attributes['last_update'] = dt.now().isoformat('T')
Expand Down

0 comments on commit 77afb63

Please sign in to comment.