Hi all,
I am still working on the Modbus communication between my Siemens LOGO and HomeAssistant.
So far, most of the things I wanted to implement are working - but now, I am playing around with some additional features.
So - basically, my LOGO is running fully automated - turning the lights in my terrarium on and off based on an astronomical clock.
Now, I already know how to read some of the variables my logo is using - for example, the time settings when the light will be turned on - and off…
The problem here is, that the LOGO does provide these values in decimal values…
Example:
Sunrise = 1799
Sunset = 5940
For sure, this isn’t going to work in my Dashboard - and I want to convert these into a readable format…
The best option would be, if I can do this directly within the yaml code for the sensor, since I can define the device_class there.
- name: Sonnenaufgang (t1)
unique_id: "t1_sunrise"
address: 0
input_type: holding
#device_class: timestamp
scan_interval: 10
swap: word
- name: Sonnenuntergang (t1)
unique_id: "t1_sunset"
address: 1
input_type: holding
#device_class: timestamp
scan_interval: 10
swap: word
I already found some information on how to convert this decimal value into a string … (I’ve done this with NodeRed previously, but want to get rid of the NodeRed implementation)
in node red:
var asHex = parseInt(msg.payload).toString("16").padStart(4,"0");
var hh = asHex.substring(0,2);
var mm = asHex.substring(2,4);
msg.payload = `${hh}:${mm}`
return msg;
this will then provide a payload like: 17:34 or 07:04 - but only as string.
So: the goal:
I want to format the incomming decimal value into a ISO timestamp string.
Unfortunaltey, I don’t think that the modbus-plattform does support something like a value formatting…?
( in this case… why isn’t such option available? I could imagine, that many Modbus devices are using formats as decimal, hex or whatever to deliver the raw data…)