• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Done] pilight-cron (implemented with eventing)
#31
I know the problem, I had a bug in the pilight.py, it did not correct using de SSDP it always go to 127.0.0.1:5000 no mather what you try te configure Wink

I fixed this and create some other tools to work with pilight.

NOTE: if you want to run this command's you need to put pilight.py in the same directory as the script runs.

Code:
pilight-config
This function will output the current running config of pilight in json format.
Code:
pilight-query
You can use this to get values of a state of one lamp like:

Example:
Code:
pilight-query -l woonkamer -d lamp3 -o state
output: off or on
Code:
pilight-query -l woonkamer -d asun1 -o state
output: down or up

Code:
pilight-events
This will run command's if you setup /etc/pilight/events.json, if one changed the other in that group will also change.

You find an example in python-pilight-config.tar.gz

Code:
pilight-cron
This will run command's on time you put in /etc/pilight/cron.json

You find an example in python-pilight-config.tar.gz

Code:
pilight-cron-update
This will run update time values of /etc/pilight/cron.json if that contain an option sunrise or sunset.

NOTE: if you want to use pilight-cron-update:
You need to install python-pip
And that pip install tzlocal to run this function.


I run this normaly on 04:00 at night.

Code:
* *     * * *   root    /usr/local/bin/pilight-cron
0 4     * * *   root    /usr/local/bin/pilight-cron-update

If you want to use this python extention in your own scripts.

You need to following to run it the right way:
Code:
import pilight

p=pilight.pilight()
if p.connect() == p.reply():
   # do your stuff
   p.close();
else:
   print "No connection"

The following functions are available:
Code:
is_json(variable)
Check is variable is json format
Code:
discover()

Discovers via SSDP server and port
Code:
connect(client,server,port)
Connects to pilight server
Code:
reply()
returns 'accept client'
Code:
controller(location,device,state,(optional: dim-level))
Send message to server only works of you connect as gui or controller
Code:
send(protocol,id,unit,state,(optional: dim-level))
Send message to server only works of you connect as sender
Code:
config()
returns config in json format
Code:
query(location,device,option1,(optional: option2))
returns value like a state or sunset
Code:
receive()
returns json codes what processed by the pilight-daemon
Code:
heart()
returns True or False if pilight-daemon sends BEAT or nothing.
Code:
close()
To close the connection to the socket.


Attached Files
.gz   python-pilight-config.tar.gz (Size: 383 bytes / Downloads: 24)
.gz   python-pilight-v0.2.tar.gz (Size: 4.77 KB / Downloads: 25)
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  [Done] pilight config read access for all gneandr 1 2,029 03-25-2015, 01:46 PM
Last Post: curlymo
  [Done] Eventing - operators MOD and DIV Niek 54 18,779 02-19-2015, 12:01 AM
Last Post: Niek
  [Done] pilight eventing - dimming step by step terrar 3 2,807 02-11-2015, 02:39 PM
Last Post: Niek
  [Done] pilight-daemon -V - currently requires root access clach04 1 2,484 10-25-2014, 11:39 PM
Last Post: wo_rasp
  [Done] pilight api: receiving and sending as gui client sweetpi 3 3,576 05-19-2014, 04:39 PM
Last Post: curlymo
  [Done] Continuous pilight-debug Tommybear1979 1 1,927 05-15-2014, 09:12 PM
Last Post: curlymo
  [Done] Eventlist (implemented with eventing) JurnD 18 7,248 01-16-2014, 08:39 PM
Last Post: curlymo
  [Done] auto detect pilight (for mobile/desktop apps) (SSDP) Martin 6 4,384 11-30-2013, 06:51 PM
Last Post: curlymo
  [Done] Message from pilight d.m.raspberry 5 2,858 09-23-2013, 10:25 AM
Last Post: curlymo

Forum Jump:


Browsing: 1 Guest(s)