Change string to switch

Hi Community,

i have 3 433mhz sockets controlled via openhab2 (openhabian on RaspberryPi).
I can control them via the openhab app.
But for Homekit and Amazon Echo i need them as Switch, not as String.

So how can i change them to a Switch?

Here are my files:

.sitemap

sitemap steckdosen label="Steckdosen" {
    Frame label="Funksteckdosen Gruppe G" {
        Switch item=steckdoseG1Switch mappings=[ "ON"="ON", "OFF"="OFF" ]
        Switch item=steckdoseG2Switch mappings=[ "ON"="ON", "OFF"="OFF" ]
        Switch item=steckdoseG3Switch mappings=[ "ON"="ON", "OFF"="OFF" ]
        }
}

.items

Group grp_steckdosen "Steckdosen" <poweroutlet>

String steckdoseG1Switch "Steckdose G1" <poweroutlet> (grp_steckdosen) [ "Switchable" ] { channel="exec:command:steckdoseG1-control:input", channel="exec:command:steckdoseG1-status:output", autoupdate="true" }
String steckdoseG2Switch "Steckdose G2" <poweroutlet> (grp_steckdosen) [ "Switchable" ] { channel="exec:command:steckdoseG2-control:input", channel="exec:command:steckdoseG2-status:output", autoupdate="true" }
String steckdoseG3Switch "Steckdose G3" <poweroutlet> (grp_steckdosen) [ "Switchable" ] { channel="exec:command:steckdoseG3-control:input", channel="exec:command:steckdoseG3-status:output", autoupdate="true" }

.things

//SteckdoseG1
Thing exec:command:steckdoseG1-control [ command="/home/openhabian/433Utils/RPi_utils/steckdose1.sh %2$s", interval=0, autorun=true ]
Thing exec:command:steckdoseG1-status [ command="/home/openhabian/433Utils/RPi_utils/steckdose1.sh status", interval=0, timeout=5 ]

//SteckdoseG2
Thing exec:command:steckdoseG2-control [ command="/home/openhabian/433Utils/RPi_utils/steckdose2.sh %2$s", interval=0, autorun=true ]
Thing exec:command:steckdoseG2-status [ command="/home/openhabian/433Utils/RPi_utils/steckdose2.sh status", interval=0, timeout=5 ]

//SteckdoseG3
Thing exec:command:steckdoseG3-control [ command="/home/openhabian/433Utils/RPi_utils/steckdose3.sh %2$s", interval=0, autorun=true ]
Thing exec:command:steckdoseG3-status [ command="/home/openhabian/433Utils/RPi_utils/steckdose3.sh status", interval=0, timeout=5 ]

.sh

#!/bin/sh

if [ "$1" = "off" ] || [ "$1" = "0" ] || [ "$1" = "OFF"  ]; then
        /home/openhabian/433Utils/RPi_utils/codesend 7721987
else
        /home/openhabian/433Utils/RPi_utils/codesend 7721996
fi

maybe someone can help me :slight_smile:

Moin!
Den Namen der Veriablen nach nehme ich an, dass du deutsch sprichst?
Falls dem so ist…hätte ich evtl. etwas für Dich, da ich an dem selben Problem sitze.

1 Like

Keep in mind that this forum uses English as the ONLY language. That way the group of users is much bigger, answering in a other language will limit the answer to persons speaking that language.

1 Like

Why did you use Strings at all? Did you try to change the Strings to Switch?
Your usage sounds like you even could use the Intertechno binding,I’m using this binding for switching my 433mhz power-pluggs (Funksteckdosen).

Will the Intertechno binding work with the elro 440 power-plugs??
I use Strings to execute a shell script which uses the send.sh script to switch the power-plugs (./send 11101 1 1 for example)

I defined a “dummy” switch (as Switch) and connected it via a rule to the String switches.
.Item:
String steckdoseG2Switch “Wohnzimmerlampe 1” (grp_steckdosen) [ “Switchable” ] { channel=“exec:command:steckdoseG2-control:input”, channel=“exec:command:steckdoseG2-status:output”, autoupdate=“true” }

Switch stehlampe “Stehlampe” [ “Switchable”] { channel=“exec:command:steckdoseG2-control:input”, channel=“exec:command:steckdoseG2-status:output”, autoupdate=“true” }

This way a am able to switch the “Stehlampe” via Alexa.

I’ve already changed the Strings to Switch, but it doesnt work…

i will try the switch from darksoul666 and report :wink:

By the way… yes iam german :slight_smile:

EDIT:
Okay now my question: how to create the “rule”? :stuck_out_tongue:
Sorry but i’m a big noob with openhab :confused:

You have to install the Rule engine Binding. After that you have the option “Rules” in the paper ui menu.
There you just have to build the rule by clicking through the rule wizzard :wink:

Unfortunately I can’t help you but I just wanted to say thanks for your question, as the example code you provide helps me a little bit better in understanding how to send non standard (other than OFF/ON/CLOSED/OPEN) from openhab via MQTT

Okay iam out… its openhab 2 and there is no rule engine binding addon…
but there is a rules folder in the config…

I do use the intertechno binding on one of my Elro440s with this item:

Switch Elro_Weiss "Elro-Weiss" (gLichtschalter) {culintertechno="type=raw;address=00000FFF0F;commandOn=FF;commandOff=F0"} /* Intertechno Code A15, Elro weiĂź */

HTH

can you show me the command with my codes? i dont have addresses like you :frowning:

I’m sorry, but I’m not used to that code, I did the initial checks if thre sending device is working using “screen” commands like “is00000FFF0FFF” for ON and “is00000FFF0FF0”.

Sorry, iam out… i think i try a 1.x installation… but i really dont understand this rule thing or the intertechno binding :frowning:

You have to install the rule engine…
In the Paper UI, go to “Add-ons”. Now, on the right side click on “MISC” and there you will find “Rule Engine (Experimental)”

Hope that helps

What kind of 433mhz PowerSwitches do you have? Brand, picture… will help.
What kind of hardware do you have that does transmit to the PowerSwitches?
Most of the usual switches a compatible with Intertechno, you just have to convert the setting. If your switches are compatible I’m still standing by to help (Although your avatar scares me to death).

Okay next problem:

Everytime i restart my raspberry the installed addons are gone…
how can i install them permanent?

You are on OH2, stable or nigthly snaoshot?
Which Addons are gone, OH2 Addons or OH1 Addons? How did you install them, through PaperUI, dropping the .jar into Addons Folder or…?

iam on openhabian (openhab2)…
installed the addons via paperui…
and when i activate a rule the sockets turn on and of every few seconds without doing anything (the sockets are from REV) Link: https://www.bastelbunker.de/funksteckdosen-von-rev-uber-arduino-ansteuern/

check your /etc/openhab2/services/addons.cfg file
You can list in there all the addons that you need and they won’t be uninstalled on OH2 service restart

post the rule here to check it

I thought the addons.cfg should not be used anymore??? Can somebody clarify this, please?