Bug 1698 - Alarm for weekdays only
: Alarm for weekdays only
Status: RESOLVED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: Plugins
: 6.1.0
: All All
: P4 enhancement (vote)
: ---
Assigned To: KDF
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2005-06-21 02:16 UTC by Stuart
Modified: 2009-09-08 09:31 UTC (History)
3 users (show)

See Also:
Category: ---


Attachments
add weekday player UI (15.23 KB, patch)
2005-08-20 23:37 UTC, KDF
Details | Diff
updated alarm module (12.75 KB, text/plain)
2005-08-21 15:02 UTC, KDF
Details
web UI (7.90 KB, patch)
2005-08-26 01:40 UTC, KDF
Details | Diff
prefs conversion code (1.35 KB, patch)
2005-08-26 08:57 UTC, KDF
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stuart 2005-06-21 02:16:12 UTC
It would be really nice, if the alarm could be set to only trigger on a weekday.
 I know there is a plugin to do this, but for such a simple feature, I would
prefer this to be an option to be available with the standard installation.
Comment 1 Michael Herger 2005-06-21 08:48:02 UTC
you could use kdf's Alarm plugin which does (amongst others) exactly this.
http://www.deane-freeman.com/slimserver/
Comment 2 Stuart 2005-06-21 10:37:13 UTC
I feel that this simple feature should become part of the main application, and
not an addon.  The trouble with Plugins, is that they can sometimes break
between updates, and you have to wait for the plugin developer to catch up. 
Normally this isn't a big issue, but when relay on the alarm to wake you up for
work, it's more reassuring to know the Alarm feature is part of the stable
application, and not a 3rd party plugin.
Comment 3 Michael Herger 2005-06-21 12:23:00 UTC
Luckily the plugin's author not only is one of the most active developpers, but also relying on his plugin 
himself. I've never had to wait for an update after updating the server. 
Comment 4 KDF 2005-06-22 00:49:24 UTC
This kind of thing has come up many times before.  The design is for a SIMPLE
alarm in core, leaving extentions for elsewhere.  The caution, I'm sure, is that
if you add one more feature, you get forced into adding more and more, all under
the statement "but its only a simple change".

I'm perfectly willing to incorporate any aspect of the plugin to the core.  If
this is desired, then Slim Devices can assign this to me. 

In my own defense, however, I do have to point out that when it comes to the
Alarm Plugin, I'm likely more up to date than the built in alarm should anything
break it.  The only difference is, its a separate download. The point regarding
plugin delays is usually valid.  The AlarmPlugin, I feel, is probably one of the
worst examples to use in defense of that point.

To make another point: a major gain in sticking to the lines when plugins come
along is that it DOES free up the core devs for working on the really important
core features, instead of dealing with all the sideline functions, which, if
they ever did stick to being simple, would not break as often as they do :)
Comment 5 Vidur Apparao 2005-06-30 13:51:55 UTC
Getting this one off the 6.1 radar.
Comment 6 Blackketter Dean 2005-08-19 22:29:12 UTC
I'd like to consider adding a set of 7 day-of-week alarms to the default alarm plugin.  Essentially, to the 
existing alarm menu, we'd add an item "Weekday Alarms", in there there'd be 7 items, one for each day:

Monday (7:00am)
Tuesday (off)
Wednesday (7:00am)
etc....

Under each of those would be a set of settings for the alarms (time, alarm sounds, etc...)

KDF: what do you think?
Comment 7 KDF 2005-08-19 22:55:42 UTC
7 settings groups, yeah, seems doable. I've done this with the plugin, but only
via installing copies of the module.  Will be a bit different to make it all
work from one central module.
Comment 8 KDF 2005-08-20 22:18:06 UTC
Dean, the time display in brackets seems to be a Squeezenetwork thing.  Any
chance I can get at the code for that instead of having to add something similar
with new, and maybe different code?

otherwise, got most of it going already.  just the alarm on/off that's still
being difficult.
Comment 9 KDF 2005-08-20 23:37:26 UTC
Created attachment 750 [details]
add weekday player UI

this is what I have so far.  it seems to work.	There is an upgrade script to
change the alarm prefs into arrays, and a submenu for weekday alarm.  Still
some cleanup here.  the weekday isn't saved, so going into that menu is always
Monday, but this could go to the last selected day OR the current day by
default.  I also still need to see the ccode for showing the time in parens for
each.
Comment 10 Blackketter Dean 2005-08-21 10:08:48 UTC
The [x] bit is handled by INPUT.Choice with an overlay ref.  Here's a sample:

               'settings/SETUP_LONGDATEFORMAT' => {
                        'useMode' => 'INPUT.Choice',
                        'listRef' => \@dateFormatChoices,
                        'header' => "{SETUP_LONGDATEFORMAT} {count} {PRESS_TO_SELECT}",
                        'name' => sub { 
                                my ($client, $item) = @_;
                                # format current time in current format option 
                                return $client->longDateF(undef, undef, $item);
                        },
                        'onRight' => sub {
                                my ($client, $item) = @_;
                                Slim::Utils::Prefs::clientSet($client, 'longdateFormat',  
                                                                                          $item);
                                $client->showBriefly($client->string('SAVING_SELECTION'));
                        },
                        'initialValue' => sub {return Slim::Utils::Prefs::clientGet($_[0], 'longdateFormat')},
                        # overlay shows checkmark next to selected option
                        'overlayRef' => sub {
                                my ($client, $item) = @_;

                                if ((Slim::Utils::Prefs::clientGet($client, 'longdateFormat') || '') eq $item) {
                                        return [undef,"[x]"]; # use "x" until we have checkmark
                                } else {
                                        return [undef,"[ ]"];
                                }

                        },
                },
