Is there a problem with nested if statements? All questions

Hi!

I have a sequence where targetHomeTempChange should be updated based on todaysLowTempForecast and tomorrowsLowTempForecast. The sequence fires correctly, but it seems to skip the nested if statements. I set tomorrowsLowTempForecast to 0 and todaysLowTempForecast to 4 and I would expect the targetHomeTempChange to be set to +1, but instead it gets set to 0, which is the last else statement.

Do I have something set up incorrectly or is there a bug here?

Best Regards,

Fredrik


Asked by Fredrik on April 8, 2020, at 5:53am

Hi Fredrik, it looks like you're trying to perform a calculation in the sequence - ie to calculate (todaysLowTempForecast - 3) and then do a comparison on the calculated value.

Unfortunately SEQUEmatic doesn't perform calculations, it just takes a value or variable and compares the values. I could look into adding basic calculations though if that would be useful for you?

Hi Derek, thanks for the quick reply!

Sorry, I've worked as a developer previously and I just assumed you could do that :)

I can just as well add some helper variables to get the correct values to compare to. The reason for my calculation is to simulate a kind of hysteresis, so that something would only happen if there is a significant difference between two values. I have the same kind of formula in another sequence so I'll have to update that one as well.

Of course, basic calculation could be helpful, or then just a quick check that notices that you're trying to do a comparison between a number and something else and warn you it won't work.

Regards,

Fredrik

Quite a reasonable assumption!

Let me take a look at it over the long weekend - it shouldn't be too difficult to implement. A good suggestion to at least have it alert that it wont work. I'll post back here once it's ready.

PS: Thanks a lot for the donation!

So for anyone reading this post, instead of having this (which won't work):

If tomorrowsLowTempForecast is below [todaysLowTempForecast - 3], then...

I added a new variable: todaysLowTempForecastMinus, and then did this:

  • Set todaysLowTempForecastMinus to [todaysLowTempForecast]
  • Decrease todaysLowTempForecastMinus by 3
  • If tomorrowsLowTempForecast is below [todaysLowTempForecastMinus]

Post a reply

The SEQUEmatic bot is still new and learning. If you don't get the answer you need, just ask to speak with Derek and your chat will be transferred.