Exec Binding on Raspi for 433 MHz

Hi Rob,

neighbors shouldn’t be the problem - or they play around a lot ;-).

Changed the channel now to:

channel="exec:command:ON:input"

Still no changes.

Is my .sh correct?

Switch status is changing but I don’t achieve to use just one switch for ON and OFF. I assume I have to change the .items line to combine on and off for one switch. I will search further…

It looks like you’re using the 2.0 exec binding which I don’t have any experience of, so can’t help with channels. Sorry.

Hey
I’m a beginner with Openhab but maybe my syntax can help. I’m using Openhab 2 with the exec Binding 2.1.0 (current one).

.items:

String dose_00011_1 “Stehlampe Schreibtisch” [ “Switchable” ] { channel=“exec:command:funkdose_control_1:input”, channel=“exec:command:device-nas-status:output”, autoupdate=“false” }

.things:

Thing exec:command:funkdose_control_1 [ command=“sudo /opt/raspberry-remote/send 00011 1 %2$s”, interval=0, autorun=true ]

.sitemaps:
Switch item=dose_00011_1 mappings=[“1”=“An”, “0”=“Aus”]

Hope this helps !

1 Like

works with the app and the HABPanel

Hi all, this is how I send my 433 commands.

I’m using 433Utils: https://github.com/ninjablocks/433Utils

Basically I have just one thing and one item for the EXEC binding. I send different strings to that through a rule. autorun=true makes sure that the exec command is executed once the input changes (by the rule). In the rule, I always repeat the command, then 0, then the command (essentially sending the command twice) as sometimes the RF-switch did not react. Now it works perfectly!

Make sure that interval = 0 means the command is NOT repeated (otherwise the default is 5 sec i believe, @Woogi).

The other 3 items are just the switches I used for the UI which trigger the different rules.

A bit complicated maybe but works fantastic!

// THING 433 switches
Thing exec:command:433switch [command="/home/openhabian/433Utils/RPi_utils/codesend %2$s", interval=0, timeout=10, autorun=true ]

// ITEMS
Switch RFSwitch1 "Media Center"
Switch RFSwitch2 "TV"
Switch RFSwitch3 "Bedroom Light" (BedroomLights)
String RFString "RF String" {channel="exec:command:433switch:input"}

// RULES
rule "433 Switch 1"
when
    Item RFSwitch1 changed
then
    if(RFSwitch1.state == ON) {
        sendCommand(RFString, "1381717")
        Thread::sleep(1000)
        sendCommand(RFString, "0")
        Thread::sleep(1000)
        sendCommand(RFString, "1381717")
    }
    else {
        sendCommand(RFString, "1381716")
        Thread::sleep(1000)
        sendCommand(RFString, "0")
        Thread::sleep(1000)
        sendCommand(RFString, "1381716")
    }
end

rule "433 Switch 2"
when
    Item RFSwitch2 changed
then
    if(RFSwitch2.state == ON) {
        sendCommand(RFString, "1394005")
        Thread::sleep(1000)
        sendCommand(RFString, "0")
        Thread::sleep(1000)
        sendCommand(RFString, "1394005")
    }
    else {
        sendCommand(RFString, "1394004")
        Thread::sleep(1000)
        sendCommand(RFString, "0")
        Thread::sleep(1000)
        sendCommand(RFString, "1394004")
    }
end

rule "433 Switch 3"
when
    Item RFSwitch3 changed
then
    if(RFSwitch3.state == ON) {
        sendCommand(RFString, "1397077")
        Thread::sleep(1000)
        sendCommand(RFString, "0")
        Thread::sleep(1000)
        sendCommand(RFString, "1397077")
    }
    else {
        sendCommand(RFString, "1397076")
        Thread::sleep(1000)
        sendCommand(RFString, "0")
        Thread::sleep(1000)
        sendCommand(RFString, "1397076")
    }
end



// SITEMAP
Switch    item=RFSwitch2 label="TV"	
Switch    item=RFSwitch1 label="Mediacenter Plug"
Switch    item=RFSwitch3 label="Bedroom Light"

Hey David,

your code sounds more understanding than my one, but unfortunately, it doesn’t work with my Pi. Do you need special rights or something like this ?

Dominik

And whats you sitemap for this ?

Hi,

I’m using the 433Utils (updated the post with the link. I’ve installed it to the homefolder and it works after compiling).

I added the sitemap to the post above -> it’s just a switch with ON and OFF, works perfectly :slight_smile:

Hi both, thanks for your reply.

@domeninini: how is the second thing definition for your NAS status? Could you post this as well?

@SpaceGlider: in your rule, if you switch on, you send the house code and “0”, why not “1” for on and why again the number?

Kindly

The code is the RF-code to switch ON (or OFF) the individual plug. This may differ from type to type. The “0” is sent only because the EXEC only executes when the input changes. If I send the code twice, EXEC will do nothing because the value did not change. That is why I go from the code to 0 and back to the code. I had to “sniff” the code with the receiver part. I just wanted to demonstrate my OH2 setup with rules and items. If you found a way to make your plugs switch, why not use your things/items with a rule too?

Martin,

