[SOLVED] Westaflex Binding

The rule is a crackers idea. If you update a modbus connected Item to some new value … what do you think is going to happen a half-second later when the next modbus poll happens.
Ditch that, delete it.

The WARN message has nothing to do with the rule. You’ve obviously found the Transformation part of the binding notes. That’s good, that’s the part we should make work - the “magic” then happens automatically between modbus and your Item.

You need to make a divide by 10 javascript, and put it in the /conf/scripts folder of your openHAB.
In the data Thing corresponding to your Item’s channel, you add a readTransform= parameter specifying the type of transformation and the name of your script. It’s in the docs.

Ok, thanks for the informations.

This would be tough. I´d never had something to do with Java etc.
But i will try that.

I am no coding specialist…
but i found that in the docs:
" transform/divide10.js :

// Wrap everything in a function (no global variable pollution)
// variable "input" contains data passed by openhab
(function(inputData) {
    // on read: the polled number as string
    // on write: openHAB command as string
    var DIVIDE_BY = 10;
    return parseFloat(inputData) / DIVIDE_BY;
})(input)

Is this the java script you thinking about ?
I put it with nano in to the /conf/folder
But how should i add that readTransform= parameter to the thing ?

You need to put the little srcipt into /conf/scripts/

Again, it’s in the docs, further down the examples.
You add a readTransform= to each data thing that needs the read divide by 10. All of them share the same script.

Ok, so how can I add the read transform ? In the PaperUi or with nano at the console?

How did you add/edit the modbus data things for your configuration? You must do it the same way. It’s just another parameter for a data thing.

Guessing you are using PaperUI, find the ‘read transform’ box and put in it

JS(divide10.js)

The JS parts tells openHAB it’s javascript, because there are several types of transformations
The divide10.js is the name of your file in /conf/scripts/

Thanks rossko57!

Thats where the magic happens :-}
But I have to put the java script into the /transform folder.

1 Like

You’re very right, I messed that up!

Ok, here comes another issue:
The divide by 10 seems to be working.
See the log:

2019-02-09 13:54:25.261 [vent.ItemStateChangedEvent] - Abluft changed from 18.3 to 18.4

2019-02-09 13:54:30.360 [vent.ItemStateChangedEvent] - Zuluft changed from 14.9 to 14.8

2019-02-09 13:54:30.469 [vent.ItemStateChangedEvent] - Fort_Luft changed from 10.4 to 10.3

2019-02-09 13:54:30.502 [vent.ItemStateChangedEvent] - Abluft changed from 18.4 to 18.3

2019-02-09 13:54:35.643 [vent.ItemStateChangedEvent] - Zuluft changed from 14.8 to 14.9

2019-02-09 13:54:35.696 [vent.ItemStateChangedEvent] - Aussenluft changed from 8.7 to 8.6

2019-02-09 13:54:35.740 [vent.ItemStateChangedEvent] - Fort_Luft changed from 10.3 to 10.4

2019-02-09 13:54:40.876 [vent.ItemStateChangedEvent] - Zuluft changed from 14.9 to 14.8

2019-02-09 13:54:40.950 [vent.ItemStateChangedEvent] - Aussenluft changed from 8.6 to 8.7

But in my PaperUi only “Abluft” shows the decimal point. Al other show the divided value by ten, but no decimal point.

Well, we cannot see your Item definitions from here.

Ok,
as far as I can see in the paperUi item “Abluft” does have the same settings like “Zuluft” but “Abluft” Shows decimal point but “Zuluft” does not.
Can you tell me where to find the file for items made with paperUi to have a closer look?

Not me, it’s in JSON somehow.
Most likely problem area is in the label, the [%xxx] part.

Can you clarify? Expected 18.3 , got 183 or 18 ?

I expect 18.3 and I got 18

Most likely problem area is in the Item label, the [%xxx] part.

You can also override that by setting a label with [%xxx] part.in your sitemap.

(personally I throw all the decimals away when displaying temp or humidity, the sensors aren’t that good and who cares anyway in a domestic setting)

Dear rossko57,

I think we can skip that. Because in the meantime I played with Habpanel and this worked perfect for me!


Now one comes the next thing.
I want add some Switches to set the speed of the Vents. I can set them 0 - 1 - 2 - 3, Off - Low - Middle - High.
This is written here in the Fans seed Register

Yep. A read/write holding register, and you would limit the allowed values to 0-3 in your openHAB setup.
What’s the problem?

Ok, but how did i make a switch with a input 0 - 1 - 2 - 3 ?

In HABpanel? No idea.

In a sitemap

Switch item=someNumber mappings=[0="Off",1="Low",2="Med",3="High"]

lots of examples of this kind of thing

NO mean in the PaperUI…