Comment 11 KDF 2005-08-21 11:39:54 UTC
Thanks.  What about the lines for displaying the time: "Alarm Clock (19:55)"?
Comment 12 KDF 2005-08-21 15:02:06 UTC
Created attachment 753 [details]
updated alarm module

this should do it.  give 'er a test, or I can commit and let everyone else at
it.
Comment 13 Blackketter Dean 2005-08-21 17:00:24 UTC
Go ahead and commit and Iet folks have a play.  Will comment on what I see.
Comment 14 Blackketter Dean 2005-08-21 17:17:09 UTC
One more thing.  Why are you removing the old alarm setting?  I think that we should have the same 
Alarm settings for the "every day" alarm, we're also adding 7 more alarms, one for each weekday.  So 
there's a new set of prefs in an array for each day, but the old alarm should be in place.  Right?
Comment 15 KDF 2005-08-21 18:00:54 UTC
I'm not removing the old pref, but I do have ot move it into the array or yaml causes a crash when I try 
to use the same names.  So, what we'll have is day 0-7 where day 0 is every day and 1-7 are each day.  
Comment 16 KDF 2005-08-21 20:42:10 UTC
Just as more info on the pref change.  Having it all as a single array gives me
more code reuse, since I can simply re-enter the existing alarm mode with a
param. Using 0 for every day means I can do a simply if ($day) and get a
true/false for everyday/oneday.  

committed to trunk at change 4024
Comment 17 Michael Herger 2005-08-21 21:20:50 UTC
I'm late... but the new alarm setting does break the player setting's web 
interface (or has it been broken since moving to yaml?). The volume setting is a 
text field containing a hash reference.
Comment 18 KDF 2005-08-21 23:52:10 UTC
thanks michael.  patched at change 4029.  its a bit of overkill, perhaps, with
the   currentValues, but they didn't want to appear using this style of UI with
array prefs.  I still need to figure out what kind of web UI would be right for
the weekday alarms.  Dean, got any ideas? I think it could be 7 groups, one for
each day just like the one we already have.  Or we use the array templates to
somehow make something work here.
Comment 19 Blackketter Dean 2005-08-22 07:53:00 UTC
I'd make an eight row table like this:

Alarm Clock

You can set up alarms that will turn on your player and play a saved playlist every day or on days of the 
week.  Enter a time, volume level (0-100) and choose a playlist below.

                                Time           Volume   Playlist
Every day:        [on]   [ 9:00am]    [50]        [Morning Music]
Monday:          [off]   [12:00am]    [50]       [                      ]
Tuesday:         [off]   [12:00am]    [50]       [                      ]
Wednesday:    [off]   [12:00am]    [50]       [                      ]
Thursday:       [off]   [12:00am]    [50]       [                      ]
Friday:            [off]   [12:00am]    [50]       [                      ]
Saturday:        [off]   [12:00am]    [50]       [                      ]
Sunday:          [off]   [12:00am]    [50]       [                      ]

(Change)
Comment 20 KDF 2005-08-22 09:27:11 UTC
ah yes. we'll need a new template to do this, that allows pulldowns in the
table.  or, I may find a way to 'fake' it using a group for each row.
Comment 21 Blackketter Dean 2005-08-22 14:35:07 UTC
When in doubt, ask the oracle of Moser.  :)
Comment 22 KDF 2005-08-25 00:18:05 UTC
and so I will.  

Robert, any thoughts on how this kind of template could be implemented?

Comment 23 Robert Moser II 2005-08-25 07:56:37 UTC
I don't believe that a simple template will work for this.  This kind of
arrangement will require some backend work as well.  The current setup.pm just
isn't flexible enough for this.

It might be best to just overhaul setup.pm such that the template engine handles
most of the layout work.  Then we can come up with a way of expressing this
arrangement a bit better.
Comment 24 KDF 2005-08-25 09:42:25 UTC
That's what I thought.  I guess we need something short term.  I'll do it with
multiple groups for now.  Its the only thing on that page, so it won't be
compeltely horrible.  An overhaul of setup might be good for 6.5 or 7 roadmap
Comment 25 KDF 2005-08-26 01:40:37 UTC
Created attachment 773 [details]
web UI

here is the web setup UI.  Its not the desired layout, but it is what the
server can generate for now. Seems to work, tho I haven't given it full testing
with existing prefs (since mine were wiped by bug2009) 

 I've also added some code to to Prefs.pm.  Theory is there that an existing
scalar pref can be converted into an array pref (so no upgrade script needed).
feedback welcome.  I know I may not be taking into account all problems caused
by allowing this.
Comment 26 Robert Moser II 2005-08-26 07:37:20 UTC
The prefs code is flawed.  You don't delete the scalar pref before setting the
new hash pref, which will most likely cause an error.  For the array pref
conversion, you store the old value in $old, but when you set the [0] index you
use $prefs{$key}, which you just deleted.
Comment 27 KDF 2005-08-26 08:51:27 UTC
erk, yes.  diffed before I saved.  I wasn't sure how to deal with the old value
if it gets moved into hash pref.  I suppose I could use '0' as well?  What would
make the most sense?  I suppose anything could be set now, since we don't have
any hash prefs that I know of as yet.
Comment 28 KDF 2005-08-26 08:57:52 UTC
Created attachment 774 [details]
prefs conversion code

I just went ahead with '0' as the old when converting to hash pref.  It can be
anything sensible as long as we set it to something.
Comment 29 KDF 2005-08-29 21:34:41 UTC
committed the Alarm web settings at change 4117
layout is about as good as I can see doing with the existing framework.   We can
close this, or leave it retargetted for a version with some setup rework. Prefs
change was only a passing thought