Chromecast volume control with rules

(Daniele Torresan) #1

Hello there! I am trying to integrate snips with openhab and I am trying to control my multi room chromecast system speakers!
I am able to change song (using spotify binding), via sitemap i can control audio volume by single rooms and by groups (using the slider) but I don’t know how to manage it in a rule! (not so much documentation for chromecast binding…)

using:
sendCommand(Music,PAUSE)
I can pause music and it is a starting point, but using:
VolumeCasa.sendCommand(INCREASE)

doesn’t work…
I even tried:
VolumeCasa.sendCommand(new PercentType(snipsSlot3Value))
with no luck…

“VolumeCasa” and “Music” are in .item file:
Dimmer VolumeCasa (gAudio) { channel="chromecast:audiogroup:Casa:volume" }
Player Music (gAudio) { channel="chromecast:audiogroup:Casa:control" }

any suggestion?
thank you everybody

0 Likes

(Russell Wong) #2

As far as I’m aware, a dimmer item is looking for a number from 0-100, so you can’t send a string (“increase”) to it.

What you could do is use a virtual item to trigger a rule that reads the current volume level into a variable, increases it by x, and sends the new value as a command.

The question I have is, how are you triggering this rule? I would think the slider on your sitemap takes care of manual control, so I’m curious as to how you’re using a rule that will always increase the volume, regardless of what the previous volume is.

0 Likes

(Christoph Weitkamp) #3

That is not true. You are able to send INCREASE/DECREASE commands to a Dimmer Item. But the Bindings have to implement the handling for it on the target Channel. This was not the case for the Chromecast Binding. I added the feature some time ago. It should be available in OH 2.5.0.M1 (milestone build).

1 Like

(Russell Wong) #4

Cool, so @Danielsan just needs to update to the milestone or use a snapshot binding?

Thanks, @cweitkamp!

0 Likes

(Christoph Weitkamp) #5

Yes, but I do not recommend upgrading OH to a snapshot version at this time unless you are developer-minded.

1 Like

(Daniele Torresan) #6

hello everybody, I found out a solution! (thanks to your suggestion)

if (snipsIntent == 'VolumeUp') {
  var  alzaVolume=VolumeCasa.state as Number
  alzaVolume=alzaVolume+10
  VolumeCasa.sendCommand(alzaVolume)
  }

so now I can control volume by asking my offline vocal assistant Snips!! :smiley:

One more question…
Do you know how I can send a stream? (like http mp3 link)
I tried with:

playStream("chromecast:audiogroup:Casa","http://ice07.fluidstream.net:8080/KissKiss.mp3")

but it doesn’t work… (of course I need to put in a rule)

0 Likes

(Christoph Weitkamp) #7

Hi @Danielsan,

Do not forget to check the the new volume values for upper / lower boundaries. The volume channel expects a percentage between 0 and 100.

Did you try playSound() too? If that does not work either we have to figure out if it is an issue with the binding by activating logging for it.

0 Likes

(RaSTuS) #8

I find it easier to do volume control in the sitemap like so:

Setpoint item=ghome1_Volume  minValue=0  maxValue=100 step=10

Which has the side effect of displaying up/down arrows to set your volume.

Item definition to show current volume setting:

Dimmer ghome1_Volume "Volume [%s]" <soundvolume> (gHomeMini) {channel="chromecast:chromecast:ghome1:volume"}
0 Likes

(Russell Wong) #9

I do that too, but it sounds like @Danielsan’s goal was to send commands via an offline voice assistant. When I think about it, I mostly use Google Assistant to control the volume on my Chromecasts.

Good point by @cweitkamp to add upper/lower boundaries with some if statements. I don’t know anything about Snips, but maybe you could even pass a value in the voice command (“set volume to X”).

0 Likes