Quantcast
Channel: Squeezebox : Community : Forums - DIY
Viewing all articles
Browse latest Browse all 123

Is it possible to override the default/server defined Snooze time for alarms (Radio)

$
0
0
Hi,

I've recently been tinkering with the files on my Squeezebox Radio (NOT upgraded to UE) with the aim of changing the alarm snooze functionality. I wanted to remove the 2nd option (turn off alarm) in the menu that is shown when the alarm goes off, as several times in a sleepy daze I've accidentally selected this option, then subsequently overslept! By removing this option from the menu, all I can do with the big scroll wheel is just snooze the alarm again, and I must make a concious effort to press the main power button to fully turn the alarm off. I was able to achieve this quite easily by modifying the file /usr/share/jive/applets/AlarmSnooze/AlarmSnoozeApplet.lua, and commenting out this block of code, saving the changes, then restarting the Radio:

--menu:addItem({
-- text = self:string("ALARM_SNOOZE_TURN_OFF_ALARM"),
-- sound = "WINDOWHIDE",
-- callback = function()
-- self:_alarmOff(true)
-- end,
-- })


What I would really like to do, (but have so far been unsuccessful), is to re-add a second menu item to the alarm menu that tells the alarm to snooze, but for a value longer than the default. So my server defined snooze time is 5 minutes, but during holidays and weekends, it would be nice to have 'Snooze for 15/30 minutes' options as well, for when I fancy a bit of a lie in!


I've tried added a second menu item, copying the code of the first, but then pointing it at a renamed copy of the 'alarmSnoozeMinutes()' function.

menu:addItem({
text = self:string("Give me half an hour!"),
sound = "WINDOWHIDE",
callback = function()
self:_alarmSnoozeThirtyMinutes()
end,
})



I then copied the existing alarmSnoozeMinutes()' function defined elsewhere in the same file, and renamed it to alarmSnoozeThirtyMinutes(). I then changed the line highlighted in bold below to a fixed value of 1800 seconds, rather than it's previous value of 'self.localPlayer:getAlarmSnoozeSeconds()'.


function _alarmSnoozeThirtyMinutes(self)
log:warn('_alarmSnooze: alarmInProgress is ', self.alarmInProgress, ' : connection status is ', self.localPlayer:isConnected())

self:_stopTimer()

log:warn('_alarmSnooze: fallback alarm snoozing for ', alarmSnoozeSeconds,' + 20 seconds')
local alarmSnoozeSeconds = 1800
local fallbackAlarmMsecs = alarmSnoozeSeconds * 1000 + 20000
self.debugRTCTime = fallbackAlarmMsecs

self:_startTimer(fallbackAlarmMsecs)
self:_wolTimerRestart(alarmSnoozeSeconds * 1000)

if self.alarmInProgress == 'rtc' then
log:warn('_alarmSnooze: stopping fallback alarm audio')
-- stop playback
self:_silenceFallbackAlarm()
else
self.alarmInProgress = 'snooze'
end

if self.localPlayer:isConnected() then
log:warn('_alarmSnooze: sending snooze command to connected server for connected player ', self.localPlayer)
self.localPlayer:snooze()
end
self:_stopDecodeStatePoller()

self.alarmWindow:playSound("WINDOWHIDE")
self:_hideAlarmWindow()
end





However, this appears to make absolutely no difference when I select this option from the alarm menu - the snooze time remains at the 5 minute server setting.


Has anyone got experience with modifying the alarms on the Squeezebox Radio that can offer any advice? The approach I'm taking might be fundamentally flawed, but I kind of feel like it should work, and it would be a cool little feature if it did!

Viewing all articles
Browse latest Browse all 123

Trending Articles