SWITCH case evaluation


#21

LOL, I was just about to ask that. The mid-condition isn’t accounted for. I suppose I could just fill out the entire array with every correlating value. . . .


#22

Yep, I was going to post two samples - one like that, and one using expressions to get around it. Now I’ll just post the latter. :slight_smile:


#23

This is going to be crazy useful. Another use case I’m looking for is “warm up the house, but I’m not in a big hurry.”. This is a second home up in the mountains that I “hibernate” when I’m not there. But when I’m going up there I “wake up” the house, meaning the heat gets bumped up. The issue is that doing that immediately kicks on the emergency heat, e.g. 10kw coils. The energy suck is enormous. I’d rather run the heat pump for 4-5 hours to accomplish the same goal for way less energy vs. an hour with those coils. Next piston will be a “gradual warm-up” routine :slight_smile:


#24

That’s great, glad to hear this is working for you and will be put to good use!

I have a couple ideas how we can gradually heat your house, too. Probably best to do it within THIS piston or set a global variable so the pistons don’t run simultaneously, otherwise this piston may read the outdoor temp and overwrite your heat setting when you’re trying to warm the house.

This works across the range and doesn’t require you to put in every conceivable number throughout the range. Any questions, let me know!

image


#25

I’m working with your original code now and I was thinking exactly the same - this is where some pre-emptive if statements will prevent excess execution and catch the high / low / and mid-range conditions. I’ll post what I come up with shortly for critique / suggestions for improvement if you are still game :smile:

Just for fun. . . . . . .On the gradual warm-up, what would be absolutely fantastic is a timed based warm-up routine, e.g. I’ll be arriving in 6 hours, so warm up the house with the minimum energy draw in that much time. example - if we are 10 degrees off target temperature set appropriate intervals to wait on the heat pump and then kick up the thermostat as necessary to hit the desired target. That way one could maximize the energy savings from the heat pump, but still kick on the backup elements as needed to hit the target in the alloted time. LOL!!! I’m just getting silly now I know, but it’s so much fun to be able to do all this :smile:


#26

Absolutely!! I was going to suggest the same. Give it a shot so you can push yourself a bit, post up and we’ll see if there are any improvements we can make. Looking forward to it! :slight_smile:

I can think of a few ways we can do this, but first I need to understand your system a bit better. I assume since you’re changing your thermostat with webCoRE, you can also change it with your phone? First thought is this:

The piston we’ve been working on will only set the heat within a range of 45-55 degrees.

Knowing that, you can set a trigger that says “if thermostat heat setting is exits range”:

Then start increasing heat 1 degree per hour until target setpoint reached.

OR do (Desired setpoint - Previous Setpoint) / number of hours until your arrival.

Either will require some additional variables and logic. Take a crack at it and see how far you get, then we’ll finish it up. We can have this all knocked out by this evening and ready for your next trip!


#27

Nice!! I’ll take a look at that approach next. I think I’ve come up with a clean / elegant way to solve for the immediate issue though. Based upon what I’ve learned here’s what I’ve come up with. I think it balances simplicity of the expressions with easy to follow logic. I decoupled it from any specific devices so it will run for anyone, all one would need to do is add in a statement associated Outside_Temp to a weather station and then supplement the log output with actual thermostat actions. Comments or critiques are welcome :slight_smile:

Note that the superfluous if statement (less than 40) is actually placeholder for the trigger to kick-start this if it were real. I realize it’s not purely necessary for this example.


#28

For reference here is my full implementation. So far it seems to be working as well as the old version - but the code is oh so cleaner :smile:


#29

Oh no, you killed off my cool expressions! Lol

That should work! The only real benefit to what I posted was it exposed more features of webCoRE for you to dig into and use to develop future pistons, and you could have a gap in your series of numbers above.

Glad you were able to get it cleaned up! Infinitely easier to follow than what was going on before!


#30

Nicely done! Now you just need to swap out a pre-defined variable for your weather station reading. You can do that in the variable itself, or delete the variable and reference your weather station directly in your conditions.

