For the moment, I’ve got a script that sets my heating or cooling ON/OFF. Based on the actual temperature and a wanted temperature. I just have 1 temperature sensor inside, and a ON for cooling and a ON for heating.
I’m thinking now of certain scenes (fe away, holidays). To save energy (heating and cooling)
But I want a kind of intelligence in this.
For example, in the winter, when it’s inside 18 degrees, and the wanted ‘away’ temperature is 15 degrees, it should not trigger the airco in this case. Just let it drops slowly. And only trigger the heating if it goes below.
Another example could be, in the summer, when’t it’s inside 21 degrees, and the wanted ‘away’ temperature is again 15 degrees, It should only be trigger if it goes fe 35 degrees (just saying something).
What’s the best approach for this? What’s the easiest/best/simple thing to do in this case?
Draw out what you want in a state diagram and look for ways you can break things down into substates.
Once you have it all mapped out it is just a matter of writing a really long if/else or switch statement that represents all the lines on the state machine.
In your case, the states you are trying to get to is whether to turn on cooling/heating or not. But a number of other states feed into that decision (summer/winter, current temp, presence, etc). Separate out the calculations of those other states from the cooling/heating states to make your rules a little more manageable. Good luck!
I broke my head what a good (read simple) solution would be. But before I do stupid things (read a lot of work, sorry, try-and-error), I prefer to ask advice at some guys that are much better at this.
I played a bit with the winter/summer as reference, but how to handle spring/autumn?
And maybe I can use the outside temperature based on the weather binding? But then, how to calcute with these values?
Today, I think of 4 different ‘cases’: Off, Manual, Work & Away.
So my problem is with the Away. How to get him energy friendly / smart…
The hardest part is to identify all the states and what to do when the system is in those states. Once you have that it is a simple matter of just adding the if/else or case statements for each line leading to each oval. That is what the state diagram is for.
There is no simple solution. The code is simple but identifying all of the conditions and states is complicated. One way you can do this, if you don’t want to draw it out in a state diagram, is to use a table.
Put all of the possible states (that have meaning) across the top and add a column to what to do. Then add a row for each combination of states in which you need to do something and write what you need to do when those states are true.
You have now identified your state machine. Now you just need to write the code. Write an if statement for each row. The conditional is checking for all those Xs and the body of the if statement is what you wrote in the last column.
I’m certain there are ways to implement this in a smart and generic way (i.e. write the above table and have generic code to figure out what to do) but without the ability to share libraries I’ve not spent any time thinking about how to do it in Rules DSL.