Chromecast status
Moderators: leecollings, remb0
-
- Posts: 26
- Joined: Monday 15 July 2013 8:17
- Target OS: Linux
- Domoticz version: Beta
- Location: Drenthe
- Contact:
Chromecast status
The Chromecast status can be retrieved in JSON (see http://fiquett.com/2013/07/chromecast-traffic-sniffing/). Would it be possible to add the Chromecast to Domoticz so we can use the status in events ?
-
- Posts: 625
- Joined: Thursday 02 October 2014 6:36
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Location: Geleen
- Contact:
Re: Chromecast status
Hm I have a chromecast. Why would you want to see the chromecast status?
-
- Posts: 26
- Joined: Monday 15 July 2013 8:17
- Target OS: Linux
- Domoticz version: Beta
- Location: Drenthe
- Contact:
Re: Chromecast status
To use it in Events. Example: Domoticz turns the lights off when it's past 23:00 AND no one is watching TV (Mediacenter virual switch). And: because we can
- Siewert308SW
- Posts: 288
- Joined: Monday 29 December 2014 15:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: The Netherlands
- Contact:
Re: Chromecast status
Already done this by using the Network presence detection.piotr wrote:To use it in Events. Example: Domoticz turns the lights off when it's past 23:00 AND no one is watching TV (Mediacenter virual switch). And: because we can
Dim lights when Chromcast/TV is on and brighten them when Chromcast/TV is off.
Or when nobody is home for more then 1hr and Chromecast/TV is off then switch OFF TV standby killer (KaKu unit)
Setup:
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
-
- Posts: 625
- Joined: Thursday 02 October 2014 6:36
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Location: Geleen
- Contact:
Re: Chromecast status
ok, your tv has not network connection? That would make sense.
- Siewert308SW
- Posts: 288
- Joined: Monday 29 December 2014 15:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: The Netherlands
- Contact:
Re: Chromecast status
Indeed, my TV doesn't have network connection and there for the Chromecast solves that issuejan_nl wrote:ok, your tv has not network connection? That would make sense.
Setup:
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
-
- Posts: 135
- Joined: Monday 27 January 2014 14:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Netherlands
- Contact:
Re: Chromecast status
Does someone know if it's possible to start a stream through Chromecast (audio) via Domoticz?
Raspberry Pi Type B
Raspberry Pi Type B2
RFXCOMtrx433e
Raspberry Pi Type B2
RFXCOMtrx433e
-
- Posts: 27
- Joined: Monday 13 April 2015 23:19
- Target OS: NAS (Synology & others)
- Domoticz version: 3.5033
- Location: Amsterdam, The Netherlands
- Contact:
Re: Chromecast status
I don't know it but this repository was posted in the tweakers domoticz topic last week by user zeu: https://github.com/balloob/pychromecastHeisenberg wrote:Does someone know if it's possible to start a stream through Chromecast (audio) via Domoticz?
He has created a simple web interface himself to use with it and put it here: https://github.com/roberthorlings/chromecast-web maybe you can use these repositories to create your wanted situation.
-
- Posts: 19
- Joined: Tuesday 19 January 2016 10:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2.4608
- Location: 's-Hertogenbosch
- Contact:
Re: Chromecast status
I'll give it a try Sunday, or maybe tonight.wmn79 wrote:I don't know it but this repository was posted in the tweakers domoticz topic last week by user zeu: https://github.com/balloob/pychromecastHeisenberg wrote:Does someone know if it's possible to start a stream through Chromecast (audio) via Domoticz?
He has created a simple web interface himself to use with it and put it here: https://github.com/roberthorlings/chromecast-web maybe you can use these repositories to create your wanted situation.
RPi Model 2: Domoticz Server (Beta)
RPi Model B+: Smart Meter Slave (Stable)
Particle Photon (2x): Prototyping, Controlling LEDS and gathering Sensor data for Domoticz
Arduino Uno R3: with CC2500 Shield for Philips LivingColor Lights 1st Gen.
RPi Model B+: Smart Meter Slave (Stable)
Particle Photon (2x): Prototyping, Controlling LEDS and gathering Sensor data for Domoticz
Arduino Uno R3: with CC2500 Shield for Philips LivingColor Lights 1st Gen.
-
- Posts: 7
- Joined: Thursday 11 June 2015 13:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2.2480
- Location: Denmark
- Contact:
Re: Chromecast status
Another possible scenario is, that when you start playback on chromecast it could dim down the lights automatically, and if the playback is paused, it could turn up the lights to normal levels..
Right now I have almost accomplished this, with pychromecast reporting into domoticz, and setting a dummy light switch according to play state. Works for most casts. Except netflix, it doesn't report back pause events (only play events, even when returning from pause state).
Right now I don't have any lights connected to domoticz (have it planned though). So I'm not pursuing netflix support actively at the moment. But I'm in the planning state of installing controllable led strips.
Right now I have almost accomplished this, with pychromecast reporting into domoticz, and setting a dummy light switch according to play state. Works for most casts. Except netflix, it doesn't report back pause events (only play events, even when returning from pause state).
Right now I don't have any lights connected to domoticz (have it planned though). So I'm not pursuing netflix support actively at the moment. But I'm in the planning state of installing controllable led strips.
Mysensors HW developer / hacker.
Creator of Sensebender Micro temperature / humidity sensor
Creator of Sensebender Micro temperature / humidity sensor
-
- Posts: 19
- Joined: Tuesday 19 January 2016 10:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2.4608
- Location: 's-Hertogenbosch
- Contact:
Re: Chromecast status
Do you have an example script?tbowmo wrote:Another possible scenario is, that when you start playback on chromecast it could dim down the lights automatically, and if the playback is paused, it could turn up the lights to normal levels..
RPi Model 2: Domoticz Server (Beta)
RPi Model B+: Smart Meter Slave (Stable)
Particle Photon (2x): Prototyping, Controlling LEDS and gathering Sensor data for Domoticz
Arduino Uno R3: with CC2500 Shield for Philips LivingColor Lights 1st Gen.
RPi Model B+: Smart Meter Slave (Stable)
Particle Photon (2x): Prototyping, Controlling LEDS and gathering Sensor data for Domoticz
Arduino Uno R3: with CC2500 Shield for Philips LivingColor Lights 1st Gen.
-
- Posts: 7
- Joined: Thursday 11 June 2015 13:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2.2480
- Location: Denmark
- Contact:
Re: Chromecast status
downloaded pychromecast from github https://github.com/balloob/pychromecast
and then using the following python script
It's a draft and seems to work.. Setting a virtual switch on / off, according to the playing state. And also populates a uservariable with the current state.
I don't have any lights connected, so haven't checked how well this works.. (The lights are in development..)
and then using the following python script
Code: Select all
from __future__ import print_function
import time
import sys
import logging
import json
import codecs
from urllib.request import urlopen
from urllib.parse import urlencode
import pychromecast
import pychromecast.controllers.youtube as youtube
domoticz = "http://localhost:8080"
if '--show-debug' in sys.argv:
logging.basicConfig(level=logging.DEBUG)
cast = pychromecast.get_chromecast()
class mediaListener:
domurl="http://localhost:8080"
device=20
def __init__(self, domoticzurl, deviceno):
self.domurl = domoticzurl
self.device=deviceno
self.oldPlayerStatus = 'NONE'
def new_media_status(self, status):
print("mediaListener")
print(status)
if (self.oldPlayerStatus != status.player_state):
self.oldPlayerStatus = status.player_state
if status.player_state == "PLAYING" or status.player_state == "BUFFERING":
data = urlopen(self.domurl+"/json.htm?type=command¶m=switchlight&idx="+self.device+"&switchcmd=on")
else :
data = urlopen(self.domurl+"/json.htm?type=command¶m=switchlight&idx="+self.device+"&switchcmd=off")
self.storeVariable('ChromeState', new_state)
def storeVariable(self,name, value):
value = urlencode({'vvalue':value, 'vname':name, 'vtype':2})
d = urlopen(self.domurl+'/json.htm?type=command¶m=updateuservariable&'+value)
reader = codecs.getreader("utf-8")
obj = json.load(reader(d))
if (obj['status'] == 'ERR'):
d = urlopen(self.domurl+'/json.htm?type=command¶m=saveuservariable&'+value)
listener = mediaListener(domoticz, 106)
cast.media_controller.register_status_listener(listener)
while (1):
pass
I don't have any lights connected, so haven't checked how well this works.. (The lights are in development..)
Mysensors HW developer / hacker.
Creator of Sensebender Micro temperature / humidity sensor
Creator of Sensebender Micro temperature / humidity sensor
- Varazir
- Posts: 360
- Joined: Friday 20 February 2015 22:23
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Contact:
Re: Chromecast status
Are you running on a raspberry pi? Looks like I have python 2.7 on my Pi and the script is made for 3 right ?tbowmo wrote:downloaded pychromecast from github https://github.com/balloob/pychromecast
and then using the following python script
It's a draft and seems to work.. Setting a virtual switch on / off, according to the playing state. And also populates a uservariable with the current state.Code: Select all
from __future__ import print_function import time import sys import logging import json import codecs from urllib.request import urlopen from urllib.parse import urlencode import pychromecast import pychromecast.controllers.youtube as youtube domoticz = "http://localhost:8080" if '--show-debug' in sys.argv: logging.basicConfig(level=logging.DEBUG) cast = pychromecast.get_chromecast() class mediaListener: domurl="http://localhost:8080" device=20 def __init__(self, domoticzurl, deviceno): self.domurl = domoticzurl self.device=deviceno self.oldPlayerStatus = 'NONE' def new_media_status(self, status): print("mediaListener") print(status) if (self.oldPlayerStatus != status.player_state): self.oldPlayerStatus = status.player_state if status.player_state == "PLAYING" or status.player_state == "BUFFERING": data = urlopen(self.domurl+"/json.htm?type=command¶m=switchlight&idx="+self.device+"&switchcmd=on") else : data = urlopen(self.domurl+"/json.htm?type=command¶m=switchlight&idx="+self.device+"&switchcmd=off") self.storeVariable('ChromeState', new_state) def storeVariable(self,name, value): value = urlencode({'vvalue':value, 'vname':name, 'vtype':2}) d = urlopen(self.domurl+'/json.htm?type=command¶m=updateuservariable&'+value) reader = codecs.getreader("utf-8") obj = json.load(reader(d)) if (obj['status'] == 'ERR'): d = urlopen(self.domurl+'/json.htm?type=command¶m=saveuservariable&'+value) listener = mediaListener(domoticz, 106) cast.media_controller.register_status_listener(listener) while (1): pass
I don't have any lights connected, so haven't checked how well this works.. (The lights are in development..)
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
Several IKEA devices/z-wave devices
-
- Posts: 19
- Joined: Tuesday 19 January 2016 10:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2.4608
- Location: 's-Hertogenbosch
- Contact:
Re: Chromecast status
I ChangedVarazir wrote:Are you running on a raspberry pi? Looks like I have python 2.7 on my Pi and the script is made for 3 right ?tbowmo wrote:downloaded pychromecast from github https://github.com/balloob/pychromecast
and then using the following python script
It's a draft and seems to work.. Setting a virtual switch on / off, according to the playing state. And also populates a uservariable with the current state.Code: Select all
from __future__ import print_function import time import sys import logging import json import codecs from urllib.request import urlopen from urllib.parse import urlencode import pychromecast import pychromecast.controllers.youtube as youtube domoticz = "http://localhost:8080" if '--show-debug' in sys.argv: logging.basicConfig(level=logging.DEBUG) cast = pychromecast.get_chromecast() class mediaListener: domurl="http://localhost:8080" device=20 def __init__(self, domoticzurl, deviceno): self.domurl = domoticzurl self.device=deviceno self.oldPlayerStatus = 'NONE' def new_media_status(self, status): print("mediaListener") print(status) if (self.oldPlayerStatus != status.player_state): self.oldPlayerStatus = status.player_state if status.player_state == "PLAYING" or status.player_state == "BUFFERING": data = urlopen(self.domurl+"/json.htm?type=command¶m=switchlight&idx="+self.device+"&switchcmd=on") else : data = urlopen(self.domurl+"/json.htm?type=command¶m=switchlight&idx="+self.device+"&switchcmd=off") self.storeVariable('ChromeState', new_state) def storeVariable(self,name, value): value = urlencode({'vvalue':value, 'vname':name, 'vtype':2}) d = urlopen(self.domurl+'/json.htm?type=command¶m=updateuservariable&'+value) reader = codecs.getreader("utf-8") obj = json.load(reader(d)) if (obj['status'] == 'ERR'): d = urlopen(self.domurl+'/json.htm?type=command¶m=saveuservariable&'+value) listener = mediaListener(domoticz, 106) cast.media_controller.register_status_listener(listener) while (1): pass
I don't have any lights connected, so haven't checked how well this works.. (The lights are in development..)
Code: Select all
from urllib.request import urlopen
from urllib.parse import urlencode
Code: Select all
import urllib
RPi Model 2: Domoticz Server (Beta)
RPi Model B+: Smart Meter Slave (Stable)
Particle Photon (2x): Prototyping, Controlling LEDS and gathering Sensor data for Domoticz
Arduino Uno R3: with CC2500 Shield for Philips LivingColor Lights 1st Gen.
RPi Model B+: Smart Meter Slave (Stable)
Particle Photon (2x): Prototyping, Controlling LEDS and gathering Sensor data for Domoticz
Arduino Uno R3: with CC2500 Shield for Philips LivingColor Lights 1st Gen.
- Varazir
- Posts: 360
- Joined: Friday 20 February 2015 22:23
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Contact:
Re: Chromecast status
Got one more step forward.daandamhuis wrote:
I Changedto and now it works with Python 2.7Code: Select all
from urllib.request import urlopen from urllib.parse import urlencode
Code: Select all
import urllib
I guess I have to do something more as it's not finding the
Code: Select all
Traceback (most recent call last):
File "chromecast.py", line 10, in <module>
import pychromecast
ImportError: No module named pychromecast
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
Several IKEA devices/z-wave devices
-
- Posts: 19
- Joined: Tuesday 19 January 2016 10:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2.4608
- Location: 's-Hertogenbosch
- Contact:
Re: Chromecast status
Did you place the Python script inside the Pychromecast folder? That did the trick for me.
RPi Model 2: Domoticz Server (Beta)
RPi Model B+: Smart Meter Slave (Stable)
Particle Photon (2x): Prototyping, Controlling LEDS and gathering Sensor data for Domoticz
Arduino Uno R3: with CC2500 Shield for Philips LivingColor Lights 1st Gen.
RPi Model B+: Smart Meter Slave (Stable)
Particle Photon (2x): Prototyping, Controlling LEDS and gathering Sensor data for Domoticz
Arduino Uno R3: with CC2500 Shield for Philips LivingColor Lights 1st Gen.
- Varazir
- Posts: 360
- Joined: Friday 20 February 2015 22:23
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Contact:
Re: Chromecast status
I got it to work sort of:daandamhuis wrote:Did you place the Python script inside the Pychromecast folder? That did the trick for me.
Code: Select all
~/pychromecast $ python chromecast.py
mediaListener
<MediaStatus {'player_state': u'PLAYING', 'volume_level': 1, 'images': [], 'media_custom_data': {}, 'duration': 2546, 'current_time': 841.182, 'playback_rate': 1, 'title': None, 'media_session_id': 1, 'volume_muted': False, 'supports_skip_forward': False, 'track': None, 'season': None, 'idle_reason': None, 'stream_type': u'BUFFERED', 'supports_stream_mute': False, 'supports_stream_volume': False, 'content_type': u'video/mp4', 'metadata_type': None, 'subtitle_tracks': {}, 'album_name': None, 'series_title': None, 'album_artist': None, 'media_metadata': {}, 'episode': None, 'artist': None, 'supported_media_commands': 1, 'supports_seek': False, 'content_id': u'http://dummy', 'supports_skip_backward': False, 'supports_pause': True}>
I changed this in the script
Code: Select all
domoticz = "http://localhost:80"
domurl="http://localhost:80"
device=33
Edit: I saw that the script is maxing out the CPU
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
Several IKEA devices/z-wave devices
-
- Posts: 7
- Joined: Thursday 11 June 2015 13:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2.2480
- Location: Denmark
- Contact:
Re: Chromecast status
I'm not here on this forum that often..
Anyway, it's a work in progress. Running on a pi2, so don't notice that one core is maxed out by the script. But yes dome kind of wait loop should be made instead of the current while loop, so it doesn't use max cpu.
And yes I'm using it with python3. I have both python 2.7 and 3.4 installed.
Anyway, it's a work in progress. Running on a pi2, so don't notice that one core is maxed out by the script. But yes dome kind of wait loop should be made instead of the current while loop, so it doesn't use max cpu.
And yes I'm using it with python3. I have both python 2.7 and 3.4 installed.
Mysensors HW developer / hacker.
Creator of Sensebender Micro temperature / humidity sensor
Creator of Sensebender Micro temperature / humidity sensor
-
- Posts: 135
- Joined: Monday 27 January 2014 14:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Netherlands
- Contact:
Re: Chromecast status
I installed pychromecast but cannot seem to find the folder. Do I really need to put the python script inside this folder to run?
Raspberry Pi Type B
Raspberry Pi Type B2
RFXCOMtrx433e
Raspberry Pi Type B2
RFXCOMtrx433e
-
- Posts: 7
- Joined: Sunday 11 December 2016 9:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Chromecast status
Im trying to get this working.
But i am keeping getting this error
Im not a python programmer. I can read code but im not good at wrtiting.
So if you could give me a hint that would be very helpfull
(using raspberry pi2 and python 2).
But i am keeping getting this error
Code: Select all
Traceback (most recent call last):
File "D:\Domoticz\Scripts\PyChromecast\ChromeStatus.py", line 49, in <module>
cast.media_controller.register_status_listener(listener)
AttributeError: 'NoneType' object has no attribute 'media_controller'
So if you could give me a hint that would be very helpfull
(using raspberry pi2 and python 2).
Who is online
Users browsing this forum: No registered users and 1 guest