Making future changes just got a lot easier than that behemoth of an expression you had in your earlier revision too!


#31

Can you tell me a bit more about this? I actually retained your original suggestions to deal with the gaps for future reference (I have suspended pistons for holding examples like that :smile:) - so all is not lost there. I just like the flow of what I did better in terms of immediate readability.

I originally had a variable defined with the outdoor temperature vs. referencing the device over and over. . . .but it didn’t read as cleanly. Is that what you mean by your comment above. Thanks so much, I’ve learned a ton in a short time today.


#32

I’m going to give it a go :smile: The trick is allowing me from my phone app to set a dynamic value for the thermostat. I’m not sure I know a straightforward way to do that. My other option is to simply have a set of functions to do a gradual warmup, and then use my normal routine when I’m about to leave (takes me 1 hour to get there). That’s usually enough time to warm things up.

Initial approach - create a virtual thermostat device that creates a “soft target” for the primary thermostat, gradually sliding up the temperature one degree at a time vs actual temperature but never exceeding a 2 degree differential (triggering emergency heat). That’s what I’m currently thinking. Will work in a bit and post back for input.


#33

Yep, that’s exactly what I meant! You can either set Outdoor_Temp = weather station reading, or delete the variable and change your condition statements from “If Outdoor_Temp > 40, do this” to “If Weather station reading > 40, do this.”


#34

Of course Smartthings is kicking errors at me now. Can’t add any devices, change anything because “I don’t have permission”. .grrrrrrrr


#35

I believe I’ve solved the gradual warm-up challenge. It’s not yet elegant but I wanted to get it working first, which I believe I have accomplished. I’m now looking into possibly a while loop or another way to do this more cleanly vs. a series of IF statements. They do the trick, but again. . . .not very elegant. Here’s the solution I came up with:

  1. I created a virtual switch in Smarthings called the “gradual warm-up switch”

  2. When that is flipped to ON I set the heating point at current temperature + 1.0

  3. If the temperature changes and the gradual warmup switch is on, it will readjust the thermostat to current temp + 1.0 until the target is acheived.

  4. I have a catch statement to make sure the setpoint never falls below 43, which can actually happen if it is extremely cold. In those conditions running the heat pump simply will not heat the house, and it wouldn’t do to freeze things up while trying to gently heat the house.

  5. I caveated the statements to make sure they will only run when the house is hibernated, e.g. the alarm is set, etc. Otherwise the switch is ignored.

  6. I also added a condition to my other piston that automatically adjusts the thermostat to not function if the gradual warm-up switch is engaged, otherwise I suspect they would fight with each other for control.

I have it running now and it’s working perfectly. Thoughts?? :smile:


#36

Looks like a good start! You’ve got the trigger set-up so starting your “warm up” routine triggers the piston, and then changes to the reported temperature from your thermostat keep dialing it up 1 degree at a time.

I’ll post up an alternate way of doing it after dinner, but I don’t see any reason it wouldn’t work! Good catch with the 43 on there too!


#37

Sadly, running this routine can help confirm your suspicion over the last few weeks that your heat pump actually isn’t working at all. Which explains the $400 power bill last month. GRRRRRRRR. Something is amiss. My routine was working great, but the house actually just got colder while it was running, always maintaining 1 degree above the actual inside temperature. And only about 10 degrees colder than outside. . . . .UGH. Time to call the HVAC repair man. :frowning:


#38

Ugh, I feel for ya! Those calls are never cheap. :frowning:


#39

So sadly my dynamic thermostat management routine is suddenly failing. For reasons I can’t explain the routine is returning a 5 and seeing my thermostat quite low! For the life of me I can’t figure out how it’s getting a 5. Any clue at all?



#40

It would only do that if the index was shifted by a character, so it was returning a comma and a five rather than the number you want it to:

50, 51 ,53, 54

Can you post full logs too. Have you modified OTemps or ITemps from what you have above?