NetHome with EventGhost
-
- Posts: 12
- Joined: Thu Jan 08, 2015 7:04 pm
NetHome with EventGhost
Is there any support with EventGhost? My need: I want my Sonos to start playing a spesific playlist when a particular lamp is "ON".
Re: NetHome with EventGhost
Nethome can execute sh commands or with perl you can sent TCP or udp messages can you tell how you activate that sonos play?
Re: NetHome with EventGhost
I might be guessing but I think that 'heggholmen' has found out that there is a plugin for Sonos available in EventGhost. If this is correctly understood, he is looking for methods how to generate events in EventGhost from NetHome to trigger actions for his Sonos system.
One way that could be used I have described here:
viewtopic.php?f=5&t=11#p47
One way that could be used I have described here:
viewtopic.php?f=5&t=11#p47
Re: NetHome with EventGhost
ok i can try look some ideas that eventghost trigger at later today.
Re: NetHome with EventGhost
@nasty76
First, let 'heggholmen' work & read a bit...and better define his wishes
First, let 'heggholmen' work & read a bit...and better define his wishes
-
- Posts: 12
- Joined: Thu Jan 08, 2015 7:04 pm
Re: NetHome with EventGhost
Hi guys
Yes - there is already a working plugin for Sonos in EventGhost - so the description from krambriw is 100% correct.
Earlier I used SwitchKing, but i experienced very bad respond using SwitchKing when I had motiondetectors that should trigger lamps. With NetHome this works so much better:):)
Your solution krambriw, should fit my need also. Would you share a step by step guide (if it's much work, just give me some hints, and I'll try:) ) - and your python script?
Yes - there is already a working plugin for Sonos in EventGhost - so the description from krambriw is 100% correct.
Earlier I used SwitchKing, but i experienced very bad respond using SwitchKing when I had motiondetectors that should trigger lamps. With NetHome this works so much better:):)
Your solution krambriw, should fit my need also. Would you share a step by step guide (if it's much work, just give me some hints, and I'll try:) ) - and your python script?
Re: NetHome with EventGhost
Okay, I hope you run NetHome in a RaspberryPi (RPi) since the description will be based on that assumption.
1) You have a working RPi with NetHome installed & functioning
2) Now install Mosquitto, follow this instruction, http://mosquitto.org/2013/01/mosquitto- ... epository/ or simply issue the following commands from a putty session
3) Now you have to copy two files to your /home/pi/ folder in the RPi:
- mosquitto.py
- MQTTevents.py
Since this forum is not allowing attachments, I have provided them for download from here:http://sto.hopto.org/Under%20constructi ... enNetHome/
4) Fix so that the python script starts at boot, in a putty session, type crontab -e, add this as the last line
5) Reboot your RPi
6) After reboot, from a putty session, type 'ps aux' and check that the script is running and that you see in the list of processes that mosquitto is also running
7) Now is time to move to EventGhost
8) Install MQTT Client plugin, configure a client action to connect to your RPi (ip =????, port=1883, topic = /nethomeserver )
9) Execute MQTT Client action (run with green icon button) to connect to the Mosquitto broker and soon you should start to see events from NetHome coming into EventGhost log
10) Once you have reached here, we will discuss how to use the events for your Sonos control
1) You have a working RPi with NetHome installed & functioning
2) Now install Mosquitto, follow this instruction, http://mosquitto.org/2013/01/mosquitto- ... epository/ or simply issue the following commands from a putty session
Code: Select all
wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
cd /etc/apt/sources.list.d/
sudo wget http://repo.mosquitto.org/debian/mosquitto-wheezy.list
apt-get update
apt-get install mosquitto
- mosquitto.py
- MQTTevents.py
Since this forum is not allowing attachments, I have provided them for download from here:http://sto.hopto.org/Under%20constructi ... enNetHome/
4) Fix so that the python script starts at boot, in a putty session, type crontab -e, add this as the last line
Code: Select all
@reboot python /home/pi/MQTTevents.py &
6) After reboot, from a putty session, type 'ps aux' and check that the script is running and that you see in the list of processes that mosquitto is also running
7) Now is time to move to EventGhost
8) Install MQTT Client plugin, configure a client action to connect to your RPi (ip =????, port=1883, topic = /nethomeserver )
9) Execute MQTT Client action (run with green icon button) to connect to the Mosquitto broker and soon you should start to see events from NetHome coming into EventGhost log
10) Once you have reached here, we will discuss how to use the events for your Sonos control
Re: NetHome with EventGhost
oh you look handling that good , good I m total noob with event ghost , but do you guys know lets say we know what sonos want to start faforite song list. so we make example perl script example runmusic.pl
now we put there some perl code which sent sonos start command.
now we can execute that pl script via nethome example scene item and there you select exec function now we give only script path and allways when scene activate that run perl script too , I use this lot and that is handy to make something outside nethome.
here is example how I read onewire temp via raspi gpio pin and sent them upd to nethome , I have nethome item ds1820 temp plugin which I code my self , but generic upm thermometer work too. there is my perl script.
now we put there some perl code which sent sonos start command.
now we can execute that pl script via nethome example scene item and there you select exec function now we give only script path and allways when scene activate that run perl script too , I use this lot and that is handy to make something outside nethome.
here is example how I read onewire temp via raspi gpio pin and sent them upd to nethome , I have nethome item ds1820 temp plugin which I code my self , but generic upm thermometer work too. there is my perl script.
Code: Select all
#!/usr/bin/perl
use strict;
use warnings;
use IO::Socket;
my $device = "10-0008028fd655";
my $ret = 9999; # default to return 9999 (fail)
my $sensordata = `cat /sys/bus/w1/devices/$device/w1_slave 2>&1`;
# print "Read: $sensordata";
if(index($sensordata, 'YES') != -1) {
#fix for negative temps from http://habrahabr.ru/post/163575/
$sensordata =~ /t=(\D*\d+)/i;
#$sensor_temp =~ /t=(\d+)/i;
$sensordata = (($1/1000));
$ret = $sensordata*1000;
#sent tcp packet nethome
my $sock = IO::Socket::INET->new(
Proto => 'udp',
PeerPort => 8005,
PeerAddr => '127.0.0.1',
) or die "Could not create socket: $!\n";
print $sock "event,UPM_Message,Direction,In,UPM.DeviceCode,2,UPM.HouseCode,1,UPM.Primary,$ret,UPM.Secon$
} else {
}
Re: NetHome with EventGhost
There are many, many ways to send a message to EventGhost from "outside". There are plugins supporting listening for incoming events on UDP, TCP, HTTP and many more I do not even remember now. I just mentioned MQTT because I like using a message broker...but I have also used the others from time to timebut do you guys know lets say we know what sonos want to start
-
- Posts: 12
- Joined: Thu Jan 08, 2015 7:04 pm
Re: NetHome with EventGhost
Thanks a lot krambriw!! I'm running Windows - but that's my concern:) I'll give it a try - if not I have to find my RPi, I know it's somewhere:)