• 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
Trying to activate relay/gpio with remote control 433 mhz
#1
Tongue 
Hey,

I am trying to set a gpio pin of my raspberry pi for a short time on power by a little remote control whose signal I am able to receive with pilight.

pilight-receive with remote control:
Code:
    "message": {
        "systemcode": 23,
        "unitcode": 1,
        "state": "closed"
    },
    "origin": "receiver",
    "protocol": "sc2262",
    "uuid": "0000-XX-XX-eb-XXXc8",
    "repeats": 1
}

I have two devices, my remote (german: funkfernbedienung ;) and the switch1/relay connected to the correct wiringPi pin 0. Sending and receiving signals with pilight is working fine (pilight-send & pilight-receive).
Now I am trying to add a rule like "IF funkfernbedienung.state IS closed THEN switch DEVICE switch1.state TO on". Pereferabely only for one second or less and switch funkfernbedienung.state afterwards to "opened" again.
If I add this rule, I get an errors stating "pilight-daemon: ERROR: device "off" doesn't exists". :/

Maybe someone has an advise for me?
Thanks, Michael

/etc/pilight/config.json:
Code:
{
        "devices": {
                "funkfernbedienung": {
                        "protocol": [ "sc2262" ],
                        "id": [{
                                "systemcode": 23,
                                "unitcode": 1
                        }],
                        "state": "opened"
                },
                "switch1": {
                        "protocol": [ "relay" ],
                        "id": [{
                                "gpio": 0
                        }],
                        "state": "off"
                }
        },
        "rules": {},
        "gui": {
                "funkfernbedienung": {
                        "name": "Tuer oeffnen",
                        "group": [ "Eingang" ],
                        "media": [ "all" ]
                }
        },
        "settings": {
                "log-level": 6,
                "pid-file": "/var/run/pilight.pid",
                "log-file": "/var/log/pilight.log",
                "webserver-enable": 1,
                "webserver-root": "/usr/local/share/pilight/",
                "webserver-http-port": 5001,
                "webserver-cache": 1
        },
        "hardware": {
                "433gpio": {
                        "sender": 2,
                        "receiver": 1
                }
        },
        "registry": {
                "webgui": {
                        "tabs": 0
                },
                "pilight": {
                        "version": {
                                "current": "7.0"
                        }
                }
        }
}
 
Reply
#2
Your rule should be
Code:
"......THEN switch DEVICE switch1 TO on"
.

So without .state
 
Reply
#3
Great, thanks for your help.

Furthermore, I got it working to start a shell script but unfortunately only once after starting pilight. Some state ist not being resetted I guess. My remote only sends "closed" signals, so default in the config is opened (device funkfernbedienung).

Execute program and switch funkfernbedienung back to opened:
Code:
"rule": "IF funkfernbedienung.state IS closed THEN switch DEVICE testProgram TO running AND switch DEVICE funkfernbedienung TO opened",

Does this rule make sense for switching funkfernbedienung to opened right after program execution?

The whole config so far:
Code:
{
        "devices": {
                "funkfernbedienung": {
                        "protocol": [ "sc2262" ],
                        "id": [{
                                "systemcode": 23,
                                "unitcode": 1
                        }],
                        "state": "opened"
                },
                "testProgram": {
                        "protocol": [ "program" ],
                        "id": [{
                                "name": "test"
                        }],
                        "name": "test",
                        "program": "/bin/bash",
                        "arguments": "/home/pi/open_door.sh",
                        "stop-command": "kill -9 $(pgrep open_door.sh)",
                        "start-command": "/bin/bash /home/pi/open_door.sh >/dev/null 1>/dev/null 2>/dev/null &",
                        "state": "stopped",
                        "pid": 0
                }
        },
        "rules": {
                "opendoor": {
                        "rule": "IF funkfernbedienung.state IS closed THEN switch DEVICE testProgram TO running AND switch DEVICE funkfernbedienung TO opened",
                        "active": 1
                }
        },
        "gui": {
                "funkfernbedienung": {
                        "name": "Tuer oeffnen",
                        "group": [ "Eingang" ],
                        "media": [ "all" ]
                }
        },
        "settings": {
                "log-level": 6,
                "pid-file": "/var/run/pilight.pid",
                "log-file": "/var/log/pilight.log",
                "webserver-enable": 1,
                "webserver-root": "/usr/local/share/pilight/",
                "webserver-http-port": 5001,
                "webserver-cache": 1
        },
        "hardware": {
                "433gpio": {
                        "sender": 2,
                        "receiver": 1
                }
        },
        "registry": {
                "webgui": {
                        "tabs": 0
                },
                "pilight": {
                        "version": {
                                "current": "7.0"
                        }
                }
        }
}
 
Reply
#4
You won't be able to do a switch action on a device using the sc2261 protocol, because sc2261 is a contact sensor protocol and not a switch, relay or dimmer protocol.

A real contact sensor will send different codes when it is opened vs closed and the state of the device will then reflect the last one of those. In your case the remote is recognized as a contact sensor only sending "closed".

What you can try is:

Code:
IF sc2262.systemcode == 23 AND sc2262.unitcode == 1 AND sc2261.state IS closed THEN switch DEVICE relay TO on FOR 1 SECOND

Every time you press the remote this rule should fire and switch the relay to on for a second. Of course you can put in your own relay device name and the time the relay is kept in the on state.

I cannot guarantee however that it will work for your remote. It doesn't work for my Kaku remote for instance, while it does work for at least one of my other remotes.
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  Real 433Mhz Remote is disturbed by pilight service henne111 2 162 10-06-2019, 06:18 PM
Last Post: wo_rasp
  Raspberry PI, gpio-ir-tx and pilight not starting lordslash 5 868 06-11-2019, 05:19 PM
Last Post: curlymo
  GPIO input -> starting a rule scootermacro 1 201 06-09-2019, 07:40 AM
Last Post: curlymo
  Remote with two crystals 10.000mhz and 7.3728 MSTNGSPRTS 0 155 04-18-2019, 10:33 PM
Last Post: MSTNGSPRTS
  error pilightsend, recieve and control hansipi 2 454 11-04-2018, 03:46 PM
Last Post: hansipi
  [solved] kwmobile: repeating the remote signal doesn't work dawncrow 9 943 10-25-2018, 03:46 PM
Last Post: dawncrow
  ["SOLVED"] Not able to control intertechno ITR-1500 Kambaramba 12 1,524 10-03-2018, 05:52 PM
Last Post: curlymo
  Segmentation fault wth gpio-platform raspberrypi1b1 meloen 12 1,229 09-10-2018, 07:44 PM
Last Post: curlymo
  [SOLVED] Home Assistant switch gpio segalion 5 811 09-10-2018, 12:39 PM
Last Post: segalion
Rainbow Trying to control RF Celling FAN bennyboy 0 375 06-23-2018, 05:49 PM
Last Post: bennyboy

Forum Jump:


Browsing: 1 Guest(s)