Page 1 of 1

pychromecast get device but not the status - Need help :(

Posted: Thursday 16 February 2017 21:01
by Thecyp31
Hello all !

So i tried to get the status of my chromecast with pychromecast.

I have a ubuntu server 16 with the latest version of pychomecast.


When i run this scripts (is under pychromecast folder) :

Code: Select all

from __future__ import print_function
import time
import sys
import logging
import json
import codecs
import urllib
import pychromecast

cast = pychromecast.Chromecast("192.168.xx.xx")

print(cast.device)
print(cast.status)
print(cast.media_controller.status)



i have this result :

Code: Select all

DeviceStatus(friendly_name=u'Salon', model_name=u'Eureka Dongle', manufacturer=u'Google Inc.', api_version=(1, 0), uuid=UUID('xx'), cast_type='cast')
None
<MediaStatus {'player_state': 'UNKNOWN', 'volume_level': 1, 'images': [], 'media_custom_data': {}, 'duration': None, 'current_time': 0, 'playback_rate': 1, 'title': None, 'media_session_id': None, 'volume_muted': False, 'supports_skip_forward': False, 'track': None, 'season': None, 'idle_reason': None, 'stream_type': 'UNKNOWN', 'supports_stream_mute': False, 'supports_stream_volume': False, 'content_type': None, 'metadata_type': None, 'subtitle_tracks': {}, 'album_name': None, 'series_title': None, 'album_artist': None, 'media_metadata': {}, 'episode': None, 'artist': None, 'supported_media_commands': 0, 'supports_seek': False, 'current_subtitle_tracks': [], 'content_id': None, 'supports_skip_backward': False, 'supports_pause': False}>

But i be have "player_state : Idle" and not UNKNOW.

I don't understand my probleme because the value of cast.status is good ! :(


Thanks !

Re: pychromecast get device but not the status - Need help :(

Posted: Monday 20 February 2017 20:04
by Thecyp31
Help ^^ :)

Re: pychromecast get device but not the status - Need help :(

Posted: Tuesday 21 March 2017 15:34
by Ewaldharmsen
what does it have for a value when you play youtube or netflix?

Re: pychromecast get device but not the status - Need help :(

Posted: Monday 03 April 2017 15:31
by triton
Don't know if this helps you. I've looked at pychomecast but wanted something simpler to get the casting state and discovered they use MDNS which also returns the current connected casting application. If you use a Raspberry pi install the avahi-utils and you can use:

Code: Select all

avahi-browse -rt _googlecast._tcp
which returns something like below for every Chromecast it can find on your network:

Code: Select all

+   eth0 IPv4 Chromecast-90580754da3ed1b3e4be38c9b277bc9b   _googlecast._tcp     local
=   eth0 IPv4 Chromecast-90580754da3ed1b3e4be38c9b277bc9b   _googlecast._tcp     local
   hostname = [90580754-da3e-d1b3-e4be-38c9b277bc9b.local]
   address = [192.x.x.x]
   port = [8009]
   txt = ["rs=Netflix" "bs=DE34FSD4WDS4" "st=0" "ca=4101" "fn=Chromecast_1" "ic=/setup/icon.png" "md=Chromecast" "ve=05" "rm=" "id=90580754da3ed1b3e4be38c9b277bc9b"]
If you look at the txt line you can see "rs=Netflix" Means Netflix is connected to the chromecast. It does not give me a state such as paused, playing etc. But this was all I wanted and you can write a wrapper script in any language that suits you best and feed Domoticz the info.

Hope it helps!