Hi there,
I'm using Frontpage (which works very nice) and I would like to play a sound when for example a motion sensor is set On.
So when I open Frontpage in the browser, the sound plays on the affected device.
It should be somewhere in the frontpage.js file I think.
if(item.idx == idx_motion && vdata == 'On'){
???????; // play sound when switch is on
}
Does anyone have an idea?
Play sound when switch is on (using Frontpage) Topic is solved
Moderator: leecollings
-
- Posts: 30
- Joined: Friday 26 August 2016 9:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Play sound when switch is on (using Frontpage)
Issue solved!
Put the code below in your frontpage.js
Put the code below in your frontpage.js
Code: Select all
if(item.idx == idx_alarm && vdata == 'On'){
switchclick = 'onclick="SwitchToggle('+item.idx+', \'Off\');lightbox_open(\'switch\', '+switch_off_timeout+', '+txt_switch_off+')"';
vdata=new String(vdata).replace( "On","<img src=icons/png/caution.png height=50 align=center style='margin-top:3px;'><audio loop autoplay><source src='sounds/alarm.wav' type='audio/wav'><source src='sounds/alarm.ogg' type='audio/ogg'><source src='sounds/alarm.mp3' type='audio/mpeg'>Your browser does not support the audio element.</audio>"); // on
} else if(item.idx == idx_alarm && vdata == 'Off'){
switchclick = 'onclick="SwitchToggle('+item.idx+', \'On\');lightbox_open(\'switch\', '+switch_on_timeout+', '+txt_switch_on+')"';
vdata=new String(vdata).replace( "Off",""); // off
}
Who is online
Users browsing this forum: No registered users and 1 guest