Reply to post: Re: I can handle this one

Nest thermostat owners out in the cold after software update cockup

Jimmy2Cows Silver badge
Headmaster

Re: I can handle this one

<CodePedantMode>

Close but no banana...

Defensive coding 101 - never assume side effects in functions, and avoid adding side effects to functions.

If (too_hot)

{

Heat_Off();

AC_On();

}

Else if (too_cold)

{

AC_Off();

Heat_On();

}

Else

{

Heat_and_AC_Off();

}

Plus there's no guarantee that turning the heater on turns off the AC, and vice versa. If the sample rate isn't high enough, transition from too hot/cold to too cold/hot could skip the Heat_and_AC_Off() call allowing heater and AC to be on together.

</CodePedantMode>

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Biting the hand that feeds IT © 1998–2019