Get motion sensor to fire rule once until its been reset to play video

So I have a motion sensor in the hallway which triggers my hallway light, which works fine. During the summer I rent my flat out occasionally, so then I would like to know when my guest arrive. So the idea is to use my motion rule:

rule "Update hallway light when motion happens"
when
    Item HueMotionBathroom changed from CLOSED to OPEN 
then
	Presence_Home.sendCommand(ON)
	Light_Hallway_Timer.sendCommand(ON)
	if (Light_Hallway.state ==OFF) {
		Light_Hallway.sendCommand(ON)		
	}
	
end

Which then will trigger this rule only once! (Until I manually reset it). Maybe a bit overload to check evrytime Presence_home changes to see state of Presence_WaitingForGuest, maybe move it to the rule above instead?

rule "Sensor update"
when
    Item Presence_Home received update
then
    Presence_Home_LastUpdate.postUpdate( new DateTimeType() )
         if ( Presence_WaitingForGuest.state ==OFF) {
		Presence_WaitingForGuest.sendCommand(ON)		
	} 
end

And finally to my problem, how do I play a local file from RPI on chromecast?

rule "Guest Arrived"
when
    Item Presence_WaitingForGuest CHANGED FROM OFF TO ON
then
  // Send email to myself...
  // Play notification on stereo, to make guest move to sofa
//Wait a minute or so
// Play video on chromecast from local file on rpi
end

NO, that’s the right way to do it or your could put your two rules into one:

rule "Update hallway light when motion happens"
when
    Item HueMotionBathroom changed from CLOSED to OPEN 
then
    Presence_Home.sendCommand(ON)
    Light_Hallway_Timer.sendCommand(ON)
    if (Light_Hallway.state ==OFF) {
        Light_Hallway.sendCommand(ON)		
    }
    if (Presence_Home.state == OFF) {
        Presence_Home.sendCommand(ON)
        Presence_Home_LastUpdate.postUpdate( new DateTimeType() )
            if ( Presence_WaitingForGuest.state ==OFF) {
            Presence_WaitingForGuest.sendCommand(ON)		
        }
    }
end

For your second question:
Your need the chromecast binding
A video file (mp4) that you put into the /conf/html folder
and link an item to the playuri channel
and send a command to the item with the location of the file :"/etc/openhab2/conf/html/welcome.mp4"

1 Like

Thanks! Will try it tonight

So I can control volume on chromecast, but I can not show the video, just an empty cast symbol on screen:

Chromecast_LivingRoom_Playuri.sendCommand('/etc/openhab2/conf/html/test.mp4')
Chromecast_LivingRoom_Playuri.sendCommand('https://www.youtube.com/watch?v=8W4FP8ZD06I&t=24s')

Not sure what i am missing…

Maybe use " instead of ’

Tried both… without succsess

Is it user right issues? I am not very familiar with linux. The chromecast is on 2.4ghz wifi where the rpi is on the ethernet.

No it shouldn’t matter, it works for me.

So you can confirm that it works with youtube url? Can you show me your item and things definition, thanks for the help

I did it through the PaperUI
And created an item through the paperUI too.
When I send a command to the item it plays on the TV

@vzorglub did you set:
callbackUrl text optional Callback URL - url to use for playing notification sounds, e.g. http://192.168.0.2:8080

Is the Ip address, the IP of chromecast or openhabian? The documention is unclear on this point.

NO I didn’t set it. The binding finds the chromecast on auto discovery but then I only have one chromecast.
It would be the chromecast IP

I still can not figure out why it is not working:

2018-08-28 00:20:53.057 [vent.ItemStateChangedEvent] - Chromecast_LivingRoom_Playuri changed from //etc/openHAB-conf/html/test.mp4 to /etc/openHAB-conf/html/test.mp4

2018-08-28 00:20:55.137 [hingStatusInfoChangedEvent] - 'chromecast:chromecast:chromecast_livingRoom' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Unable to load media

Is this some kind of permission problem?

My commands are:

    Chromecast_LivingRoom_Playuri.sendCommand("/etc/openHAB-conf/html/test.mp4")
    
    Chromecast_LivingRoom_Playuri.sendCommand("https://www.youtube.com/watch?v=8W4FP8ZD06I&t=24s")

Why is it called playuri and not playurl? And what is valid commands?
playStream("chromecast:chromecast:Chromecast_LivingRoom","http://st01.dlf.de/dlf/01/128/mp3/stream.mp3") does not work either, and I assume this is only for chromecast audio… However I can not confirm this and its not mentioned in the binding information.

/etc/openhab2/html/test.mp4
That would my path

Its still not able to load the media, i think it most be some be some permission errors. Can you confirm that you uses openhabian on rpi? Did you get youtube to work aswell?

I don’t use openHABbian on pi.
I use a standard installation on a linux box (Ubuntu)
YouTube works too.
I don’t know why your set-up doesn’t work, sorry

Thanks for your effort though, I suspect the openhabian user doesn’t have the right permission to cast. Because I can see the video if I double click on it on the samba share. So has anyone out here been able to cast video on an openhabian setup?