From e2dbdcd66a89f48dcb75fd277693be259a1c5c27 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 5 Feb 2019 10:02:27 +0100 Subject: [PATCH] Parsing the right state attributes out of the Chromecast status --- platypush/plugins/media/chromecast.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/platypush/plugins/media/chromecast.py b/platypush/plugins/media/chromecast.py index bd38b878..1f8a1a5c 100644 --- a/platypush/plugins/media/chromecast.py +++ b/platypush/plugins/media/chromecast.py @@ -1,3 +1,4 @@ +import datetime import re import pychromecast @@ -295,10 +296,20 @@ class MediaChromecastPlugin(MediaPlugin): ret = {} for attr in attrs: + value = getattr(status, attr) + if attr == 'volume_level': + value *= 100 + if attr == 'player_state': + value = value.lower() + if value == 'paused': value = 'pause' + if value == 'playing': value = 'play' + if isinstance(value, datetime.datetime): + value = value.isoformat() + if attr in renamed_attrs: - ret[renamed_attrs[attr]] = getattr(status, attr) + ret[renamed_attrs[attr]] = value else: - ret[attr] = getattr(status, attr) + ret[attr] = value return ret