omar1971
(Omar)
December 28, 2017, 9:19am
1
I would like to be able to display and set the temperature threshold using the set (+) (-) buttons
The temperature detected by the system is shown in a 16bit decimaltype word, which reads and writes the value of the SP1 setpoint, in ° K x10
Example: value in word: 2980 value to be displayed: (2980-2730) / 10 = 25.0 ° C).
All setpoints can be set between 10.0 and 35.5 ° C in 0.1 ° C steps
Is it possible to work with the js transformation?
config
modbus: serial.O22.connection = / dev / ttyUSB0: 19200: 8: none: 1: rtu
modbus: serial.O22.id = 1
modbus: serial.O22.start = 278
modbus: serial.O22.length = 1
modbus: serial.O22.type = holding
items:
Number NumberItem “Number [% .1f]” {modbus = “> [O22: 0: transformation = JS (divide10.js)], <[O22: 0: transformation = JS (multiply10.js)]”}
Sitemap:
Setpoint item = NumberItem label = “-” icon = “” minValue = 10 maxValue = 35 step = 1
File divide10.js
(function (i) {
return parseFloat (i- 2730) / 10;
})(input)
File multiply10.js
(function (i) {
return Math.round (parseFloat (i + 2730) * 10);
})(input)
but unfortunately it does not work, did you please me?
I forgot …
binding modbus is
org.openhab.binding.modbus-1.11.0
OH 1.8.3
Hello
ssalonen
(Ssalonen)
December 28, 2017, 9:28am
2
Can you please format all the configuration as code? See this thread for instructions (“Using three backticks at the start and end of the code”)
With current formatting the whitespace seems to be wrong, and it’s hard to tell what you have in the configurations.
Also, could you please share what kind of errors (if any) you receive in the logs?
There is a small issue with transformation, at least
instead of
return Math.round (parseFloat (i + 2730) * 10);
you should have
return Math.round ( (parseFloat (i) + 2730) * 10 );
(notice the difference in parentheses with parseFloat)
Best,
Sami
omar1971
(Omar)
December 28, 2017, 7:36pm
3
hi, how can I check the log?
ssalonen
(Ssalonen)
December 28, 2017, 8:10pm
4
Please find the relevant docs here : https://docs.openhab.org/administration/logging.html
Let me know if there is something unclear.
ssalonen
(Ssalonen)
December 28, 2017, 8:17pm
5
I am sorry, I forgot you were using openHAB1. The logging manual is for openhab2. Try to find the openhab.log, it should contain all the logs.
Would help also if you would format the configurations with backticks, see above.
Best
Sami
omar1971
(Omar)
December 28, 2017, 11:02pm
6
I found the log file, weighs 34Mb is full of data. what mistake should I see?
ssalonen
(Ssalonen)
December 29, 2017, 5:50am
7
I suggest to focus on recent log lines, not any old ones. Most of the lines are probably old. Lines with error or warning are of interest when something does not work as expected.
omar1971
(Omar)
December 29, 2017, 7:48am
8
hello, I tried to focus the period I was trying, but modbus errors I do not find.
place a piece of log file?
Using three backticks at the start and end of the code?
Thanks for your time
ssalonen
(Ssalonen)
December 29, 2017, 8:01am
9
Great! Go ahead and paste it here.
omar1971
(Omar)
December 30, 2017, 4:02pm
10
I’m happy
hi, I tried again and everything seems to work properly.
Only problem that of the set point in steps of 1, I would need 0.1.
config
‘’’
modbus:serial.O12.connection=COM1:19200:8:none:1:rtu
modbus:serial.O12.id=1
modbus:serial.O12.start=268
modbus:serial.O12.length=1
modbus:serial.O12.type=holding
‘’'
items
‘’’
Number NumberItemSP1 “Number [%.1f]” (Termostato_Setup) {modbus=">[O12:0:transformation=JS(multiply10.js)],<[O12:0:transformation=JS(divide10.js)]"}
‘’’
sitemap
‘’’
Setpoint item=NumberItemSP1 label=“SP1 [%.1f]” icon="" minValue=10 maxValue=35 step=1
‘’’
file transform multiply10.js
‘’’
(function(i) {
return Math.round(parseFloat(i*10) + 2730);
})(input)
‘’’
file transform divide10.js
‘’’
(function(i) {
return parseFloat(i- 2730) / 10;
})(input)
’’’
what do you think about it?
ssalonen
(Ssalonen)
December 30, 2017, 10:12pm
11
Great stuff. You can control the step size by the step parameter of Setpoint in sitemap.
omar1971
(Omar)
December 30, 2017, 11:32pm
12
but the minimum value of the step is 1 or am I wrong?
ssalonen
(Ssalonen)
January 3, 2018, 6:08pm
13
Where did you read that? Please try it out and report back.
omar1971
(Omar)
January 3, 2018, 7:48pm
14
I tried with step = 0.1 it works.
But with Android system Item displays 20.1 … 20.2 … 20.3 etc.
but when I get to 20.4 it is displayed 20.400002 so also with the 20.9 it shows 20.900002 … why ???
ssalonen
(Ssalonen)
January 3, 2018, 8:46pm
15
Not sure, with the below format string it should be with one decimal.
omar1971:
[%.1f]
The underlying numbers might not be even, due to floating point arithmetic. But format string should guarantee certain resolution.
Please note that this is openHAB1 which is quite old already, perhaps fixed in openHAB2?
omar1971
(Omar)
January 3, 2018, 8:50pm
16
but openhab 2 the modbus binding is in beta test.
and it scares me
ssalonen
(Ssalonen)
January 3, 2018, 8:52pm
17
You can use the old binding with openHAB2 – no need to use beta versions. Many people use Modbus 1.x binding with openHAB2.
But it will require some setup for sure, and lots of new things to learn. Unfortunately this is where openHAB is heading, so you might want to consider doing the transition at some point.