Skip to content

Instantly share code, notes, and snippets.

@leroix
Created May 4, 2015 21:59
Show Gist options
  • Save leroix/60fba542c5f8b4e32229 to your computer and use it in GitHub Desktop.
Save leroix/60fba542c5f8b4e32229 to your computer and use it in GitHub Desktop.
Getting and setting the chromecast volume
#! /usr/bin/env python
import sys
import time
import pychromecast
requested_volume = float(sys.argv[1]) if len(sys.argv) > 1 else None
cast = pychromecast.get_chromecast()
time.sleep(0.5)
if requested_volume != None:
cast.set_volume(requested_volume)
else:
print cast.status.volume_level
Copy link

ghost commented Jul 5, 2019

Have you tried cast.wait() instead of sleeping?

@frakman1
Copy link

frakman1 commented Feb 25, 2020

What units/range is the volume? 0 to 1 or 0 to 100?

@KalleDK
Copy link

KalleDK commented Jan 18, 2021

My testing is saying 0.0 to 1.0

@589290
Copy link

589290 commented Jan 16, 2022

Looks like its a double between 0 to 1. I set it at 0.45, slept 1 second, then queried, it was set at 0.44999998807907104

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment