Inverted settings window covering device

Hello,

I have a ZigBee window covering device which is closed with 0% and open when it’s 100%. The normal setting is completely inverted. Can I invert it somehow?

Often there will be an option on the Thing/Channel configuration. If not you can use a Script transformation either on the Thing/Channel or, if not possible there, in a transform profile.

1 Like

Can you help me with the transform script? There is no option in the thing configuration

Not without more information.

How are your Items configured?

What rules languages are you using?

My solution is

items

Rollershutter	myLivingShutter	"Wohnzimmer  [JS(rollershutter.script):%d]"	{ channel="deconz:windowcovering:000000000000:a4c1385ebde6490601:position" }

rollershutter.script

(function(position) {
    var newposition = 100 - position; 
    return newposition;
}) (input)

sitemap

Default item=myLivingShutter

any better solution?

That’s just going to change the way the value appears on sitemaps. It doesn’t actually change the Item’s state and I’m not sure it even changes the icon shown. It won’t change anything about how it appears in MainUI.

See Items | openHAB, the transform in particular. There are several examples.

But how can I do the calculation 100-x with a profile?

From the docs:

With Profiles, you are able to change the behavior how Channels interact with your Items.

Transformation Profiles can be used to transform the item state (instead of only transforming it in the Sitemap) using the specified transformation service. You can find the documentation of these Profiles within the documentation of the Transformation Service. E.g. map or jsonpath

#

On the link between a Channel and an Item you’ll see the option to add a transform profile (along with all the other profiiles).

The add-on for JS Scripting has more information about how to write a transform using that language.

Okay…

here is my try of a solution now…

Rollershutter	myLivingShutter	"Wohnzimmer  [%d]"	{ channel="deconz:windowcovering:000000000000:a4c1385ebde6490601:position" [profile="transform:JS", toItemScript="rollershutter.js"] }

rollershutter.js

(function(position) {
    var newposition = 100 - position; 
    return newposition;
}) (input)

I doesn’t work

But if I do it via main UI everything is fine

Which is a big reason why I don’t use text files any more nor really support them on the forum. I’d rather spend my time fixing home automation problems instead of syntax errors and typos.

I don’t know why the text file version doesn’t work. It looks close to right. There should be an error in the logs.

No error in the log :man_shrugging:

Then I’m at the end of what I can support. It can work and it does work through the UI. I don’t do text files so can provide no more assistance getting it to work there.

I don’t use js, but I thought the profile needed the type at the beginning.
I.e JS:rollershutter.js ? My Motion.map is MAP:Motion.map

That’s it…than the documentation is wrong