Last active
March 31, 2019 17:55
-
-
Save JasonHarder/d962e21a57076efe93f7557289473d5e to your computer and use it in GitHub Desktop.
Highlimit Restart Count created by Blinkfaster - https://repl.it/@Blinkfaster/Highlimit-Restart-Count
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let temperatures = [9,null,10,null,null,68,null,70.1, null, null, 72, 80,null, 69, null,78,null, 84,100,300,50, null, 70, null, 90, null, null, null, 50,null,100,null,null,85] | |
//if it is below the setpoint we can assume the ecobee would have called for heat. | |
// Heat call or if set temp goes under set point. | |
let furnace = true | |
let formattedTemps = [] | |
let restarts = 0 | |
let setPoint = 70 // later on iterate and set it to the same temp in the column | |
// nullcounts = true , when we hit a restart null counts = false , it is setup this way so that way multiple null values are only counted once. | |
const formatData = (Array) => { | |
let nullCounts = true | |
for (let temperature of temperatures) { | |
if (temperature === null && nullCounts === true) { | |
restarts +=1 | |
nullCounts = false | |
formattedTemps.push('restart') | |
} else if (temperature !== null ){ | |
nullCounts = true | |
formattedTemps.push(temperature) // Stricter condition has to be created here. | |
} | |
} | |
} | |
formatData(temperatures) | |
const highLimitSwitch = (formattedTemps,setpoint) => { | |
let highLimitRestarts = 0 | |
// had to break down formattedTemps into its individual entries and break it down by index and datatype (operation) to get the iterators beside the string | |
for (const [index, operation] of formattedTemps.entries()) { | |
const previousValue = formattedTemps[index - 1]; | |
const nextValue = formattedTemps[index + 1]; | |
// break down type of operation (line 34) | |
// if temperature is lower than the setpoints || heat stage one (sec) has a number value greater than 0|| heat stage one on in reports = heat stage 1 = true. | |
if (typeof previousValue === "number" && typeof operation === "string" && typeof nextValue === "number") { | |
if (nextValue > previousValue ) { | |
console.log(` Before Restart ${previousValue} After restart: ${nextValue} `) | |
highLimitRestarts += 1 | |
} | |
// could add a typeof statement (if !previousValue (of if null/undefined) && typeof operation === "string" && typeof nextValue === "number") | |
} | |
} | |
console.log(`Total High Limit Count: ${highLimitRestarts}`) | |
} | |
if (furnace === true) { | |
highLimitSwitch(formattedTemps) | |
} | |
console.log(`Total Restart Count: ${restarts}`) | |
// const heatstage1Check = (temperatures,setPoint) = { | |
// if heatstage1 = true { | |
// // run high limit func heat pumps can also overheat. (rename function in reference to overheating vs high limits) | |
// } | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The first version of the high limit restart function.