Hi all,
I am receiving a string which I want to format and extract only some information from it.
This is the string I am receiving:
openWB/system/Uptime : msg.payload : string[67]
" 12:31:14 up 15 days, 16:38, 1 user, load average: 1,03, 1,48, 1,40"
this is what I want to get from the string (bold)
" 12:31:14 up 15 days, 16:38, 1 user, load average: 1,03, 1,48, 1,40"
In a python module, I am using this for the format... now I need to translate this into a node-red function...
# Reformat uptime sensor
if "uptime" in self.entity_id:
days = self._attr_native_value[12:].split(',')[0][:-5]
hourmins = self._attr_native_value[12:].split(',')[1]
hours = hourmins[1:].split(":")[0]
mins = hourmins[2:].split(":")[1]
self._attr_native_value = days + " d " + hours + " h " + mins + " min"
Any Idea on how I can do this?
Thanks