[SOLVED] Switching 2 items with one switch

Hey everybody

I’m trying to switch to items with one switch. But when i look in my log viewer i see following errors

2018-11-29 12:04:33.012 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘home.items’

2018-11-29 12:04:33.117 [WARN ] [mon.registry.AbstractManagedProvider] - Could not update element with key _tags:LightAll in ManagedMetadataProviderImpl, because it does not exists.

==> /var/log/openhab2/events.log <==

2018-11-29 12:04:33.184 [ome.event.ItemUpdatedEvent] - Item ‘LightAll’ has been updated.

==> /var/log/openhab2/openhab.log <==

2018-11-29 12:05:00.616 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘home.rules’ has errors, therefore ignoring it: [8,2]: no viable alternative at input ‘when’

[9,8]: no viable alternative at input ‘LightAll’

[9,30]: no viable alternative at input ‘ON’

[9,36]: no viable alternative at input ‘OFF’

this is my home.items file:
//This is the Items File

//Lichten kamer Gregory
Switch LightLeft “Left lights [%S]” [“Lighting” ] {mqtt=">[broker:GVA-S$
Switch LightRight “Right lights [%s]” [“Lighting”] {mqtt=">[broker:GVA$
Switch LightAll “All lights” [“Switchable”]

This is my rules file:
//This is the rules File
rule “Turn on lights”
when
Item LightAll changed from OFF to ON
then
LightLeft.sendCommand(ON)
LightRight.sendCommand(ON)
when
Item LightAll changed from ON to OFF
then
LightLeft.sendCommand(OFF)
LightRight.sendCommand(OFF)
end

anyone any idea why it doesn’t work.

Kind regards

You either need to separate the second part , starting with the second “when” into a second rule with the an own rule name and add the end statement to first rule.
Or you can condense them both into one rule by using " received command" as the trigger and sending “receivedCommand” to the lights.

Type all into the phone, typos probable!

Thank you so much!

It works now.

I’m pretty sure you won’t need any rule for this, just define LightAll as a group item:

//Lichten kamer Gregory
Group:Switch LightAll "All lights" [ "Switchable" ]
Switch LightLeft "Left lights [%S]" (LightAll) [ "Lighting" ] {mqtt=">[broker:GVA-S..."}
Switch LightRight "Right lights [%s]" (LightAll) [ "Lighting" ] {mqtt=">[broker:GVA..."}

This should do the Job.

1 Like

Exactly how I do it and it works very very well. Clean, simple and easily scalable.

When i try your suggestion i get this error.
Configuration model ‘home.items’ has errors, therefore ignoring it: [5,49]: missing EOF at ‘<’

SOLUTION: i still had the >light> in the 2 lines with Left and Right light and that caused the issue