Update slider from JSON feedback

Hi,
my problem looks like it’s being similar to this one: [SOLVED] Update slider from MQTT feedback
but I can’t figure out howto translate the solution into my configuration.

I control my rollershutters via http-requests sent to my Rademacher Homepilot (433 Mhz technology) and I can receive the status via another http-request. Therefore I implemented two items. One controls the rollershuter via a slider and a rule:

Number rolloSetPosWohnLinks1	"Rollo links 1 [%s %%]"		<rollershutter>	(gRolloWohnLinks)
rule "rollo_set_SetPos_WohnLinks1"
when
	Item rolloSetPosWohnLinks1 received update
then
    SetPos = rolloSetPosWohnLinks1.state as DecimalType
    rolloUrl = String::format("http://xxx.xxx.xxx.xxx/deviceajax.do?cid=9&did=10002&goto=" + "%s" + "&command=1", SetPos)
    sendHttpGetRequest(rolloUrl)
end

My sitemap only contains:

Slider item=rolloSetPosWohnLinks1
Text item=aktPosWohn1

The second item displays the actual position of the rollershutter:

String aktPosWohn1 "Akt.Pos. [%s]" {http="<[http://xxx.xxx.xxx.xxx/deviceajax.do?device=10002:30000:JS(getValue.js)]"}

getValue.js is defined as:

(function(i) {
    var json = JSON.parse(i);
    return json['device']['position'];
})(input)

I should mention that my rollershutters can also be controlled via hardware wallswitches and by a 433MHz remote control.

I want to use my slider to control the shutter and also display its state for example after the shutter has beend moved by the remote control.

Can someone point me into the correct direction?

No ideas, anybody?

Hi All,

a year later, but this might help others:

Dimmer Rolladen       "Rolladen: [%d %%]"      (Test)  {http=">[*:POST:http://homepilot/deviceajax.do?cid=9&did=10123456&goto=%2$s&command=0] <[http://homepilot/deviceajax.do?devices:10000:JSONPATH($.devices[:1].statusesMap.Position)]"}

Best regards,

Empor

Sorry, but that doesn’t work. The rollershutter can be controlled by the Rolladen item, but the slider jumps back to 0 immediately after usage. Also the slider isn’t updated by the position of the rollershutter.

what is the state of the aktPosWohn1 String Item now?
A Dimmer Item accepts percentage values (0 to 100)
Maybe you need to cast the result of the http call to a PercentType? (not sure)

Check: Type Conversions

Got the solution. Simply had to change the input part of the request to

<[http://homepilot/deviceajax.do?device=10002:10000:JS(getValue.js)]

Don’t know why the JSONPATH command didn’t work

so you changed the refreshintervalinmilliseconds from 30000 (30 secs) to 10000 (10 secs) and this fixed the problem? strange…

The Dimmer Item works now?

No, I didn’t change the refreshintervalinmilliseconds. I changed postcontent from

<[http://homepilot/deviceajax.do?devices:10000:JSONPATH($.devices[:1].statusesMap.Position)]

to

<[http://homepilot/deviceajax.do?device=10002:10000:JS(getValue.js)]'

where getValue.js is defined as:

(function(i) {
    var json = JSON.parse(i);
    return json['device']['position'];
})(input)

This works fine for me:
http="<[http://homepilot.local/deviceajax.do?device=10004:60000:JSONPATH($.device.position)]"
My Problem is, when I used the same item for target and current position, the rollershutter stops, when current position is refreshed during movement.
Regards,
Reik.