piBeacon: presence monitoring plugin discussions
Re: piBeacon: presence monitoring plugin discussions
Yes I know.
As a prel fix you could go in and delete the file.
I could release an intermittent version that just fixed that. But I would like to complete the sensor stuff and release everything at once.
Sent from my iPhone using Tapatalk
As a prel fix you could go in and delete the file.
I could release an intermittent version that just fixed that. But I would like to complete the sensor stuff and release everything at once.
Sent from my iPhone using Tapatalk
Re: piBeacon: presence monitoring plugin discussions
Hi Karl. This is maybe a long shot, but anyway.
I have just started to use a wifi module for my roomba called thinkingcleaner. This module has an option to configure a web hook. This web hook does not contain any information, only a message that status should now be polled. Since it only support http and not https, I am unable to get it to work natively with indigo. Could it be possible to listen for this at the rP?
Could this be done?
I have just started to use a wifi module for my roomba called thinkingcleaner. This module has an option to configure a web hook. This web hook does not contain any information, only a message that status should now be polled. Since it only support http and not https, I am unable to get it to work natively with indigo. Could it be possible to listen for this at the rP?
Code: Select all
WEBHOOK (web callback or HTTP push API, available in firmware 1.0.80 and newer) :
The web hook setting will eliminate the need for constant polling the Thinking Cleaner status.
In the web-app on the “Options” page click on advanced settings and the web hook settings will show. You can set a webhook address, path and portnumber. Thinking Cleaner will make a HTTP GET request to your service on every status change. No information is sent with the hook so you use it to trigger a json request to get the info you want.
1) Only HTTP requests, we do not support HTTPS yet.
2) To switch off, leave the webhook field empty
3) The maximum length of both the webhook url and path is 64 characters Håvard
Re: piBeacon: presence monitoring plugin discussions
Thanks for the info, Karl. I just wanted to make sure you were aware of it. Waiting for your next release is fine. I can keep an eye on it.
Re: piBeacon: presence monitoring plugin discussions
that would require a web server on the py.I have just started to use a wifi module for my roomba called thinkingcleaner. This module has an option to configure a web hook. This web hook does not contain any information, only a message that status should now be polled. Since it only support http and not https, I am unable to get it to work natively with indigo. Could it be possible to listen for this at the rP?
I am only using a lower level socket server. But it should be able to receive the message too. But difficult to do without having the exact strings send...
you could setup a SIMPLE python web server on indigo just to test.
This starts a web server on you mac, open terminal and type:
Code: Select all
python -m SimpleHTTPServer 8000Just a starting point
Karl
Re: piBeacon: presence monitoring plugin discussions
Thanks Karl. I can play with that tomorrow and see what it returns. I did manage to get some feedback from the cynical network plugin, but I am not sure this is the optimal solution. And I am unsure if the plugin is still maintained.
Håvard
Re: piBeacon: presence monitoring plugin discussions
Hi Karl.
I ran the terminal code you suggested and got the following output when I activated. This is a message that should tell my system that the state of the roomba has change so you should poll status.
I ran the terminal code you suggested and got the following output when I activated. This is a message that should tell my system that the state of the roomba has change so you should poll status.
Code: Select all
MiniServer:~ Server$ python -m SimpleHTTPServer 6193
Serving HTTP on 0.0.0.0 port 6193 ...
192.168.1.114 - - [05/Feb/2016 18:17:30] code 404, message File not found
192.168.1.114 - - [05/Feb/2016 18:17:30] "GET /webhook.html?timestamp=1454696250 HTTP/1.0" 404 -
192.168.1.114 - - [05/Feb/2016 18:17:39] code 404, message File not found
192.168.1.114 - - [05/Feb/2016 18:17:39] "GET /webhook.html?timestamp=1454696259 HTTP/1.0" 404 -
192.168.1.114 - - [05/Feb/2016 18:17:40] code 404, message File not found
192.168.1.114 - - [05/Feb/2016 18:17:40] "GET /webhook.html?timestamp=1454696260 HTTP/1.0" 404 -Håvard
Re: piBeacon: presence monitoring plugin discussions
i guess that mean it send a GET request for " webhook.html"
try the attached code:
create file
copy and paste the code, CTRL-o to save , CTRL-x to exit
then
see what happens
Karl
try the attached code:
Code: Select all
ssh pi@yourpi-ipnumberCode: Select all
nano roomba.py then
Code: Select all
sudo python roomba.py 6193Karl
Code: Select all
# by Karl Wachs
# feb 5
# try to get roomba command
##
import SocketServer
import sys,subprocess, os
class MyTCPHandler(SocketServer.BaseRequestHandler):
"""
The RequestHandler class for our server.
It is instantiated once per connection to the server, and must
override the handle() method to implement communication to the
client.
"""
def handle(self):
# self.request is the TCP socket connected to the client
self.data = self.request.recv(1024).strip()
print self.client_address
print self.data
if unicode(self.data).find:
print "roomba send command"
return
def getIPaddress():
# find my IP number
ret = subprocess.Popen("ifconfig " ,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate()
sep=""
if "\r" in ret[0]: sep+="\r"
if "\n" in ret[0]: sep+="\n"
out=ret[0].split(sep)
for line in out:
if line.find("inet addr:")==-1: continue
if line.find("Bcast:") ==-1: continue
if line.find("127.0.0.1") >-1: continue
ipAddress=line.split("addr:")[1]
ipAddress=ipAddress.split(" ")[0]
return ipAddress
return ""
if __name__ == "__main__":
PORT = int(sys.argv[1])
ipAddress=getIPaddress()
# Create the server, binding on port # from command line
server = SocketServer.TCPServer((ipAddress, PORT), MyTCPHandler)
# Activate the server; this will keep running until you
# interrupt the program with Ctrl-C
server.serve_forever()
Re: piBeacon: presence monitoring plugin discussions
on my mac i did:
the rpi saw this:
seems to work!!
Next step is what do you want to do with it, we could change a state on a device in indigo..
Karl
Code: Select all
curl 192.168.1.21:9898Code: Select all
sudo python roomba.py 9898
('192.168.1.176', 61593)
GET / HTTP/1.1
Host: 192.168.1.21:9898
User-Agent: curl/7.43.0
Accept: */*
roomba send commandNext step is what do you want to do with it, we could change a state on a device in indigo..
Karl
Re: piBeacon: presence monitoring plugin discussions
or you could run the code on the mac and with plugin SATI trigger an event or create a file and listen for change, or put the script into an indigo external script that sets a variable ...
Karl
Karl
Re: piBeacon: presence monitoring plugin discussions
This code actually works:
1. save into file on your mac e.g. roomba.py in ~/ documents/indigo (or anything you like) and change IP and port to what you want to have
2. create action group roomba
3. add action "execute Script( script ..) " select external file and enter the path .. of the roomba.py file
4. execute action group
every time roomba sends a web hook.html command a variable "roomba" will be updated with the current date time stamp. and then you can trigger on any change in the variable.
hope that helps.
Karl
ps you MUST manually delete old roomba actions running in a terminal session
ps -ef | grep roomba.py
kill -9 PID of the process
other wise you will see an error message:
we could change that by kill any old roomba.py process when a new one starts.. but thats for tomorrow
1. save into file on your mac e.g. roomba.py in ~/ documents/indigo (or anything you like) and change IP and port to what you want to have
2. create action group roomba
3. add action "execute Script( script ..) " select external file and enter the path .. of the roomba.py file
4. execute action group
every time roomba sends a web hook.html command a variable "roomba" will be updated with the current date time stamp. and then you can trigger on any change in the variable.
hope that helps.
Karl
ps you MUST manually delete old roomba actions running in a terminal session
ps -ef | grep roomba.py
kill -9 PID of the process
other wise you will see an error message:
Code: Select all
Script Error roomba.py: [Errno 48] Address already in use
Script Error Exception Traceback (most recent call shown last):
roomba.py, line 42, at top level
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py", line 402, in __init__
self.server_bind()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py", line 413, in server_bind
self.socket.bind(self.server_address)
roomba.py, line -1, in bind
error: [Errno 48] Address already in use
Code: Select all
# by Karl Wachs
# feb 5
# get roomba command web hook into variable roomba
##
import SocketServer
import datetime
class MyTCPHandler(SocketServer.BaseRequestHandler):
"""
The RequestHandler class for our server.
It is instantiated once per connection to the server, and must
override the handle() method to implement communication to the
client.
"""
def handle(self):
# self.request is the TCP socket connected to the client
self.data = self.request.recv(1024).strip()
indigo.server.log( unicode(self.client_address))
indigo.server.log( unicode(self.data))
if unicode(self.data).find("webhook.html")>-1:
indigo.server.log( "roomba send command")
indigo.variable.updateValue("roomba",datetime.datetime.now().strftime("%Y%m%d-%H:%M:%S"))
return
if __name__ == "__main__":
PORT = 9898
ipAddress="192.168.1.136"
try:
indigo.variable.create("roomba","")
except:
pass
myPID = str(os.getpid())
indigo.server.log(" PID of roomba server is:" +myPID + " before you start this again, please kill old process in terminal" )
# Create the server, binding on port xxxx
server = SocketServer.TCPServer((ipAddress, PORT), MyTCPHandler)
# Activate the server; this will keep running until you
# interrupt the program with Ctrl-C
server.serve_forever()
Re: piBeacon: presence monitoring plugin discussions
just to finish it.
this one will kill the old process before starting the new one.
Karl
this one will kill the old process before starting the new one.
Karl
Code: Select all
# by Karl Wachs
# feb 5
# try to get roomba command
##
import SocketServer
import datetime, subprocess, os, time
class MyTCPHandler(SocketServer.BaseRequestHandler):
def handle(self):
# self.request is the TCP socket connected to the client
self.data = self.request.recv(1024).strip()
#indigo.server.log( unicode(self.client_address))
#indigo.server.log( unicode(self.data))
if unicode(self.data).find("webhook.html")>-1:
indigo.server.log( "roomba send command")
indigo.variable.updateValue("roomba",datetime.datetime.now().strftime("%Y%m%d-%H:%M:%S"))
return
def killOldPgm(myPID,pgmToKill):
cmd= "ps -ef | grep "+pgmToKill+" | grep -v grep"
ret = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate()[0]
lines=ret.split("\n")
for line in lines:
if len(line) < 10: continue
line=line.split()
pid=int(line[1])
if pid == int(myPID): continue
os.system("kill -9 "+str(pid))
indigo.server.log( "killed program: "+pgmToKill+" pid="+str(pid))
time.sleep(5)
if __name__ == "__main__":
PORT = 9898 ## port number used by roomba
ipAddress="192.168.1.136" ## ip number of your indigo MAC
try:
indigo.variable.create("roomba","")
except:
pass
myPID = str(os.getpid())
indigo.server.log(" PID of roomba server is:" +myPID )
killOldPgm(myPID,"roomba.py")
# Create the server, binding on port xxx
server = SocketServer.TCPServer((ipAddress, PORT), MyTCPHandler)
# Activate the server; this will keep running until you
# interrupt the program with Ctrl-C
server.serve_forever()
Re: piBeacon: presence monitoring plugin discussions
Wow Karl. That is incredible. I have been away from my computer all night, and am on my phone now, so I have not been able to test it yet. But this definitely looks like it can work! Thanks a lot.
Håvard
Re: piBeacon: presence monitoring plugin discussions
Thanks again Karl.
I am about to start playing with this now. Just I have an understanding for what is happening. This script starts a server that is listening on the specified port. Correct? How can I stop this server if that is needed? Is this taking much resources?
I am about to start playing with this now. Just I have an understanding for what is happening. This script starts a server that is listening on the specified port. Correct? How can I stop this server if that is needed? Is this taking much resources?
Håvard
Re: piBeacon: presence monitoring plugin discussions
Since this is no longer directly related to the piBeacon plugin, I started a new topic that covers the work with thinkingcleaner roomba interface.
http://forums.indigodomo.com/viewtopic. ... 64&t=15596
http://forums.indigodomo.com/viewtopic. ... 64&t=15596
Håvard
Re: piBeacon: presence monitoring plugin discussions
Hi,
I installed the latest version v-1.8.1. and configured my two rPi's. I notice that the load on the rPi's is higher then before:
top - 10:07:14 up 2:38, 1 user, load average: 1.33, 0.95, 0.81
Is this a result of this version being able to use the GPIO of the rPi?
Wouter
I installed the latest version v-1.8.1. and configured my two rPi's. I notice that the load on the rPi's is higher then before:
top - 10:07:14 up 2:38, 1 user, load average: 1.33, 0.95, 0.81
Is this a result of this version being able to use the GPIO of the rPi?
Wouter