Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
SONOS Plugin
Re: SONOS Plugin
Well that was quick! Awesome. I'll try to add more commands to it as well.
If I have one IP address of at least one SONOS player I can get all the IP addresses pretty easily. To search for all the IP addresses automatically as an action or during initialization of the plugin, I have to send out a UPNP broadcast message and then wait for all the replies and filter through them to find only the SONOS players (all UPNP devices will respond). I have some code i wrote somewhere that I was testing to do this with but i'll have to find it, it was in earlier 2012. It will also need some of the filter features added. it's doable for sure.
I'm not as familiar with creating plugins for eventghost yet and I haven't tested the plugin you created yet, but is the plugin specific for only one ZP (it looked like the Configure function is at plugin initialization)? If so would it be difficult to adapt it to configure or set the IP address when an action is added instead, or maybe list all IP addresses in __init__ file to simply select which ZP the command should go to? With that in mind, when I get home I'll look for the code that searches as well. Hopefully I can add that pretty easily and then the list can automatically be added. Then when an action is created, you just select the ZP from the list you want the command to go to.
What do you think?
If I have one IP address of at least one SONOS player I can get all the IP addresses pretty easily. To search for all the IP addresses automatically as an action or during initialization of the plugin, I have to send out a UPNP broadcast message and then wait for all the replies and filter through them to find only the SONOS players (all UPNP devices will respond). I have some code i wrote somewhere that I was testing to do this with but i'll have to find it, it was in earlier 2012. It will also need some of the filter features added. it's doable for sure.
I'm not as familiar with creating plugins for eventghost yet and I haven't tested the plugin you created yet, but is the plugin specific for only one ZP (it looked like the Configure function is at plugin initialization)? If so would it be difficult to adapt it to configure or set the IP address when an action is added instead, or maybe list all IP addresses in __init__ file to simply select which ZP the command should go to? With that in mind, when I get home I'll look for the code that searches as well. Hopefully I can add that pretty easily and then the list can automatically be added. Then when an action is created, you just select the ZP from the list you want the command to go to.
What do you think?
The Latest SONOS Plugin:
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309
EventGhost Lets me automate my home the way I want it, I love using it!
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309
EventGhost Lets me automate my home the way I want it, I love using it!
Re: SONOS Plugin
Quick but dirty. I just copy pasted your code into a plugin, i should properly try to edit it a little bit to make it more user frendly and also make some more code universable to cut back on the code lines.
Yes it is for one ZP only, But the plugin is capable of multiloading so you can add add it more than once which will give you possibility to control more than on ZP. But i agree with you that the best solution would be that the plugin initialization configs all the zones and then in the action config you can spesify which zone to control, this should also make it more easy to bind groups in the future instead of having multiple plugins running. I can try to put something together, but keep in mind i am not that familiar with creating plugins either and even though i can read and understand some phyton scripting i am not god at writing it.
Yes it is for one ZP only, But the plugin is capable of multiloading so you can add add it more than once which will give you possibility to control more than on ZP. But i agree with you that the best solution would be that the plugin initialization configs all the zones and then in the action config you can spesify which zone to control, this should also make it more easy to bind groups in the future instead of having multiple plugins running. I can try to put something together, but keep in mind i am not that familiar with creating plugins either and even though i can read and understand some phyton scripting i am not god at writing it.
Re: SONOS Plugin
Jostein, you're getting me more motivated to work on this plugin.
Okay, so i put together some code last night that can scan your network and capture all the SONOS Zone Players (ZPs). It captures the name (what ever you set in SONOS app), UDN (basically the MAC Address), IP address and if it's visible or not. I still have some tweaking to do but the plan is to put it in the plugin and re-write some of the plugin commands to reduce the duplicate lines. I should have that by end of this weekend. This will only look at the network once and does not automatically update if a ZP is added or removed from the network. Stretch goal will be to at least add an action that allows searching again at anytime.
The only part I'm not that familiar with is how to have a popup window appear when creating an action and have that popup show a drop down menu to allow you to select a ZP. I'll try to look at some other plugins code to get examples, but if anyone knows how to do that, i would greatly appreciate the help.
I plan on having the drop down list the MAC, IP, and Name, but the UDN will be what is used as the unique identifier sense the IP and name can change at any time.
For preset actions,
I'm thinking of adding an action that allows you to capture the current streaming station for a specific ZP when it's first created, then store that in the action so it can be recalled at any point within EG. This should work with most streaming services. more testing will have to be performed to see how well it can work with Spotify and local play lists.
Jostein,
what streaming source do you typically use? I can try to make sure if i add that action that it works with those as well.
Okay, so i put together some code last night that can scan your network and capture all the SONOS Zone Players (ZPs). It captures the name (what ever you set in SONOS app), UDN (basically the MAC Address), IP address and if it's visible or not. I still have some tweaking to do but the plan is to put it in the plugin and re-write some of the plugin commands to reduce the duplicate lines. I should have that by end of this weekend. This will only look at the network once and does not automatically update if a ZP is added or removed from the network. Stretch goal will be to at least add an action that allows searching again at anytime.
The only part I'm not that familiar with is how to have a popup window appear when creating an action and have that popup show a drop down menu to allow you to select a ZP. I'll try to look at some other plugins code to get examples, but if anyone knows how to do that, i would greatly appreciate the help.
I plan on having the drop down list the MAC, IP, and Name, but the UDN will be what is used as the unique identifier sense the IP and name can change at any time.
For preset actions,
I'm thinking of adding an action that allows you to capture the current streaming station for a specific ZP when it's first created, then store that in the action so it can be recalled at any point within EG. This should work with most streaming services. more testing will have to be performed to see how well it can work with Spotify and local play lists.
Jostein,
what streaming source do you typically use? I can try to make sure if i add that action that it works with those as well.
The Latest SONOS Plugin:
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309
EventGhost Lets me automate my home the way I want it, I love using it!
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309
EventGhost Lets me automate my home the way I want it, I love using it!
Re: SONOS Plugin
Good to hear that you are finding motivation, as lack of it is often the thing to stop a project.
System - Sound card: C:\Program Files (x86)\EventGhost\plugins\System\__init__.py. (Mute on is proparly as close to what we want as i understand check line 891-911.)
OSD plugin: C:\Program Files (x86)\EventGhost\plugins\EventGhost\ShowOSD.py.
Maby you can also find some help in this thread:
http://www.eventghost.com/forum/viewtop ... 109#p18437
You have proparly seen this already but this explains how to write a plugin for eg:
http://www.eventghost.net/docs/writing_plugins.html#
But there is no info on how to make list`s there
If you have no luck we can always ask for help for the problem in the coding corner instead as i dont think there are many people following this thread.
Regards Jostein
Sounds great. I could also try to do some cleaning in the code but maby it is best that you do it since you understand the code mutch better than me.techoguy wrote:Okay, so i put together some code last night that can scan your network and capture all the SONOS Zone Players (ZPs). It captures the name (what ever you set in SONOS app), UDN (basically the MAC Address), IP address and if it's visible or not. I still have some tweaking to do but the plan is to put it in the plugin and re-write some of the plugin commands to reduce the duplicate lines. I should have that by end of this weekend. This will only look at the network once and does not automatically update if a ZP is added or removed from the network. Stretch goal will be to at least add an action that allows searching again at anytime.
I am not familiar with popup windows either. But i know how to make a config box in an action config, se attached file (here you can se that there is one config box in the plugin and one in the action how to make it into a list i dont know, have tried with no luck.) I have never successfully made a pulldown list myself but now that the following uses them:techoguy wrote:The only part I'm not that familiar with is how to have a popup window appear when creating an action and have that popup show a drop down menu to allow you to select a ZP. I'll try to look at some other plugins code to get examples, but if anyone knows how to do that, i would greatly appreciate the help.
System - Sound card: C:\Program Files (x86)\EventGhost\plugins\System\__init__.py. (Mute on is proparly as close to what we want as i understand check line 891-911.)
OSD plugin: C:\Program Files (x86)\EventGhost\plugins\EventGhost\ShowOSD.py.
Maby you can also find some help in this thread:
http://www.eventghost.com/forum/viewtop ... 109#p18437
You have proparly seen this already but this explains how to write a plugin for eg:
http://www.eventghost.net/docs/writing_plugins.html#
But there is no info on how to make list`s there
If you have no luck we can always ask for help for the problem in the coding corner instead as i dont think there are many people following this thread.
This sounds like a great way of doing it and if you could implement it it would be great. I mostly use spotify and local radio channels. But i dont have a rush to get it working so if you want to work on other stuff first that is no problem for me.Jostein wrote:For preset actions,
I'm thinking of adding an action that allows you to capture the current streaming station for a specific ZP when it's first created, then store that in the action so it can be recalled at any point within EG. This should work with most streaming services. more testing will have to be performed to see how well it can work with Spotify and local play lists.
Jostein,
what streaming source do you typically use? I can try to make sure if i add that action that it works with those as well.
Regards Jostein
-
kalinkamaen
- Experienced User
- Posts: 138
- Joined: Wed Dec 26, 2012 9:23 am
Re: SONOS Plugin
Thank you both for doing this one your own spare time.
I will test this as soon as i am home and report back to you guys.
Thanks again.
I will test this as soon as i am home and report back to you guys.
Thanks again.
-
kalinkamaen
- Experienced User
- Posts: 138
- Joined: Wed Dec 26, 2012 9:23 am
Re: SONOS Plugin
Yes it works on Play 3 now. Very good guys. And much easier to setup. Looking forward to this 
Re: SONOS Plugin
Latest version can be found here: viewtopic.php?f=9&t=5312&p=29852#p29852
updated: zipped the wrong file, replaced with correct zip file. old file was just a shortcut.
When you add the plugin (or stop/restart the plugin) it will automatically search your network for all the SONOS Zone Players and store information about them.
If you add or remove a ZP to your network, simply stop and start the plug in to search the network again (it does not do this on its own). When configuring an action, you're presented with all the ZP, select the one you want the command to go to (for stereo pairs, it will only show the master of the pair) and that's it. Also, these commands should work with any Zone Player. Best of all it will send the command to the right ZP regardless if the ZP is group, in a stereo pair, or not.
Test it out and let me know how it goes.
Hopefully soon i'll be able to add commands to select specific playlists and automatically group/un-group ZPs.
NOTE: this plugin requires that your SONOS zone players have static IP addresses. SONOS doesn't support static IP addresses so this has to be done in your router.
i'm still cleaning up a lot of the code as well. Currently it still has a lot of prints that will be removed in following versions.
Enjoy!
updated: zipped the wrong file, replaced with correct zip file. old file was just a shortcut.
When you add the plugin (or stop/restart the plugin) it will automatically search your network for all the SONOS Zone Players and store information about them.
If you add or remove a ZP to your network, simply stop and start the plug in to search the network again (it does not do this on its own). When configuring an action, you're presented with all the ZP, select the one you want the command to go to (for stereo pairs, it will only show the master of the pair) and that's it. Also, these commands should work with any Zone Player. Best of all it will send the command to the right ZP regardless if the ZP is group, in a stereo pair, or not.
Test it out and let me know how it goes.
Hopefully soon i'll be able to add commands to select specific playlists and automatically group/un-group ZPs.
NOTE: this plugin requires that your SONOS zone players have static IP addresses. SONOS doesn't support static IP addresses so this has to be done in your router.
i'm still cleaning up a lot of the code as well. Currently it still has a lot of prints that will be removed in following versions.
Enjoy!
Last edited by techoguy on Sat Feb 15, 2014 12:36 am, edited 3 times in total.
The Latest SONOS Plugin:
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309
EventGhost Lets me automate my home the way I want it, I love using it!
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309
EventGhost Lets me automate my home the way I want it, I love using it!
-
kalinkamaen
- Experienced User
- Posts: 138
- Joined: Wed Dec 26, 2012 9:23 am
Re: SONOS Plugin
This last EG_sonos.zip i do not completly understand.
Do i just download, unzip and put folder "EG_sonos" into plugins?
I have tried this but couldnt open it as an plugin that way.
Do i just download, unzip and put folder "EG_sonos" into plugins?
I have tried this but couldnt open it as an plugin that way.
Re: SONOS Plugin
hi Kalinkamaen,kalinkamaen wrote:This last EG_sonos.zip i do not completly understand.
Do i just download, unzip and put folder "EG_sonos" into plugins?
I have tried this but couldnt open it as an plugin that way.
It was late last night when i created and uploaded the zip. the zip file was not complete. I have replaced the zip file in the previous post with the correct file. You are correct, you just need to unzip the folder and place it in the plugin folder.
The Latest SONOS Plugin:
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309
EventGhost Lets me automate my home the way I want it, I love using it!
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309
EventGhost Lets me automate my home the way I want it, I love using it!
Re: SONOS Plugin
Latest version can be found here: viewtopic.php?f=9&t=5312&p=29852#p29852
Hey All,
I have added to the SONOS plugin.
Version 0.3: New actions:
-- Set Volume to specific value
-- Relative Volume adjustments
-- Start playing specific playlist/station from SONOS Favorites list
-- Change Play Mode like shuffle and repeat
-- the ability to search the network for SONOS players without restarting the plugin
Notes:
-- Previous Volume down and up have been replaced with the relative volume adjustments. This allows you to select the size of each step when adjusting the volume. positive number is up and negative number is down.
-- I have tested the playlists/stations with Songza, Pandora, Slacker, RadioStations, and Spotify. It should work with any others as long as the station or playlist has been saved to your favorites in SONOS first. Please let know if you have issues with any other services.
-- Note that PlayMode is only for playlists. If you are streaming a station from something like Pandora, this command will print a 500 error. Know that this is normal and that the plugin will keep working.
Let me know what you guys think and how it's working for you.
I'm Curious also how many of you guys have multiple SONOS players? I'll probably be working on grouping actions next or selecting Aux inputs. Let me know if there is a preference.
Enjoy!
Hey All,
I have added to the SONOS plugin.
Version 0.3: New actions:
-- Set Volume to specific value
-- Relative Volume adjustments
-- Start playing specific playlist/station from SONOS Favorites list
-- Change Play Mode like shuffle and repeat
-- the ability to search the network for SONOS players without restarting the plugin
Notes:
-- Previous Volume down and up have been replaced with the relative volume adjustments. This allows you to select the size of each step when adjusting the volume. positive number is up and negative number is down.
-- I have tested the playlists/stations with Songza, Pandora, Slacker, RadioStations, and Spotify. It should work with any others as long as the station or playlist has been saved to your favorites in SONOS first. Please let know if you have issues with any other services.
-- Note that PlayMode is only for playlists. If you are streaming a station from something like Pandora, this command will print a 500 error. Know that this is normal and that the plugin will keep working.
Let me know what you guys think and how it's working for you.
I'm Curious also how many of you guys have multiple SONOS players? I'll probably be working on grouping actions next or selecting Aux inputs. Let me know if there is a preference.
Enjoy!
Last edited by techoguy on Sat Feb 15, 2014 12:37 am, edited 1 time in total.
The Latest SONOS Plugin:
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309
EventGhost Lets me automate my home the way I want it, I love using it!
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309
EventGhost Lets me automate my home the way I want it, I love using it!
Re: SONOS Plugin
Hi techoguy.
Thanks for the new version it works great. Great to be able to control the favorites without using a phone or pc.
I only have 1 zone now but will son have 5.
I have no preference on aux or grouping. Have you any plans on adding feedback for now playing and so on?
Best regards Jostein
Thanks for the new version it works great. Great to be able to control the favorites without using a phone or pc.
I only have 1 zone now but will son have 5.
I have no preference on aux or grouping. Have you any plans on adding feedback for now playing and so on?
Best regards Jostein
Re: SONOS Plugin
Hi Jostein,I only have 1 zone now but will son have 5.
I have no preference on aux or grouping. Have you any plans on adding feedback for now playing and so on?
I have been looking into it. I know how to do it within regard to SONOS and Sonos controller apps and my other version of my Sonos project. I'm trying to decide how I want to implement it within the eventghost plugin. To do it right ( meaning to get automatic updates vs continually polling) I have to use multithreading and do a lot more in the background. Doing it for one ZP isn't so bad but making it work when you have multiple ZPs is a little harder.
Hopefully I can make some headway before to long.
If anyone following is familiar with asyncore or threading modules, let me know. I'm still learning how to implement using these.
The Latest SONOS Plugin:
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309
EventGhost Lets me automate my home the way I want it, I love using it!
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309
EventGhost Lets me automate my home the way I want it, I love using it!
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: SONOS Plugin
Hi, you could consider to use the eg.scheduler. I assume it is running in multiple threads and in this way, you are making use of an EG built-in.
As example, you can check my Spotify plugin where I use this to check for track/artists changes
When the plugin starts, you schedule the first check:
When the scheduler triggers, you do the stuff inside the specified function and at the end, schedules itself for the next check
When you stop the plugin, I recommend a cleanup of remaining not yet triggered schedules
As example, you can check my Spotify plugin where I use this to check for track/artists changes
When the plugin starts, you schedule the first check:
Code: Select all
self.CCT_Task = eg.scheduler.AddTask(
5.0,
self.CheckCurrentTrack
)
When the scheduler triggers, you do the stuff inside the specified function and at the end, schedules itself for the next check
Code: Select all
def CheckCurrentTrack(self):
try:
if self.spotify.isPlaying():
self.currentTrack = ['', '']
self.currentTrack[0] = self.spotify.getCurrentArtist()
self.currentTrack[1] = self.spotify.getCurrentTrack()
else:
self.nothingPlayed = ["Not playing anything...", '']
except:
pass
if self.prevTrack <> self.currentTrack:
self.TriggerEvent('CurrentArtistTrack', payload = self.currentTrack)
self.prevTrack = self.currentTrack
self.nothingPlayed = ['', '']
self.prevNothing = ['', '']
if self.prevNothing <> self.nothingPlayed:
self.TriggerEvent('CurrentArtistTrack', payload = self.nothingPlayed)
self.prevNothing = self.nothingPlayed
self.currentTrack = ['', '']
self.prevTrack = ['', '']
self.CCT_Task = eg.scheduler.AddTask(
1.0,
self.CheckCurrentTrack
)
When you stop the plugin, I recommend a cleanup of remaining not yet triggered schedules
Code: Select all
def __stop__(self):
try:
eg.scheduler.CancelTask(self.CCT_Task)
except:
pass
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
Re: SONOS Plugin
hi krambriw,Hi, you could consider to use the eg.scheduler. I assume it is running in multiple threads and in this way, you are making use of an EG built-in.
Thanks for the suggestion. Correct me if i'm wrong but isn't the eg.scheduler based on calling functions at specific times? the way SONOS works is that you subscribe to events and then SONOS will sent you an update anytime a variable you are subscribed to has changed so it's nearly instant and you don't have to poll. To do this I need to setup a small server that listens for these event updates and this is what I would use threading or asyncore for. To subscribe, you do have to send a renewal every x seconds so I probably can use the eg.scheduler for that at least.
I have some code that works by subscribing and listening for events for one ZP but it breaks when using multiple ZPs. It's also poorly written. So i'm working on fixing it and implementing it in a better more efficient manner.
Thanks,
Chase
The Latest SONOS Plugin:
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309
EventGhost Lets me automate my home the way I want it, I love using it!
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309
EventGhost Lets me automate my home the way I want it, I love using it!
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: SONOS Plugin
Yes, sure, then I did misunderstand you...I thought you had to do polling...only in that case I would have used the eg.scheduler (I have an implementation where I schedule function calls to happen within 0.05 seconds and it is working excellent).
In your case, if you need to have several servers, I would of course also use threads. To manage threads, you could have a look at MQTT plugin. The plugin has a list view where it shows running subscriber threads and there are buttons to abort and restart them as well.
BestR Walter
In your case, if you need to have several servers, I would of course also use threads. To manage threads, you could have a look at MQTT plugin. The plugin has a list view where it shows running subscriber threads and there are buttons to abort and restart them as well.
BestR Walter
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM