I created 3 Switch items from MQTT state and commands (UP button, DOWN button and STOP button)
Also I created a Number Item which contains the open/close percentage, This item reads MQTT percentage state and sends the command via http (executecommand(curl http:/ip/cmd…)
I have no problems controling it with Openhab but I also like to control with Google Home. I created a Rollershutter Item with a tag, and it appears in Google Home…But, how can I associte the 3 switch items and number percentage item states/commands to the rollershutter item??
For the Switch items is very easy-> I done via web interface (paper UI)
But for the percentage it a little more complex due to it is not possible (or i don’t know how to…) to send % command via mqtt command. I created the following items:
a number item (shutter_per1) to read the value from mqtt. (create in PAPERUI web interface)
a number item (shutter_dir) to read from mqtt the state (1 is working up, 0 sttoped, -1 down…)(create in PAPERUI web interface)
a number item (shutter_per2) which really read and control the shutter percentage via two openhab rules:
Rule1:
rule “shutter2_read”
when
Item shutter_per1 changed
then
if (shutter_dir.state == 0) { //only read state it is not moving
shutter_per2.state=shutter_per1.state
}
end
Rule2:
rule “shutter_cmd”
when
Item shutter_per2 changed
then
if (shutter_dir.state == 0) {
val value = shutter_per2.toString
executeCommandLine("curl http://192.168.1.106/cm?cmnd=ShutterPosition1%20"+value)
}
end
I put the item shutter_per2 as Slider in my sitemap and works OK!
Slider item= shutter_per2 label=“shutter_pos”
You can use the channel syntax for each and create an items file, name the items what you like. Tag each item with the appropriate google metadata then create a sitemap and add your items to see values.
If the value from tasmota is a number item then use map transformation to change it so OH displays UP/Down.
Example of using map transformation on item:
Thing topic Esp1 "Garage Light Level" @ "Garage" {
Channels:
Type number : level "Light Level" [ stateTopic="/Esp1/Garage/LightLevel" ]
Type switch : contact "Open Closed" [ stateTopic="/Esp1/Door/Switch", transformationPattern="MAP:ONOFF.map" ]
Type switch : motion "Motion" [ stateTopic="/Esp1/Motion/Switch", transformationPattern="MAP:ONOFF.map" ]
}
Thanks for your quick reply…but, sorry, I dont know how to use the map transformation and how this will aid to my interest
I partially solve the problem, creating a dimmer item (called shutter) and tagging it “ligthing” to see in Google Home. I created a rule, when shutter_per1 changed-> sendCommand(shutter, shutter_per1.state)
This solve partially the problem…when I move the rollershutter in openhab, it appears in Google Home…
But I dont know how to do the inverse procedure…how to read the dimmer percentage value when it changes
With alexa you can invert with a rule like this example. I’m sure google will work the same as the rule is doing the work.
rule "Buero_Colortemp_Alexa Commands"
when
Item Buero_Colortemp_Alexa received command
then
Buero_Colortemp_Test.sendCommand(100 - receivedCommand as PercentType)
end
rule "Buero_Colortemp_Test Changes"
when
Item Buero_Colortemp_Test changed
then
Buero_Colortemp_Alexa.postUpdate(100 - Buero_Colortemp_Test.state as PercentType)
end
Finally I can solve the problem with a rule and using DecimalType to convert the percent to a number
When shutter changed
shutter_per1.state = shutter.state as DecimalType