Ok, I think I have it working now with the proxy approach:
Proxy item:
Dimmer AU_Sauna_Licht_Kabine_Proxy_GA "Sauna Kabine" { ga="Light" }
Rules:
- Translate commands FROM Assistant TO the real items
1b) Fix value in GA displaying 100% after “Turn on” command sent to Assistant - Translate ON/OFF or brightness changes FROM real item TO Assistant
Maybe some edge cases (null items etc.) are still missing.
rule "Sauna Kabine Proxy Google Assistant - FROM proxy TO real item" // 1
when
Item AU_Sauna_Licht_Kabine_Proxy_GA received command
then
if (receivedCommand instanceof OnOffType) {
AU_Sauna_Licht_Kabine.sendCommand(receivedCommand)
} else if (receivedCommand.toString == "0") {
AU_Sauna_Licht_Kabine.sendCommand("OFF")
} else {
AU_Sauna_Licht_Kabine.sendCommand("ON")
AU_Sauna_Licht_Kabine_Helligkeit.sendCommand(receivedCommand)
}
end
// Fix value in GA displaying 100% after "Turn on" command sent to GA
rule "Sauna Kabine Proxy Google Assistant - FROM proxy TO real item (fix)" // 1b
when
Item AU_Sauna_Licht_Kabine_Proxy_GA received update
then
if (AU_Sauna_Licht_Kabine.state.toString == "ON" &&
AU_Sauna_Licht_Kabine_Proxy_GA.state.toString != AU_Sauna_Licht_Kabine_Helligkeit.state.toString) {
if (AU_Sauna_Licht_Kabine_Helligkeit.state == NULL) {
logWarning("Licht", "AU_Sauna_Licht_Kabine_Helligkeit NULL")
return;
}
AU_Sauna_Licht_Kabine_Proxy_GA.postUpdate(AU_Sauna_Licht_Kabine_Helligkeit.state.toString)
}
end
rule "Sauna Kabine Proxy Google Assistant - FROM real item TO proxy" // 2
when
Item AU_Sauna_Licht_Kabine changed or
Item AU_Sauna_Licht_Kabine_Helligkeit changed
then
if (AU_Sauna_Licht_Kabine.state == NULL) {
logWarning("Licht", "AU_Sauna_Licht_Kabine NULL")
return;
}
if (AU_Sauna_Licht_Kabine.state.toString == "ON") {
if (AU_Sauna_Licht_Kabine_Helligkeit.state == NULL) {
logWarning("Licht", "AU_Sauna_Licht_Kabine_Helligkeit NULL")
return;
}
AU_Sauna_Licht_Kabine_Proxy_GA.postUpdate(AU_Sauna_Licht_Kabine_Helligkeit.state.toString)
} else {
AU_Sauna_Licht_Kabine_Proxy_GA.postUpdate("OFF")
}
end
So now everything is working but I needed 3 rules for it. I have a feeling that there might be a simpler approach, so if anybody knows how to simplify this I’m quite interested
Thanks for your help guys!