• 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
How to detect subsequent ON or OFF signals from remote?
#1
My goal is to get a similar behaviour like the Kaku/Coco ASUN-650 sun blinds switch. From its manual:

(1) Send an ON-signal to raise the screen.
(2) Send an ON-signal again to stop.
(3) Send an OFF-signal to lower the screen.
(4) Send an OFF-signal again to stop.

So I'm looking for a way to do
Code:
IF (on received from remote) THEN switch DEVICE relayA TO on
IF (on received from remote) THEN switch DEVICE relayA TO off
IF (on received from remote) THEN switch DEVICE relayA TO on
...
IF (off received from remote) THEN switch DEVICE relayB TO on
IF (off received from remote) THEN switch DEVICE relayB TO off

But how can I detect subsequent ON or OFF signals with pilight? Or how can I detect if the button on the remote is actually pushed or released?

With pilight-receive I see the following:

Code:
... remote button ON pushed ...
{
    "message": {
        "systemcode": 4,
        "unitcode": 1,
        "state": "on"
    },
    "origin": "receiver",
    "protocol": "elro_800_switch",
    "repeats": 1
}
{
    "message": {
        ...
        "state": "on"
    },
    ...
    "repeats": 2
}
{
    "message": {
        ...
        "state": "on"
    },
    ...
    "repeats": 3
}

... remote button ON released and pushed again ...
{
    "message": {
        "systemcode": 4,
        "unitcode": 1,
        "state": "on"
    },
    "origin": "receiver",
    "protocol": "elro_800_switch",
    "repeats": 1
}
{
    "message": {
        ...
        "state": "on"
    },
    ...
    "repeats": 2
}
{
    "message": {
        ...
        "state": "on"
    },
    ...
    "repeats": 3
}

Note that "repeats" is increasing as long as the button is pushed and is reset to 1 when pushed again. But how can I use it in a pilight rule?
 
Reply
#2
Most protocols do not work 2-way, very few protocols provide a toogle bit.
In brief, you do need to do it yourself and based on your individual application, you need to write yourself a "state-machine", but keep in mind:
- RF 433 signal strength is limited
- in order to ensure that a command is received and recognized most remote controls convert a single button press into a series of 2 to 4 pulsetrains (e.q. a single command is typically repeated 2 to 4 times)
- take the time required into account it takes to transmit a single command from the remote control to the device (time varies from remote to remote and is in the 100 to 1000mS range)
 
Reply
#3
Yes, there is no 2-way communication and in my scenario I have to write a "state-machine" myself. But first I'm simply looking for a way to execute the same rule each time the ON signal is received. However, it seems that it is not possible with pilight, because the rule is only run at the very first ON...?
 
Reply
#4
Yes, rules are only executed when the state of one of the devices is changed, so you need a generic_switch which is switched every time the signal is received, and turned off again in the actions of your above rules
 
Reply
#5
I'm currently working on a feature to allow what the poster is requesting.
 
Reply
#6
If you use the latest nightly this should do as requested:
Code:
IF RECEIVED(elro_800_switch, systemcode=4, unitcode=1, state=on) THEN toggle DEVICE relayA BETWEEN on AND off
 
Reply
#7
Even better, i removed the RECIEVED function again and made the support native:
Code:
IF elro_800_switch.systemcode == 4 AND elro_800_switch.unitcode == 1 AND elro_800_switch.state IS on THEN toggle DEVICE relayA BETWEEN on AND off
 
Reply
#8
Great, thanks! Just compiled from git and it works. However, as long as I hold the button the relay is flipping... How can I make sure that the rule is only run once per button press (e.g. only if "repeats" counter decreased)?
 
Reply
#9
Can you check the latest updates which should allow you to use the repeat parameter in the rules.
 
Reply
#10
Ok, with "... AND elro_800_switch.repeats == 1 ..." it works now!

I wonder if it would be better if this could be combined with a device definition and a new parameter which can be used instead of ".state", e.g.:

Code:
"devices": {
    "remote": {
        "protocol": [ "elro_800_switch" ],
        "id": [{
            "systemcode": 4,
            "unitcode": 1
        }],
        "state": "off"
    }
},
"rules": {
    "toggle": {
        "rule": "IF remote.received IS on THEN toggle DEVICE relay BETWEEN on AND off"
    }
}

Then rule writing would be more clear and consistent Wink
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  remote switch to off multiple times koos147 0 2,872 04-28-2015, 06:53 PM
Last Post: koos147

Forum Jump:


Browsing: 1 Guest(s)