I don’t know exactly what you mean with “NAS status” and “second definition” - I only have that one and only thing definition I wrote on the top. Maybe it helps to see my whole files (caution, now a long file follows…)

ITEMS - FILE

GNU nano 2.7.4                                                                                                Datei: mittag.items                                                                                                           

Group gWeather
Number Graz_Temperatur "Aussentemperatur [%.1f °C]" <temperature> (gWeather) { channel="yahooweather:weather:graz:temperature" }
Number Graz_Humidity   "Luftfeuchtigkeit [%d %%]"   <humidity>    (gWeather) { channel="yahooweather:weather:graz:temperature" }
Number Graz_Pressure   "Luftdruck [%.1f mbar]"      <pressure>    (gWeather) { channel="yahooweather:weather:graz:pressure" }


// GROUPS


Group:Switch:OR(ON,OFF) alllamps "All Lights"



// WOHNZIMMER

String dose_00011_1 "Stehlampe Schreibtisch" <light>  (Alle_Lampen)                             [ "Switchable" ] { channel="exec:command:funkdose_control_1:input", channel="exec:command:device-nas-status:output", autoupdate="false" }
String dose_00011_2 "Stehlampe Sofa"         <light>  (Alle_Lampen)                             [ "Switchable" ] { channel="exec:command:funkdose_control_2:input", channel="exec:command:device-nas-status:output", autoupdate="false" }

String dose_00010_1 "Schreibtischlampe"      <network>                             [ "Switchable" ] { channel="exec:command:funkdose_control_3:input", channel="exec:command:device-nas-status:output", autoupdate="false" }
String dose_00010_2 "Lowboard Lampe"         <network>                             [ "Switchable" ] { channel="exec:command:funkdose_control_4:input", channel="exec:command:device-nas-status:output", autoupdate="false" }
String dose_00010_3 "Couchtisch Beleuchtung" <network> (licht, gMyLights) [ "Switchable" ] { channel="exec:command:funkdose_control_5:input", channel="exec:command:device-nas-status:output", autoupdate="false" }
String dose_00010_4 "LED Lowboard"           <network> (licht, gMyLights) [ "Switchable" ] { channel="exec:command:funkdose_control_6:input", channel="exec:command:device-nas-status:output", autoupdate="false" }
String dose_00010_5 "Vitrine"                <network> (licht, gMyLights) [ "Switchable" ] { channel="exec:command:funkdose_control_7:input", channel="exec:command:device-nas-status:output", autoupdate="false" }

THINGS - FILE

Thing exec:command:funkdose_control_1 [ command="sudo /opt/raspberry-remote/send 00011 1 %2$s", interval=0, autorun=true ]
Thing exec:command:funkdose_control_2 [ command="sudo /opt/raspberry-remote/send 00011 2 %2$s", interval=0, autorun=true ]

Thing exec:command:funkdose_control_3 [ command="sudo /opt/raspberry-remote/send 00010 1 %2$s", interval=0, autorun=true ]
Thing exec:command:funkdose_control_4 [ command="sudo /opt/raspberry-remote/send 00010 2 %2$s", interval=0, autorun=true ]
Thing exec:command:funkdose_control_5 [ command="sudo /opt/raspberry-remote/send 00010 3 %2$s", interval=0, autorun=true ]
Thing exec:command:funkdose_control_6 [ command="sudo /opt/raspberry-remote/send 00010 4 %2$s", interval=0, autorun=true ]
Thing exec:command:funkdose_control_7 [ command="sudo /opt/raspberry-remote/send 00010 5 %2$s", interval=0, autorun=true ]

SITEMAPS - FILE

sitemap default label="Dominik und Helena"
{
     Frame label="Wohnzimmer" {
   //Switch item=alllamps
     Switch item=dose_00010_1 mappings=[1="An", 0="Aus"]
     Switch item=dose_00010_2 mappings=[1="An", 0="Aus"]
     Switch item=dose_00010_3 mappings=[1="An", 0="Aus"]
     Switch item=dose_00010_4 mappings=[1="An", 0="Aus"]
     Switch item=dose_00011_1 mappings=[1="An", 0="Aus"]
     Switch item=dose_00011_2 mappings=[1="An", 0="Aus"]
     Switch item=dose_00010_5 mappings=[1="An", 0="Aus"]
    }

Frame label="Wetter in Graz von Yahoo" {
   Text item=Graz_Temperatur
   Text item=Graz_Humidity
   Text item=Graz_Pressure
   Text item=Date
    }
}

Not be confused with the group “alllaps” - this doesn’t work yet !

I just wrote a tutorial about how this works in OpenaHAB2. This does not execute with sudo but if you need to read how to get sudo working with exec.

Hi erverybody!!

Sorry for the late response, I had to reinstall openhabian from scratch again, but now, thank to @domeninini, @Rob_Pope and @Josar I was able to switch the blogs based on the tutorial from the previous post. Thank you so much!

@domeninini I meant the peace of code: "

I did not understand where the device-nas-status is used for.

But due to the fact that it is solved, thanks again and enjoy your Sunday!

Nice to hear this ! Your welcome :wink: