• 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)
#1
I have made an php script to run automatically set switches on or of at different times.

/etc/pilight/cron.json
Code:
{
        "timer1":
        {
                "location":"living",
                "state":"on",
                "sunset":"true", # Optional
                "day":["Sun,","Mon","Tue","Wed","Thu","Fri","Sat"], # Optional
                "time":"18:55",
                "devices":["lamp3",
                "lamp4",
                "lamp6"]
        }
}

my crontab:
Code:
* * * * * root /usr/bin/php /usr/local/bin/pilight-cron > /dev/null


Attached Files
.txt   pilight-cron.txt (Size: 2.02 KB / Downloads: 148)
.txt   pilight-lib.txt (Size: 838 bytes / Downloads: 104)
 
Reply
#2
Nice work, and great that someone started with some suggestions on how the event JSON structure should look like.
 
Reply
#3
I want to make an c version of the pilight-cron, I try to find how to use the json c files from you, but i can't find how to use them.
Is there a how to of how to use the json functions ?
 
Reply
#4
yes, with the json library that pilight uses as well. However, i do like to discuss first the structure of the json so we can have the best version directly.
 
Reply
#5
Example:
Code:
{
        "timer1":
        {
                "location":"living",
                "state":"on",
                "sunset":"true",
                "day":["Sun,","Mon","Tue","Wed","Thu","Fri","Sat"],
                "time":"18:55",
                "devices":["lamp3",
                "lamp4",
                "lamp6"]
        },
        "timer2":
        {
                "location":"living",
                "state":"off",
                "time":"00:13",
                "devices":["lamp3",
                "lamp4",
                "lamp6"]
        }
}

Current json options are in my cron file:
location:
state:
devices: (array or not)
time:

Optional:
day: ["Sun,","Mon","Tue","Wed","Thu","Fri","Sat"]
sunrise: "true"
sunset: "true"

sunset and sunrise option is use currently to update with a seperate file at 04:00 to update the times of sunset and sunrise.

These are the options that I use and a friend of mine.
 
Reply
#6
There are some downsides to your approach that i will explain later and i of course will offer some solutions to overcome those Smile

1. Not all devices have a on / off state, but can also have an up / down state.
2. For some devices the on / off doesn't cover the full state. Dimmers can be on but also have a specific dimlevel. So you need the ability to add specific values. pilight does this by using the following json object:
Code:
{
    "message": "send",
    "code": {
        "location": "living",
        "device": "mainlight",
        "state": "on",
        "values": {
            "dimlevel": "10"
        }
    }
}
3. You currently only support switching devices in a single location, i would like to see multiple locations supported.
4. You only have events that do things on a calender variable, but i would also like to see events triggered on a received code. E.g., if i turn on lamp1, i also want to turn on lamp2 and 3.
5. I currently have a script implemented that turns my bedlight dimmer into a wake-up light. So we need some sort of timer to turns on a dimmer to full in a certain period of time.

There are probably more things that needs adjustment but these where the ones i could come up with until know.

A big request and the most hardest one is to implement this all in a modular way. Just like pilight does with the protocols and hardwares. That way, we can have a calender plugin, wakeup plugin, and what plugins people can think off.
 
Reply
#7
Ok,

1), this was not an issues at all, you know i ask for the screen option up and down option, the problem was more an documentation issue that a technical issue
2) I have current one dimmer and used that not as much now, only if eat on the big table
But you are right, I didn't not create such thing currently.

3) Is currently I think a protocol issue, you need currently two or more timers to change lights on different locations.
Or i need the look at the api again, it think its fixable.

4) I had that already in my mind, but its not in this discussion about change devices (on, off, down or up), I liked the way that if its possible to turn lamp1 on and that lamp 2 en 3 also to turn on at the same time.

5) I had already make such thing like sleep option of php but not as good is i wanted.

But i have no idea how we can start to make this Crying my C is to bad.
 
Reply
#8
If you don't know how to do C, let's wait for other developers or let me pick it up some day.
 
Reply
#9
Option 4 needs i think a setting in the config like group

Code:
{
        "woonkamer": {
                "name": "Woonkamer",
                "lamp1": {
                        "name": "Lamp 1",
                        "protocol": [ "kaku_switch" ],
                        "id": [{
                                "id": 57695464,
                                "unit": 0
                        }],
                        "state": "off",
                        "group": 1
                },
                "lamp2": {
                        "name": "Computer",
                        "protocol": [ "kaku_switch" ],
                        "id": [{
                                "id": 57695464,
                                "unit": 1
                        }],
                        "state": "off",
                        "group": 1
                },
                "lamp3": {
                        "name": "Lamp Hoek",
                        "protocol": [ "kaku_switch" ],
                        "id": [{
                                "id": 57695464,
                                "unit": 2
                        }],
                        "state": "on",
                        "group": 2
                },
                "lamp3": {
                        "name": "Lamp Hoek2",
                        "protocol": [ "kaku_switch" ],
                        "id": [{
                                "id": 57695464,
                                "unit": 3
                        }],
                        "state": "on",
                        "group": 2
                }
}
 
Reply
#10
No, this should be done in the events.json. I really appreciate you thinking with me on this. Difficult stuff Smile
 
Reply
  


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

Forum Jump:


Browsing: 1 Guest(s)