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 decreaes the variable “Radio SetNewVolume”
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:
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