[SOLVED] Halloween rule challenge (Sound and light flashing)

I know i´m a bit late on this challenge, but time is not on my side these days. So I desperate need some help getting a rule ready for tomorrow.

What I want to do:
When a motion sensor (at our frontdoor) trigger, playsound on a Google Home Mini (the best I could do atm), and starts flashing the light in our doorway.
When I press a button, mute the sound, (cant figure how to stop playing the sound on the Google Home Mini), and set the light to x%, until I press the key again - Then back to start, and get ready for the next poor souls (children) :hot_face:
I hope I got the idea covered.

Items available:

Dimmer  GoogleHoMini1Vol "Google Home Mini1 Volume [%s]"  <soundvolume> {channel="chromecast:chromecast:255f3cf49521e13fa5f92fc38ae7ac51:volume"}
Switch  GoogleHoMini1Mute "Google Home Mini1 Mute [%d]"   <soundvolume> {channel="chromecast:chromecast:255f3cf49521e13fa5f92fc38ae7ac51:mute"}

Dimmer lys_indgang 		"Udvendiglys Indgangsparti lysstyrke [%s %%]" 	<light> 	 {ihc="3916893"}
Switch 	Node13_BinarySensor 	"Neo Coolcam PIR Binary Sensor [%s]" <cum_motion> 	(gMotion) 		{channel="zwave:device:512:node13:sensor_binary"}

Switch bryggers_OEH "Bryggers switch upper right" <WallSwitch> (gV) {ihc=">[ON:47706:100]", autoupdate="false"}
Switch bryggers_NH "Bryggers switch lower right" <WallSwitch> (gV) {ihc=">[ON:49498:100]", autoupdate="false"}

What I have sofar, is this rule:

rule "Play stream to Google Home Mini"
when

//	Item ZWaveNode5ZW100MultiSensor6_MotionAlarm changed from OFF to ON or // Test motionsensor at office
	Item Node13_BinarySensor changed from OFF to ON // Motionsensor at frontdoor
	Item lydknap changed from OFF to ON // Test button to manually activate the rule

then
	 	playSound("chromecast:chromecast:255f3cf49521e13fa5f92fc38ae7ac51","Halloween1.mp3")
	logInfo("RULE.SWITCH_ON_STREAM", "Sending sound to Google Home Mini" )
end

Sound play fine, but I´m missing the part with the flashing light… A small note on this. The light are LED spotlight connected to a dimmer. I suspect they cant flash (blink) in a very high frequency due to the dimmer, my guess is a time above one second. But that i´ll have to figure out on a try.
I´m also missing the mute and activate buttons ofocuse.

Can someone help? @rlkoshak perhaps :wink:

Hi

For the second time today, I’d suggest adapting something that Cédric kindly wrote for me.

FYI

To stop a stream on my Chromecast, I send it a short Say command.

1 Like

Thanks alot Stuart… I think I get the idea about the light from your rule. Now the light is flashing :slight_smile:

1 Like

This is the finished rule with some test items. Will change to correct items tomorrow when it goes on for real…

var int interval = 1
var int steps = 0
var Timer testTimer = null

rule "Step sequence"

when
    Item lydknap changed from OFF to ON
then
	playSound("chromecast:chromecast:255f3cf49521e13fa5f92fc38ae7ac51","Halloween1.mp3")
	logInfo("RULE.SWITCH_ON_STREAM", "Sending sound to Google Home Mini" )

    testTimer = createTimer(now.plusSeconds(interval))
        [|
			if(steps == 0){
				spise_halo_styrke.sendCommand(100)

				steps = 1
			}else if(steps == 1){
				spise_halo_styrke.sendCommand(0)

				steps = 0
			}
			testTimer.reschedule(now.plusSeconds(interval))
        ]
end


rule "Timer Stop" 
when
    Item spise_bry_NH changed from OFF to ON
then
	if(testTimer !== null){
		testTimer.cancel()
		testTimer = null
	}
	
		spise_halo_styrke.sendCommand(35)
		playSound("chromecast:chromecast:255f3cf49521e13fa5f92fc38ae7ac51","doorbell.mp3")

end
1 Like