Http binding and updating an item

I’m trying to set up some http binding to update some dimmer items in OpenHAB.

The slider Format is Integer and the binding looks like this:

Cehcking the log files I see this:
12:05:26.500 [DEBUG] [.JSonPathTransformationService:45 ] - transformation resulted in ‘0’
12:05:26.500 [DEBUG] [.o.b.http.internal.HttpBinding:197 ] - transformed response is ‘0’
12:05:26.501 [INFO ] [runtime.busevents :26 ] - office_wall_lamps state updated to 0
12:05:26.502 [DEBUG] [ore.internal.items.ItemUpdater:73 ] - Received update of a not accepted type (StringType) for item office_wall_lamps

I’ve tried using a JS transformer to make sure the value is an Integer:
parseInt(JSON.parse(input).properties.value, 10)

But the result is exactly the same, only difference being the response value ends up being ‘0.0’ Still (StringType) though.

What am I missing here?

Any ideas? I’ve been googling and trying it this way and that, to no avail. I just can’t figure out how to convert that value to a suitable type for the Dimmer.

Internally, all the Transform methods return String.

DimmerItems are setup to convert from a bunch of types, but String isn’t one of them so you may need to hand covert the Binding into the equivalent Rule declaration.

Thanks for the reply @guessed
Ok, lets see if I got this straight - so this is something I can not do in neither the binding nor the transformation, but rather I’m going to need to store the value in a placeholder item first and then update the DimmerItem using a Rule?

The quickest way to get going is to use the Binding, and Transform, as you have them now but change the Item to be String.

Then you build a new Item, of type Dimmer, and use a Rule (when StringItemVersion changed then…) that uses postUpdate to push an integer version of the state of the original Item into the DimmerItem

An alternative version puts both the HTTP call, and the Transform, into the Rule that fires on a Time/cron schedule. This avoids having two Items, but the Rule becomes more complex.

I actually found a simpler way.

I changed the Item to be NumberItem, checked that the http binding worked both ways. And then went ahead and defined it as Dimmer in Sitemaps and - voila! I have a full working dimmer without any rules or placeholder items.