• 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:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
action: program
#1
I'd like to start/stop a program with a rule.
As I understand this is not yet a possibility.
 
Reply
#2
Why not?
Code:
"xbmcProgram": {
    "protocol": [ "program" ],
    "id": [{
        "name": "xbmc"
    }],
    "program": "/usr/local/lib/kodi/kodi.bin",
    "arguments": "",
    "stop-command": "service kodi stop",
    "start-command": "service kodi start",
    "state": "running",
    "pid": 4487
}

Code:
IF 1 == 1 THEN switch DEVICE xbmcProgram TO running
 
Reply
#3
Well... that works too.
Never realized switching to "running" was an option.
 
Reply
#4
The switch protocol works with "states" Smile
 
Reply
#5
Hello,
I would like to run a bash script or a python program written by myself with a pilight rule.
Is this possible?
I searched through the wiki and the forum without a hint. I found several hints to start and stop xbmc, but not hints / examples to start scripts
Thanks in advanced
 
Reply
#6
Yes, it is possible, I've written about it here:
http://forum.pilight.org/Thread-Action-R...8#pid15178
 
Reply
#7
Works perfekt TX alot!!!!
 
Reply
#8
I tried the example of pilino1234, but this isn't working for me. Here's my config.json. When I use the switch, both rules are processed?! What am I doing wrong?

