A volume button for my chromecast

Description of the flow (what are you trying to achieve)
The chromecast does not have a volume up/ down option, just a set volume option.
These flows turn my hue switch into a volume button
What is needed to create this flow?
The hue app (or any other app that support a button): https://apps.athom.com/app/nl.philips.hue
The chromecast app: https://apps.athom.com/app/com.google.chromecast
The better logic app: https://apps.athom.com/app/net.i-dev.betterlogic
The Virtual devices app, to create an On/Off setting for the radio:https://apps.athom.com/app/com.arjankranenburg.virtual

1 in Better Logic I created a new variable ā€œRadio SetNewVolumeā€
2 in virtual devices create a botton ā€œplayingā€
3 the 1st flow is triggered when the radio is switched on (virtual device ā€œplayingā€=ON)
This flow sets the chromecast speaker volume and casts a radio station.
For the purpose of the volume buttons a better logic card is added that sets the better logic variable ā€œRadio SetNewVolumeā€ equal to the chromecast volume

Two flows are needed to trigger the louder or softer:
When the hue buton is pressed
A better logic card increases or decreases the variable ā€œRadio SetNewVolumeā€

The increase card sometimes results in a multi digit number (0.400000001). Chromecast cannot handle these numbers, so the button becomes unresponsive.
This math card increases by 0.05 and rounds to 2 decimal


A 3rd flow is triggered by a better logic card that checks if the variable ā€œRadio SetNewVolumeā€ has changed. The ā€œTHENā€ card set the volume of he chrimecast to the variable ā€œRadio SetNewVolumeā€ (drag the tag into the card)

There is a reason why this is a seperate flow!!
If you would add the chromecast volumechange to the louder/softer flow you have an issue:
The ā€œANDā€ card set the new variable and the 2nd ā€œAND ā€œ card sets the chromecast volume. BUT it happens at the same time, so you cannot be sure that the value has been updated 1st.
I tried to solve that by putting a delay on the chromecard setvolume card.
That worksā€¦ until you press the volume button multiple times to increase the volume fast. It will only update every second and you can press much faster.
The 3rd flow per definition triggers AFTER the variable is updated and works fine

5 Likes

Update: a small improvement to the flow. The increase card sometimes results in a multi digit number (0.400000001). Chromecast cannot handle these numbers, so the button becomes unresponsive.
So changed the card to a math card that rounds to 1 decimal:
image

what a handy application. Iā€™m going to try this. I think it would be nice to make a video about this

I have tried out your flow idea and it really works great. I immediately made an explanation video of it. it will be online on my YouTube channel this week. Kanaal: Homeycornelisse

Linkje naar Video: Klik hier

Thanks,
Theres one thing I did not figure out yet.

When look at the ā€œvolumeā€ tag for chromecast the volume setting is correct.
But when I change the chromecast volume from a device outside homey (e.a google home app) then homey does not show that chance.

I want to force homey into updating that value so I can change volume using both devicesā€¦

Thanks to @Mark_Homey for noticing a small gap in this flow

:pray:But I need some help here :question::question:
How do I make a math.js command that limits the value between 0 and 1?
I tried math.clamp but that seems to be not supported (does not result in a value)

2 flows are needed for the limit between 0 and 1:

Flow 1
WHEN a number variable ā€˜volume valueā€™ changed, min. by 0.1
AND ā€˜volume valueā€™ is greater than 1
THEN set ā€˜volume valueā€™ at 1.

Flow 2:
WHEN a number variable ā€˜volume valueā€™ changed, min. by 0.1
AND ā€˜volume valueā€™ is less than 0
THEN set ā€˜volume valueā€™ at 0.

@Ruud ik heb jouw voorbeeld uit het YouTube kanaal gevolgdā€¦ kan het zijn dat deze flow alleen met een fysieke Chromecast werk en niet met een speakergroep? Ik krijg het niet werkend namelijkā€¦

Bij een fysieke GH gaat die maar Max tot 0.3 zag ik ook verder met loggingā€¦

Test the ā€œset volumeā€ card in a simple flow and see if that works.
If it doesā€¦ then this flow should also work.
If it does not hou need to contact the creator of the chromecast group

Sorry I forgot it was an English topic! But Iā€™ll try thatā€¦ I think itā€™s an issue with the Chromecast appā€¦