So that I can display if they are all OK in HabPanel, is my syntax correct in the items file? OH2 accepts it. But looking in the console the items dont return ‘OK’, just 1
Yes, it works without the map file (how ive got it right now)
It turns ‘1’ for all strings, which is what I’d expect as the router shows all fans operational and OK ie: Value 1
I just want to translate the 1 to OK so I can report it in Hab Panel, something a bit more friendly. And then eventually, use a group to define that if any of them are 3,4,5 then report the group as ‘FAIL’
18:50:02.144 [WARN ] [.rest.core.item.EnrichedItemDTOMapper] - Failed transforming the state '1' on item 'gFANS' with pattern 'MAP(C3945snmp.map):%s': An error occurred while opening file.
18:50:02.148 [WARN ] [.rest.core.item.EnrichedItemDTOMapper] - Failed transforming the state '1' on item 'C3945_FAN1' with pattern 'MAP(C3945snmp.map):%s': An error occurred while opening file.
18:50:02.152 [WARN ] [.rest.core.item.EnrichedItemDTOMapper] - Failed transforming the state '1' on item 'C3945_FAN2' with pattern 'MAP(C3945snmp.map):%s': An error occurred while opening file.
18:50:02.155 [WARN ] [.rest.core.item.EnrichedItemDTOMapper] - Failed transforming the state '1' on item 'C3945_FAN3' with pattern 'MAP(C3945snmp.map):%s': An error occurred while opening file.
18:50:02.158 [WARN ] [.rest.core.item.EnrichedItemDTOMapper] - Failed transforming the state '1' on item 'C3945_FAN4' with pattern 'MAP(C3945snmp.map):%s': An error occurred while opening file.
18:50:02.161 [WARN ] [.rest.core.item.EnrichedItemDTOMapper] - Failed transforming the state '1' on item 'C3945_FAN5' with pattern 'MAP(C3945snmp.map):%s': An error occurred while opening file.
I have noticed your UPTIME for the server
I use this transform that makes it really easy to read:
time.js in the transform folder
Make sure the javascript transform is installed
(function(i) {
if (i == 'NULL') { return i; }
if (i == '-') { return 'Undefined'; }
var val = parseInt(i); // The value sent by OH is a string so we parse into an integer
var days = 0; // Initialise variables
var hours = 0;
var minutes = 0;
if (val >= 1440) { // 1440 minutes in a days
days = Math.floor(val / 1440); // Number of days
val = val - (days * 1440); // Remove days from val
}
if (val >= 60) { // 60 minutes in an hour
hours = Math.floor(val /60); // Number of hours
val = val - (hours * 60); // Remove hours from val
}
minutes = Math.floor(val); // Number of minutes
var stringDays = ''; // Initialse string variables
var stringHours = '';
var stringMinutes = '';
if (days === 1) {
stringDays = '1 day '; // Only 1 day so no 's'
} else if (days > 1) {
stringDays = days + ' days '; // More than 1 day so 's'
} // If days = 0 then stringDays remains ''
if (hours === 1) {
stringHours = '1 hour '; // Only 1 hour so no 's'
} else if (hours > 1) {
stringHours = hours + ' hours '; // More than 1 hour so 's'
} // If hours = 0 then stringHours remains ''
if (minutes === 1) {
stringMinutes = '1 minute'; // Only 1 minute so no 's'
} else if (minutes > 1) {
stringMinutes = minutes + ' minutes'; // More than 1 minute so 's'
} // If minutes = 0 then stringMinutes remains ''
var returnString = stringDays + stringHours + stringMinutes
return returnString.trim(); // Removes the extraneous space at the end
})(input)