Code:
{
    "devices": {
        "LC_eettafel": {
            "protocol": [ "program" ],
            "id": [{
                "name": "lc0"
            }],
            "program": "/bin/bash",
            "arguments": "",
            "stop-command": "sudo /home/pi/bin/controllc.sh u0",
            "start-command": "sudo /home/pi/bin/controllc.sh a0",
            "state": "stopped",
            "pid": 0
        },
        "LivingColors_eettafel": {
            "protocol": [ "generic_switch" ],
            "id": [{
                "id": 0
            }],
            "state": "off"
        }
    },
    "rules": {
        "LC_eettafel_aan": {
            "rule": "IF LivingColors_eettafel.state IS on THEN switch DEVICE LC_eettafel TO running",
            "active": 1
        },
                "LC_eettafel_uit": {
                        "rule": "IF LivingColors_eettafel.state IS off THEN switch DEVICE LC_eettafel TO stopped",
                        "active": 1
        }
    },
    "gui": {
        "LivingColors_eettafel": {
            "name": "LivingColors eettafel",
            "group": [ "Woonkamer" ],
            "media": [ "all" ]
        }
    },
 
Reply
#9
Both rules should be processed as a device that they depend on changed state. But only one of them should actually be executed and switch the state of your program.
Not sure why it doesn't work, can you post pilight-daemon -D output please?
 
Reply
#10
You mean one device for stop-command and one device for start-command?
Hereby the log:

Code:
[Dec 15 19:34:23:586782] pilight-daemon: DEBUG: socket recv: {"action":"control","code":{"device":"LivingColors_eettafel","state":"on"}}
[Dec 15 19:34:23:587928] pilight-daemon: DEBUG: socket write succeeded: {"status":"success"}

[Dec 15 19:34:23:589498] pilight-daemon: DEBUG: socket write succeeded: {"origin":"update","type":1,"devices":["LivingColors_eettafel"],"values":{"timestamp":1450208063,"state":"on"}}

[Dec 15 19:34:23:589955] pilight-daemon: DEBUG: broadcasted: {"origin":"update","type":1,"devices":["LivingColors_eettafel"],"values":{"timestamp":1450208063,"state":"on"}}
[Dec 15 19:34:23:590571] pilight-daemon: DEBUG: socket write succeeded: {"origin":"update","type":1,"devices":["LivingColors_eettafel"],"values":{"timestamp":1450208063,"state":"on"}}

[Dec 15 19:34:23:590994] pilight-daemon: DEBUG: broadcasted: {"origin":"update","type":1,"devices":["LivingColors_eettafel"],"values":{"timestamp":1450208063,"state":"on"}}
[Dec 15 19:34:23:591442] pilight-daemon: DEBUG: broadcasted: {"origin":"sender","protocol":"generic_switch","message":{"id":0,"state":"on"},"repeat":1,"uuid":"0000-b8-27-eb-7a3fa7"}
[Dec 15 19:34:23:592631] pilight-daemon: INFO: executed rule: LC_eettafel_aan
[Dec 15 19:34:23:593082] pilight-daemon: DEBUG: rule #1 LC_eettafel_aan was parsed in 0.000960 seconds
[Dec 15 19:34:23:593566] pilight-daemon: DEBUG: rule #2 LC_eettafel_uit was parsed in 0.000123 seconds
[Dec 15 19:34:23:592663] pilight-daemon: INFO: started "switch" action for device "LC_eettafel"
[Dec 15 19:34:23:606116] pilight-daemon: INFO: stopped "switch" action for device "LC_eettafel"
[Dec 15 19:34:23:606414] pilight-daemon: DEBUG: aborting running "switch" action for device "LC_eettafel"
[Dec 15 19:34:23:607201] pilight-daemon: DEBUG: socket write succeeded: {"origin":"update","type":7,"devices":["LC_eettafel"],"values":{"timestamp":1450208063,"state":"running"}}

[Dec 15 19:34:23:607384] pilight-daemon: DEBUG: broadcasted: {"origin":"update","type":7,"devices":["LC_eettafel"],"values":{"timestamp":1450208063,"state":"running"}}
[Dec 15 19:34:23:607989] pilight-daemon: DEBUG: socket write succeeded: {"origin":"update","type":7,"devices":["LC_eettafel"],"values":{"timestamp":1450208063,"state":"running"}}

[Dec 15 19:34:23:608129] pilight-daemon: DEBUG: broadcasted: {"origin":"update","type":7,"devices":["LC_eettafel"],"values":{"timestamp":1450208063,"state":"running"}}
[Dec 15 19:34:23:608420] pilight-daemon: DEBUG: broadcasted: {"message":{"name":"lc0","state":"running"},"origin":"receiver","protocol":"program","uuid":"0000-b8-27-eb-7a3fa7"}
[Dec 15 19:34:23:609599] pilight-daemon: DEBUG: socket write succeeded: {"origin":"update","type":7,"devices":["LC_eettafel"],"values":{"timestamp":1450208063,"state":"pending"}}

[Dec 15 19:34:23:609753] pilight-daemon: DEBUG: broadcasted: {"origin":"update","type":7,"devices":["LC_eettafel"],"values":{"timestamp":1450208063,"state":"pending"}}
[Dec 15 19:34:23:610292] pilight-daemon: DEBUG: socket write succeeded: {"origin":"update","type":7,"devices":["LC_eettafel"],"values":{"timestamp":1450208063,"state":"pending"}}

[Dec 15 19:34:23:610415] pilight-daemon: DEBUG: broadcasted: {"origin":"update","type":7,"devices":["LC_eettafel"],"values":{"timestamp":1450208063,"state":"pending"}}
[Dec 15 19:34:23:610625] pilight-daemon: DEBUG: broadcasted: {"origin":"sender","protocol":"program","message":{"name":"lc0","state":"pending"},"repeat":1,"uuid":"0000-b8-27-eb-7a3fa7"}
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  _VARSTORE_ set action fourty2 1 1,019 05-19-2019, 09:07 PM
Last Post: curlymo
  skipping overridden action switch do1eh 2 680 01-19-2019, 05:25 PM
Last Post: do1eh
  http action Niek 21 4,632 08-12-2018, 11:44 AM
Last Post: rorie
  Program can't be set to state running Gisto 7 1,279 07-17-2018, 12:51 PM
Last Post: Gisto
  Problem with executing bash script via rule/program dYna 1 1,030 02-15-2018, 09:06 PM
Last Post: dYna
  action: Pushbullet bazb 24 12,081 01-04-2018, 08:38 PM
Last Post: curlymo
  action: pushover Niek 36 18,305 12-03-2017, 11:13 AM
Last Post: Alex
  action: file Niek 14 4,285 06-23-2016, 04:02 PM
Last Post: Niek
  action: switch Niek 54 20,878 03-31-2016, 06:24 PM
Last Post: jjj
  action: toggle Niek 1 2,534 02-19-2016, 03:04 PM
Last Post: Joeks

Forum Jump:


Browsing: 1 Guest(s)