Control two openHAB items with just one Google Assistens Item

Tags: #<Tag:0x00007fe735ee1f28> #<Tag:0x00007fe735ee1c80> #<Tag:0x00007fe735ee1af0>

I have a dimmable light that is split into two things because the modbus implementation for this device is set this way:

AU.Sauna Licht Kabine (switch)
AU.Sauna Licht Kabine Helligkeit (dimmer)

I linked those to some items:

// Modbus
Group	g_AU_Sauna_Licht_Kabine_Wrapper		"Sauna Kabine"																				{ homekit="Lighting" }
Switch	AU_Sauna_Licht_Kabine				"Sauna Kabine"				(g_AU_Sauna_Licht_Kabine_Wrapper, g_AU_Licht, g_AU_Sauna)		{ ga="Light", alexa="PowerController.powerState" [category="LIGHT"], homekit="Lighting.OnState", autoupdate="false"}
Dimmer	AU_Sauna_Licht_Kabine_Helligkeit	"Sauna Kabine Helligkeit"	(g_AU_Sauna_Licht_Kabine_Wrapper)								{ homekit="Lighting.Brightness", autoupdate="false" }
String	AU_Sauna_Licht_Kabine_Name										(g_AU_Sauna_Licht_Kabine_Wrapper, g_Persist_Restore)			{ homekit="Lighting.Name" } // Für Homekit Binding, setzen per Konsole

My goal is to be able to control this light with one item in Google Assistant. Currently I can only turn it on / off (which makes sense of cource because I have the tag on the switch item).

For homekit I can achieve this just fine because the characteristics (on/off, dimmer level) can be set to different items in a group, but the Google Assistant binding does not seem to support something like that.

How can I control these two openHAB items with just one Google Assistent item?

Dimming to zero does not turn the item off?

If it does you are done, if not you need to expose two things to google assistant.

It does turn it off, but on the physical light switch there ist a „power on/off“ button that restores to the latest brightness. That’s the main reason I want to keep things seperated. Sorry I forgot to mention this.

So

  1. I turn it off by setting the brightness to zero
  2. I turn it on with the physical button
  3. Nothing happens, it‘s „on“ now at 0 percent brightness

There must be some fancy workaround using proxy items and/or rules but I can‘t wrap my head around that yet.

You might be able to use a proxy item and rule like:
Item:

Dimmer	AU_Sauna_Licht_Kabine_GA				"Sauna Kabine" { ga="Light" }

Rule:

rule "Google assistant sauna light"
when
    Item AU_Sauna_Licht_Kabine_GA received command
then
    if (receivedCommand instanceof OnOffType) {
        AU_Sauna_Licht_Kabine.sendCommand(receivedCommand)
    } else {
        AU_Sauna_Licht_Kabine_Helligkeit.sendCommand(receivedCommand)
    }
end

I haven’t tested, so might need tweaking, but something like this should work I believe.

1 Like

You might be able to use the previousState extension to restore the dimmer value whenever the dimmer value is set to 0 by Google Assistant. You would use the dimmer item as your GA item, and whenever it goes to zero you have a rule set the switch item to OFF and restore the previous brightness.

Alternatively, you could have a rule that when your switch turns to ON (because you pressed the button), openHAB restores brightness to the previous state.

I like that the first rule does the work immediately, but your hardware might work better with the second rule.

Thank you! I’ll try these suggestions and post my final solution here :slight_smile:

1 Like