Do something when THIS happend BUT NOT when this other thing happend¨¨

Hi guys,im kind of stuck,i made my rule and works fine...well sort of, what happen is,when nothing is playing trough my chromecast device (mediasource none) and change to spootify, youtube or any other media source my radio turn on...so far everything is fine, BUT if im listening spootify and i decide to change to listen/Cast youtube music,the action run from start over and turn off my radio (this happened because im using a infrared send codes with a broadlink device ,and on and off is the same Infrared code)...hope you can help me,Thanks and happy new year (with a few days old :stuck_out_tongue: )

A screenshot of your rule might help make it easier to comment...

(Im triying uploading a photo the site says it cant upload)

1 Like

I think if you are new it may take some time and perhaps a certain badge before you can do that... Is it easy enough to type out in some form?

Actually I think I get it now, let me think on it....

1 Like

This is my rule in text,i still triying why cant upload the photo:

Trigger Event:
Rod Radio/Tv reports mediaSource(None) changed

Actions to run:
IF (Rod Radio/Tv mediaSource(None) contains TuneIn (F) OR
Rod Radio/Tv mediaSource(None) contains Spotify(F) OR
Rod Radio/Tv mediaSource(None) contains YouTube (F) OR
Rod Radio/Tv mediaSource(None) contains 1.FM ChromeCast(F) [FALSE]) THEN
Push button 1 on α Boton; Dac-Input (2) ChromeCast
Push button 1 on α Boton; Radio Lg: On/Off

1 Like

I think it's a number of posts or something like that you need to get to before the system will let you, I assume it's to stop people / systems spamming a forum like this.

It is going to be a tough one re the radio, given you don't know the state of the radio. The best I can think of is to keep a variable for the mediaSource and detect when it moves from none to one of the one's you care about, but when it moves between sources to not turn the radio on. Does that make sense? So the chromecast part could remain and be in response to the IF-THEN statement, just remove the radio bit at the end. Then work on incorporating a variable to detecting a change in the mediaSource the way you need it. Sorry my brain is still waking up.... :slight_smile: Plus I haven't used variables myself effectively. Others here may be able to help or hopefully you can work through that yourself....

1 Like

hahaha,thanks,thats the major problem,not knowing the state of the device,the easy way maybe in the future is getting a device with power metering :P.The use of variables maybe could work,i will keep in mind,Thanks :slight_smile:

1 Like

1 Like

Actually, thinking about it again, perhaps this would be an easier solution:

Create a new Virtual Switch, say call it Radio VS

In your existing rule:

IF ....(you're existing conditions) THEN
Change input to Chromecast (existing action)
Turn on Radio VS
ELSE
Turn off Radio VS

Setup a new rule:

IF Radio VS changes THEN
Turn "on" the radio (action from your current rule setup)

The new rule will only run when there is a reason to turn the radio on or off, i.e. the media source changes from one you care about to none or vice-versa. If it changes between spotify and youtube hopefully the second rule won't fire because it has not changed. If it does fire, we should still be able to tweak it I expect to do what you need.

Hope this helps (and works),
Simon