# A volume button for my chromecast

**URL:** <https://community.homey.app/t/a-volume-button-for-my-chromecast/9476>\
**Category:** Flows\
**Created:** [February 20, 2019, 9:13pm UTC](https://community.homey.app/t/a-volume-button-for-my-chromecast/9476 "2019-02-20T21:13:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![FKey](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fkey/32/14793_2.png) [@FKey](https://community.homey.app/u/FKey)\
**Post date:** [February 20, 2019, 9:13pm UTC](https://community.homey.app/t/a-volume-button-for-my-chromecast/9476/1 "2019-02-20T21:13:32Z")

</div>

**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](https://apps.athom.com/app/nl.philips.hue)  
The chromecast app: [https://apps.athom.com/app/com.google.chromecast](https://apps.athom.com/app/com.google.chromecast)  
The better logic app: [https://apps.athom.com/app/net.i-dev.betterlogic](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](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

---

<div class="post-metadata">

**Author:** ![FKey](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fkey/32/14793_2.png) [@FKey](https://community.homey.app/u/FKey)\
**Post date:** [March 10, 2019, 8:48am UTC](https://community.homey.app/t/a-volume-button-for-my-chromecast/9476/2 "2019-03-10T08:48:22Z")

</div>

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](https://us1.discourse-cdn.com/flex025/uploads/athom/original/2X/5/5ee1e9800afde17c9cbc5d5317c29eecd925ff58.jpeg)

---

<div class="post-metadata">

**Author:** ![Ruud](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ruud/32/64214_2.png) [@Ruud](https://community.homey.app/u/Ruud)\
**Post date:** [March 31, 2019, 12:03pm UTC](https://community.homey.app/t/a-volume-button-for-my-chromecast/9476/3 "2019-03-31T12:03:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ruud](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ruud/32/64214_2.png) [@Ruud](https://community.homey.app/u/Ruud)\
**Post date:** [April 2, 2019, 7:53pm UTC](https://community.homey.app/t/a-volume-button-for-my-chromecast/9476/4 "2019-04-02T19:53:39Z")

</div>

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](http://Www.youtube.nl/homeycornelisse)

Linkje naar Video: Klik [hier](https://youtu.be/kLuwJvNzRHU)

---

<div class="post-metadata">

**Author:** ![FKey](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fkey/32/14793_2.png) [@FKey](https://community.homey.app/u/FKey)\
**Post date:** [April 2, 2019, 8:46pm UTC](https://community.homey.app/t/a-volume-button-for-my-chromecast/9476/5 "2019-04-02T20:46:17Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![FKey](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fkey/32/14793_2.png) [@FKey](https://community.homey.app/u/FKey)\
**Post date:** [May 26, 2019, 6:22pm UTC](https://community.homey.app/t/a-volume-button-for-my-chromecast/9476/6 "2019-05-26T18:22:25Z")

</div>

> [@Volume Sonos instellen via afstandsbediening](https://community.homey.app/t/volume-sonos-instellen-via-afstandsbediening/13455/15):
>
> ik mis in dat topic de ‘begrenzer’ op 0 en 1 zodat je niet onder 0 en boven 1 kan

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

> [@Volume Sonos instellen via afstandsbediening](https://community.homey.app/t/volume-sonos-instellen-via-afstandsbediening/13455/15):
>
> ik mis in dat topic de ‘begrenzer’ op 0 en 1 zodat je niet onder 0 en boven 1 kan

🙏But I need some help here ❓❓  
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)

---

<div class="post-metadata">

**Author:** ![Mark\_Homey](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mark_homey/32/9202_2.png) [@Mark\_Homey](https://community.homey.app/u/Mark_Homey)\
**Post date:** [May 26, 2019, 6:52pm UTC](https://community.homey.app/t/a-volume-button-for-my-chromecast/9476/7 "2019-05-26T18:52:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![wvduffelen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/wvduffelen/32/34133_2.png) [@wvduffelen](https://community.homey.app/u/wvduffelen)\
**Post date:** [January 14, 2021, 9:59pm UTC](https://community.homey.app/t/a-volume-button-for-my-chromecast/9476/8 "2021-01-14T21:59:55Z")

</div>

@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…

---

<div class="post-metadata">

**Author:** ![FKey](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fkey/32/14793_2.png) [@FKey](https://community.homey.app/u/FKey)\
**Post date:** [January 15, 2021, 6:31pm UTC](https://community.homey.app/t/a-volume-button-for-my-chromecast/9476/9 "2021-01-15T18:31:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![wvduffelen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/wvduffelen/32/34133_2.png) [@wvduffelen](https://community.homey.app/u/wvduffelen)\
**Post date:** [January 15, 2021, 7:16pm UTC](https://community.homey.app/t/a-volume-button-for-my-chromecast/9476/10 "2021-01-15T19:16:57Z")

</div>

Sorry I forgot it was an English topic! But I’ll try that… I think it’s an issue with the Chromecast app…
