[SOLVED] Multiple ON and OFF's for crappy 433MHz-devices?

I have some 433MHz-devices… and usually they are a bit hit and miss…sometimes they turn on and sometimes not…I guess that’s something everybody has to accept with the 433MHz system …

Anyway …I communicate with my RFLINK via Mqtt-commands…
I would like openhab to duplicate the ON and OFF commands… when I give an ON command… I would like openhab to send the command 3 times or so …to increase the probability that the signal actually get all the way to the recieving device… that’s apparently a feature that the tellstick system has…

How could this be achieved in openhab ?

Use a rule:

var Number repeat = 0
val Number maxRepeat = 3

rule "repeat 443Mhz"
when
    Item myItem received command
then
    repeat = repeat + 1
    if (repeat <= maxRepeat) {
        Thread::sleep(500)
        myItem.sendCommand(receivedCommand)
    } else {
        repeat = 0
    }
end

Thanks! This would work for both ON and OFF as far as I can see…but I would have to have one rule for every switch then … any way to slim this even more ? Ideal would be one single rule that handle all the switches… could something be done with groups?

Put all your 433Mhz items in a group:

Group Group433

Then:

var Number repeat = 0
val Number maxRepeat = 3

rule "repeat 443Mhz"
when
    Member of Group433 received command
then
    repeat = repeat + 1
    if (repeat <= maxRepeat) {
        Thread::sleep(500)
        triggeringItem.sendCommand(receivedCommand)
    } else {
        repeat = 0
    }
end

BUT BE CAREFUL.
This will only work one item at a time. If you send a command to several items at once the rule will NOT work.
You will have to work with:


instead

1 Like

Such sounds like the behaviour that is implemented into für Intertechno binding. Did your look into that one?

TO be honest , I have given up with 433Mhz except for some sensors, like garden weather station and some temperatures here and there. It is not that critical if I miss one or two messages
BUT
The commands sent over 433Mhz are susceptible to interference and switching something is just not reliable.

I have ONE 433Mhz plug socket left. And it’s going a soon as possible.
I am upgrading to zigbee little by little.

Thanks! Interesting … however I guess I’m going to run into trouble, because my switches is part of a group that I turn on and off… and I guess that means that several commands are in use at once…

The you will need that design pattern as above

If you only need to switch them all together (as opposed to switching one by one) you could set them all to the same code, that way one signal could switch all!

Yes I’m very much aware… :slight_smile: of course I dont use 433MHz for “critical applications”…but I still beleve that I could raise the functionality a lot if I succeed with this…

Would I need to modify the code above somehow for that ?

You will need to use this:

In case you set all devices to the same code, all would be reacting on command. The need for multiple sends of the same command would still be valid, but only for this one code.

I have tried vzorglub’s code now… and it appears to be working also when I turn an entire group ON and OFF … so thanks a lot!

Well it turned out that it didn’t work as well as I first thought… too many commands at the same time I guess (the risk that I also was informed about in the post…)

Instead I want to try this:

 var Number repeat = 0
val Number maxRepeat = 3

rule "repetera 433MHz-kommando"
when
    Member of 433sw received command
then
    433sw.members.forEach[item |
        if (item.state == ON) {
            repeat = repeat + 1
            if (repeat <= maxRepeat) {
                Thread::sleep(500)
                item.sendCommand(ON)
            }
            else { repeat = 0 }
        }
        if (item.state == OFF) {
            repeat = repeat + 1
                if (repeat <= maxRepeat) {
                    Thread::sleep(500)
                    item.sendCommand(OFF)
                }
                else { repeat = 0 }
        }
    ]
end

Unfortunately I get this error message:

Configuration model '433rep.rules' has errors, therefore ignoring it: [6,5]: no viable alternative at input '433'

I have checked the group, it is okay and it has 5 members… what can the problem be ?

Answering myself here… apparently a group can’t begin with numbers… changed it to sw_433 and that seems to work…

I also had to had to make a simple lock to avoid an infinite loop…

So this is the finnished result… seems to work fine now!

(note, Im aware that the way this works it sends command to all units regardless of what unit that triggered the rule…right now I don’t think that is a problem…)

var Number repeat = 0
var Number lock = 0
val Number maxRepeat = 2


rule "repetera 433MHz-kommando"
when
    Member of sw_433 received command
then
    if (lock == 0) {
        lock = 1
        sw_433.members.forEach[item |
            if (item.state == ON) {
                while (repeat <= maxRepeat) {
                    repeat = repeat + 1
                    Thread::sleep(500)
                    item.sendCommand(ON)
                }
                repeat = 0
            }
            if (item.state == OFF) {
                    while (repeat <= maxRepeat) {
                        repeat = repeat + 1
                        Thread::sleep(500)
                        item.sendCommand(OFF)
                    }
                    repeat = 0
            }
        ]
    lock = 0
    }
end

Any item name cannot begin with a number
See: https://www.openhab.org/docs/configuration/items.html#name

Second line

Sorry about that basic mistake :slight_smile: