'Getting connected/disconnected status from Chromecast Audio using PyChromecast
I'm trying to write a script to sense whether either of my two CC audios are disconnected, and if so, do some other stuff. I have tried a few different approaches, such as pinging the devices. The problem is, I can ping them even when I am unable to connect to them through Google Home.
So, I am trying to use PyChromecast. I've tried a few different functions within PyChromecast. The simplest one should be the one I have quoted below. However, I always get None, whether it's connected or not.
def chromcastTest():
castGarage = pychromecast.Chromecast("192.xxx.x.xx")
print(castGarage.status)
Output:
None
Solution 1:[1]
Try to get the chromecasts in the area with:
chromecasts = pychromecast.get_chromecasts()
Solution 2:[2]
You can check it in SocketClient object:
def chromcastTest():
castGarage = pychromecast.Chromecast("192.xxx.x.xx")
print(castGarage.socket_client.is_connected)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Merunas Grincalaitis |
| Solution 2 | Pablo Chinea |
