I have these items
ORA displays from 0 to 23
MINUTI from 0 to 59
Number ORA “Ora [%x]” (Statobus) { modbus = “dfckora:0” }
Number MINUTI “Minuti [%x]” (Statobus) { modbus = “dfckminuti:0” }
I want to put them together on the same line with this item
String Ora_Minuti “Time / Minutes” (Statobus)
but the result is not what you wanted
I use the following rule:
rule "Ora/Minuti changed"
when
Item ORA changed
or Item MINUTI changed
then
Ora_Minuti.postUpdate(ORA.state.toString + “:” + MINUTI.state.toString)
end
–
I have other items to be bonded together
I have these items
DAY from 0 to 6 (0 = Sun 1 = Mon 2 = Tue …)
DATA = 1 to 31
MONTH = 1 to 12
YEAR = 2 digits (17)
Number GIORNO “Giorno [MAP(giorno.map):%x]” (Statobus) { modbus = “dfckgiorno:0” }
Number DATA “Data [%x]” (Statobus) { modbus = “dfckdata:0” }
Number MESE “Mese [%x]” (Statobus) { modbus = “dfckmese:0” }
Number ANNO “Anno [%x]” (Statobus) { modbus = “dfckanno:0” }
I want to put them together on the same line with this item
Data_Mese_Anno “Day - Date / Month / Year” (Statobus)
while the item now and separate minutu, view
item time: 4
item minutes: 17
I saw that when the items TIME and MINUTES display the data from 0 to 9, the string is correct,
and when the item TIME and MINUTES displaying a value of the string 10…11 … 12 … I see a value of 16 … 17…18 …
We couldn’t guess that. You’ll need a way to analyze your input and process BCD bytes into decimal digit characters
Found someone’s OH rule using BCD
Rule "Update AC_HALL_RTC clock"
When
Item AC_HALL_RTC received update
Then
Var Number T = AC_HALL_RTC.state as DecimalType
Var H = T.intValue / 256
Var M = T.intValue% 256
Var S = String :: format ("% 02x:% 02x", H, M)
PostUpdate (AC_HALL_RTC_S, S)
End
Yes, you’ll have to do some work and adapt that idea
/ Divide by 256 to get the “tens” part of each BCD byte
% Modulo 256 to get the “units” part
Reassemble the two values as one string
Repeat for how many BCD hours/minutes/days you have to deal with