Rollershutter position reading problem

Hi,
While creating the roller shutter element I wanted to show its position, such information is in the returned JSON. Unfortunately, I can’t read it even though the code seems to be correct. Any suggestions? At the begining I wanted to show the value inside rollershutter item, finally I created a new one.

json:
{"shutter":{"state":2,"currentPos":{"position":88,"tilt":-1},"desiredPos":{"position":88,"tilt":-1},"favPos":{"position":50,"tilt":50}}}

items:
Rollershutter S_Room "Pokój []" <rollershutter> (Shutters) { http=">[DOWN:GET:http://192.168.0.120/s/d] >[STOP:GET:http://192.168.0.120/s/s] >[UP:GET:http://192.168.0.120/s/u]" }
Dimmer S_Room_Position "Pozycja [%d %%]" <rollershutter> { http=">[http://192.168.0.120/api/shutter/state:3000:JSONPATH($.shutter.desiredPos.position)]" }

sitemap:
Slider item=S_Room_Position

> means outward bound
If you’re trying to read, you should consider <

1 Like

Bull’s-eye!

That is complete code, one thing is enough for manipulate and read position:
Rollershutter S_Room "Pokój []" <rollershutter> (Shutters) { http=">[DOWN:GET:http://192.168.0.120/s/d] >[STOP:GET:http://192.168.0.120/s/s] >[UP:GET:http://192.168.0.120/s/u] <[http://192.168.0.120/api/shutter/state:3000:JSONPATH($.shutter.desiredPos.position)]" }

Thank you!

Hi
i have a dimmer “DimmerCam”.
If i wanto to use this code i must replace S_Room with DimmerCam and 192.168.0.120 with the mine.
Is it true?
Other?

Do you use blebox.eu dimmer module? Dimmer has different api and do not need DOWN/UP/STOP commands( https://technical.blebox.eu/dimmerBoxAPI/). So, you should read currentBrightness and set desiredBrightness on change. The code for dimmer should look like this:

http.cfg:
room.url=http://YOUR_IP/api/dimmer/state
room.updateInterval=3000

items:
Dimmer ITEM_NAME "LABEL [%d %%]" <light> (Lights) { http="<[room:3000:JS(brightness.js)]" }

transform/brightness.js (to calculate percent for dimmer item because source brightness value is between 0-255):
(function(value) {
var brightness_val = JSON.parse(value).dimmer.desiredBrightness;
var brightness_percent = Math.round((brightness_val / 255) * 100);
return brightness_percent;
})(input)

sitemap:
Frame label="Lights" {
Group item=Lights {
Switch item=ITEM_NAME label="LABEL []" icon="switch"
Slider item=ITEMNAME label="LABEL [%d %%]"
}
}

It is only for status read, to POST changes you should bind outbound in item http or use a rule.

No
I’d want to do the same you did but i use a dimmer to open a blind.
I can see the dimmer but i am not able to see the state in %.

In the openhab panel i have

What kind of equipment do you actually use and where is the api documentation?

If you can not bind http directly for an item, do it with rule, like that:
rule "My shutter"
when
Item Dim received command
then
val String URL = "http://IP/api/shutter/set - check your api"
val String contenttype = "application/json"
var String jsondata = '{"shutter": {"position": ' + Dim.state + '}} - check your json structure'
sendHttpPostRequest(URL, contenttype, jsondata)
logInfo("rshutter.rules", "Dimm position set to " + Dim.state)
end

At least, consider use rollershutter item in place of dimmer.

This is simple bind for dimmer item controling shutter:
Dimmer YOUR_ITEM "LABEL [%d %%]" <rollershutter> { http=">[*:GET:http://YOUR_IP/API/%2$s] <[http://YOUR_IP/API/state:3000:JSONPATH(target position)]" }

This one >[*:GET:http://YOUR_IP/API/%2$s] send new position to shutter controller, %2$s means dimmer position
Next one: <[http://YOUR_IP/API/state:3000:JSONPATH($.shutter.desiredPos.position)] is an example of read target position. You should read the target position, if you have one, not the current one (current = loops). $.shutter.desiredPos.position depends on the structure of your json respond.

If won’t work restart openhab service: sudo systemctl restart openhab2.service.

Actually my sitemap is


the file is

sitemap sonoff label="CAMERETTA" {
    Frame {
        Group item=Cameretta  {
   
    Frame {
       // Text label="Serranda Discesa" icon="Blinds" {
            Default item=LivingRoom_Light2 label="Discesa" icon="Blinds"
       // }

       // Text label="DimmerCam" icon="heating" {
            Default item=DimmerCam label="DimmerCam" icon="heating"
      //  }

       // Text label="Serranda Salita" icon="Blinds" {
            Default item=LivingRoom_Light1 label="Salita" icon="Blinds"
        //}
      //  Text label="Reset finestra alzata" icon="switch" {
            Default item=Reset label="Reset" icon="switch"
        //}
//Frame label="Lights" {
//Group item=Lights {
//Switch item=DimmerCam label="LABEL []" icon="switch"
//Slider item=DimmerCam label="LABEL [%d %%]"
//}
//}
		
}
}
}
}


But i don’t understand why on the habpanel the status of the switch works instead on the sitemap no.
Infact on the sitemap when a switch go off i am not able to see this switch.
Why?

You do not need another Frame in Group. What is in your item config for that dimmer?

DimmerCam

i modified so but i continue to have the problem

sitemap sonoff label="CAMERETTA" {
    Frame {
        Group item=Cameretta  {
   
  //  Frame {
       // Text label="Serranda Discesa" icon="Blinds" {
            Default item=LivingRoom_Light2 label="Discesa" icon="Blinds"
       // }

       // Text label="DimmerCam" icon="heating" {
            Default item=DimmerCam label="DimmerCam [%d %%]" icon="heating"
      //  }

       // Text label="Serranda Salita" icon="Blinds" {
            Default item=LivingRoom_Light1 label="Salita" icon="Blinds"
        //}
      //  Text label="Reset finestra alzata" icon="switch" {
            Default item=Reset label="Reset" icon="switch"
        //}
//Frame label="Lights" {
//Group item=Lights {
//Switch item=DimmerCam label="LABEL []" icon="switch"
//Slider item=DimmerCam label="LABEL [%d %%]"
//}
//}
		
//}
}
}
}


now i eliminated the group and it works.
But if i want to create a group how can i do to have the status in real time?

I described it 2h ago. You have to configure an item in items. This part read the value <[http://YOUR_IP/API/state:3000:JSONPATH(target position)].

1 Like

Ok thank’s

If i want in sitemap more rooms, how do i create this with the dimmer to work?

Please read the documentation at: https://www.openhab.org/docs/configuration/sitemaps.html.

This is an example: Text item=LR_Multimedia_Summary label="Multimedia [%s]" icon="video" {
Selection item=LR_TV_Channel mappings=[0="off", 1="DasErste", 2="BBC One", 3="Cartoon Network"]
Slider item=LR_TV_Volume
}