sonos
sonos copied to clipboard
Add create() to Alarm class
I have added the functionality to add a new Alarm.
Please advise if I can improve this so you can accept it.
Hi @PhilippKolmann thanks very much for your contribution! From memory when I first wrote this class I didn't think it was practical to setup a new alarm from scratch. Hopefully something has changed since, or there was just something I missed! Can you share some sample code on how you're using this to create new alarms?
Hi @duncan3dc,
sure I started a small project to be able to change alarms via my Raspi from remote as well. It's currenlty very rough...
I have added a section to add a new alarm:
https://github.com/pkolmann/sonos-alarm-php/blob/2cc583ba14a29b1af674b1054d7ff031189895c1/lib/SonosAlarm.php#L103
Please bear in mind, that this is currently not production ready code ;-)
PS: I was not able to find another way to create a new alarm then to use the same XML that you parse from the sonos controller.
Ah ok I see, let me have a think about it. I think something like $speaker->createAlarm(UriInterface $music): AlarmInterface would be quite nice, and then additional settings can be set on the alarm instance before saving it
Hi @duncan3dc,
did you have any chance to think about the proposal? thanks
Hi @pkolmann so sorry for the delay here! I've just released version 2.3.0 that contains a method on the Network class (with the other alarm methods) to create a new alarm, hope this is useful! Thanks for your contribution :slightly_smiling_face: