Create rollershutter item from switch and number

Hello,
I have bought a wifi rollershutter controller. I was able to install Tasmota in it -> https://templates.blakadder.com/teepao_curtain_switch.html

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??

Thanks!

Are you using files to add metadata to the item or via console, REST API?

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”

In PaperUI for the Thing, how many channels do you have? You may need to click the show more button to see all available channels.

I use Generic MQTT Thing with 5 channels:

  • Channel associated to UP button
  • Channel associated to DOWN button
  • Channel associated to STOP button
  • Channel associated to read state direction(-1, 0, 1)
  • Channel associated to shutter position (shutter_per1)

But the question…can I make a item type rollershutter(called for example “roller”) and associate it with the other items?

For example,can I changed the states of “roller” with a rule?
When item shutter_dir changed->Modify the updown property of “roller”

if (shutter_dir.state==-1)
roller.UPDOWN.state=DOWN

How is the correct syntaxis of rollershutter?
How to access the properties of the rollershutter?

According to Openhab doc, roller shutter has:
UpDown, StopMove, Percent

Can I write in this values in this way:
roller.UpDown.State=UP

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" ]
    }

The map file:

GPIO,13,1=ON
GPIO,13,0=OFF
1=ON 
0=OFF

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

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.