Skip to content

Commit

Permalink
feature: add option to not play a sound from the server (#20)
Browse files Browse the repository at this point in the history
also fixes issues when there is no sound player
  • Loading branch information
sbender9 authored Aug 11, 2023
1 parent d088f11 commit 9951990
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ module.exports = function(app) {
{

last_power_state = app.getSelfPath(default_device + ".state.value") == 'on'
power(true)
if ( !last_power_state ) {
power(true)
}

setup_for_alarm()
play_sound(value.value.state)
Expand Down Expand Up @@ -540,8 +542,13 @@ module.exports = function(app) {
function play_sound(state)
{
app.debug("play")

playing_sound = true

if ( plugin_props.playSound !== undefined && !plugin_props.playSound ) {
return
}

command = plugin_props.alarmAudioPlayer
app.debug("sound_player: " + command)

Expand All @@ -560,7 +567,7 @@ module.exports = function(app) {
play = child_process.spawn(command, args)

play.on('error', (err) => {
stop_playing()
//stop_playing()
app.error("failed to play sound " + err)
});

Expand All @@ -574,8 +581,8 @@ module.exports = function(app) {
}
else
{
app.debug("error")
stop_playing()
app.debug("error playing sound")
//stop_playing()
}
});
}
Expand All @@ -590,6 +597,7 @@ module.exports = function(app) {
"autoDiscover",
"deviceid",
"enableAlarms",
"playSound",
"alarmInput",
"alarmAudioFile",
"alarmUnMute",
Expand Down Expand Up @@ -656,6 +664,11 @@ module.exports = function(app) {
title: "Output Alarms To Stereo",
default: false
},
playSound: {
type: "boolean",
title: "Plays Sound",
default: true
},
alarmInput: {
type: "string",
title: "Input Name",
Expand Down

0 comments on commit 9951990

Please sign in to comment.