Needing help with simple rule to turn off all the lights

Hey there !

I control my lights with 433 MHz Sockets, which I implemented with the exec Binding into OH.
I’m already able to control them with the App and the HABPanel.

Now, I want to create a switch or a button, which turns off all lights, so when I leave the apartment, I only have to touch one button and not every single button for each lamp.



My setup looks like this:

— THINGS —

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 ]

— ITEMS —

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

— SITEMAPS —

sitemap default label=“Home”
{
Frame label=“Wohnzimmer” {
Switch item=dose_00011_1 mappings=[“1”=“An”, “0”=“Aus”]
Switch item=dose_00011_2 mappings=[“1”=“An”, “0”=“Aus”]
} … }



My idea is to make a new (virtual) switch called “all_off”, which turns off every lamp with a rule:

rule "all_off"
when
Item all_off received command ON
then
dose_00011_1.sendCommand(OFF)
dose_00011_2.sendCommand(OFF)
end

ITEMS
String all_off "all_off"

SITEMAPS
Switch item=all_off

And here is the problem. The app doesn’t work anymore now and I think theres a mistake in my rule.

I really looking forward to getting some answers.

Dominik

Why a rule - How about a global Group in a general items-file like for example Wohnung.items:

Group:Switch:OR(ON, OFF) Alle_Lampen “Licht” [ “Switchable” ]

You could add each light you wanna switch on/off to the above group:

Arbeitszimmer.items:
Switch PC_Lampe_Arbeitszimmer “PECE Lampe” (other groups, …, Alle_Lampen) [ “Switchable” ] { mqtt=">[mqttBroker:ArbeitszimmerLampe:command:ON:xxx],>[mqttBroker:ArbeitszimmerLampe:command:OFF:xxx]" }

Bad.items:
Dimmer Badlampe_Lichtschalter_Hue_Badezimmer “Spiegellampe” (other groups, …, Alle_Lampen) { channel=“hue:xxxx:brightness” }

and so on.

Note: [Switchable] is just for hue-emulation -> Alexa Echo.

In your sitemap-file you would use something like:

Text label=“Beleuchtung” icon=“light” {
Switch item=Alle_Lampen label=“Wohnung” mappings=[OFF=“Alle aus”, ON=“Alle an”]
}

Hey rikky and thank you for the answer,

I believe you that your idea is much easier and I want to use it, but when I copy your code ( and short it a bit ), there is a mistake and I can’t use the app any more. The mistake must be in the .items file, because when I comment out this line the app works again.
Could it be that I have troubles because I don’t have traditionally switches to control my lights but strings tu turn it on or off ?

Why not have the apartment detect when you’ve left and turn them off for you? :wink:

I’ll second rikky’s suggestion. For what you are asking a Group would be best.

When you encounter a syntax error like this always load your config into ESH Designer. It will tell you exactly what line has the problem and exactly what is wrong with the line.

Why?

im not experienced with the exec binding, so dont know how to map and send the commands.
but your dose_00011_x mappings look a little bit strange - just try 1=“An” instead of “1”=“An”.

Also watch out for smart quotes if you copy and paste. The forum seems to apply smart quotes even when you don’t want them.

1=“An” // syntax error
1="An" // correct

That would be great, but I decided to solve the project step-by-step (maybe in a few weeks you see my post here how to solve this :wink: )

Okay lets try, I have currently troubles with opening ESH Designer. Either on my raspberry nor on my Mac it will start, but I will solve this and answer again when I tried your suggestions.

Don’t spend too much time on the RPi. Designer needs more resources than the RPi has to offer.

Someone may be able to help with it on the Mac if you post specifics.

Thank you, I AM spending too much time, probably.
The aim is still the same: control my 433 MHz sockets as a group.

Up to now, I used a RPi 3 with RASPBIAN STRETCH WITH DESKTOP (V4.9) and Openhab2, install manually via the terminal. Further, I installed the exec binding (V2.1.0) manually on the RPi and the “raspberry-remote”, which is similar to all other controllers for 433 MHz frequencies, I think. I wrote every Thing, Item and Sitemap manually in the folder /etc/openhab2/… (good idea or is there an easier way?). I control my RPi with my MacBook (Pro 15 inch early 2013 10.12.6 macOS Sierra) via SSH. Now, Rich mentions to write the filed with the Eclipse Designer, which I have to install on my Mac. The installation run well, but when trying to open Eclipse, there is an error:

the log-file is (unbelievable huge). That’s only the end:

!ENTRY org.eclipse.osgi 4 0 2017-10-10 16:34:17.850
!MESSAGE Application error
!STACK 1
java.lang.RuntimeException: Application “org.eclipse.smarthome.designer.ui.application” could not be found in the registry. The applications available are: org.eclipse.ant.core.antRunner, org.eclipse.ant.ui.antRunner, org.eclipse.e4.ui.workbench.swt.E4Application, org.eclipse.e4.ui.workbench.swt.GenTopic, org.eclipse.emf.codegen.CodeGen, org.eclipse.emf.codegen.JMerger, org.eclipse.emf.codegen.ecore.Generator, org.eclipse.emf.mwe.core.WorkflowRunner, org.eclipse.equinox.app.error, org.eclipse.equinox.p2.director, org.eclipse.equinox.p2.garbagecollector.application, org.eclipse.equinox.p2.publisher.InstallPublisher, org.eclipse.equinox.p2.publisher.EclipseGenerator, org.eclipse.equinox.p2.publisher.ProductPublisher, org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher, org.eclipse.equinox.p2.reconciler.application, org.eclipse.equinox.p2.repository.repo2runnable, org.eclipse.equinox.p2.repository.metadataverifier, org.eclipse.equinox.p2.artifact.repository.mirrorApplication, org.eclipse.equinox.p2.metadata.repository.mirrorApplication, org.eclipse.equinox.p2.updatesite.UpdateSitePublisher, org.eclipse.equinox.p2.publisher.UpdateSitePublisher, org.eclipse.equinox.p2.publisher.CategoryPublisher, org.eclipse.help.base.infocenterApplication, org.eclipse.help.base.helpApplication, org.eclipse.help.base.indexTool, org.eclipse.jdt.apt.core.aptBuild, org.eclipse.jdt.core.JavaCodeFormatter, org.eclipse.jdt.core.JavaIndexer, org.eclipse.pde.build.Build, org.eclipse.ui.ide.workbench.
at org.eclipse.equinox.internal.app.EclipseAppContainer.startDefaultApp(EclipseAppContainer.java:248)
at org.eclipse.equinox.internal.app.MainApplicationLauncher.run(MainApplicationLauncher.java:29)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:236)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)

Hmmmmm. That is a new one for me.

What version of Java are you running on the Mac?

I’ve updated it yesterday - Java 8.144.

Is my basically doing okay ? I considered to remove Raspbian and replace it with Openhabian, is this worth ?

And excuse me, if there will be a simple little mistake anywhere, and I confuse all of you - I heard nothing about openhab until 2 weeks ago.

I do recommend opneHABian but doing so will not help with your problem.

That version of Java should be able to run Designer on the Mac. I’m really at a loss as to what is wrong. Perhaps you downloaded the wrong version of ESH Designer (e.g. downloaded the Windows version instead of the Mac version, the 64-bit version when you have 32-bit java). I really don’t know. That error is severe but from what I could tell with my brief Googling could mean almost anything.