I purchased Hubitat (ST convert) recently and I am trying to set up one thing at at time before I move on to the next. At first I thought I would use Mode Manager for all my mode switching, but it turns out I have some crazy modes that require more advanced logic.
My idea was to create a series of global variables and work those into a string that could be used to help switch modes.
Alpha= Time of day. Variable 1 is day, 2 is sunset, 3 is night.
Beta= Occupancy. Variable 1 is I am not home, 2 is I am home.
Charlie= Guests. Variable 1 is no guests, Variable 2 is guests.
So, if it were night time, while I am home, with guests, then my String wants to be #322.
A rule will recognize a change in that string and a series of actions evaluate which is true in order to change my mode.
That part I am stuck on is writing a rule and the syntax to use around that rule to take those series of variables and create a string with them. I read the global variables threads on these forums, I have tried to follow some with no success.
Any advice would be helpful!
You can set a String variable with %variable-name% as the string value, or %v1% %v2% %v3%...
So in the case of my variable names it would be..
Set Variable String Mode:
%Time Of Day%%Occupancy%%Guests%
If you put in a delimiter character, then a rule can also take it apart with Token...
A space character can be a delimiter. I'm not sure how you're trying to use the resultant string in a rule...
Here is what I am trying to do. Evaluate the string and chose a mode.
Alright, well here it is. I should get a four digit string, but that isn't not happening at all. I am sure whatever it is, its simple and I can't see it.
Can you use Mode Manager with settings for DAY SUNSET NIGHT AWAY and a variable for GUESTS? RM then has the logic to perform actions based on Mode and GUEST variable?
Do you think that will create a race condition? At 8AM every morning both rule manager would attempt to switch to day, while my other rule attempts guests...
Humor me with a test, but a space between each variable in that, and see if it sets the variable correctly, i.e., the 4 digits separated by spaces.
Not really a race condition,, but you can't tell who would win the race. I do think you're making this much harder than it needs to be. Could you maybe back off from all of the rules and describe in English how modes are supposed to be set?
Modes are based off presence, time of day, guests, and sleep.
So... Daytime, no guests, present=Day
Daytime, guests, present= Guest day
and so on...
The space test between the variables did not work.
One rule to rule them all.
If guest then
If day then ...
else if sunset then ...
else ... (must be night)
else if not guest then
if day then ...
else if sunset then ...
Ok.. I am with you.. let me see what I can build.
What version of Rule are you using?
That's odd. It works as expected for me. Are you using Set String in Set Variable?
And it works fine for both Local and Hub Variables...
When I backed up and created variables as alpha designations as you have done, I am able to get this all to work and create the string. Is there anything I should know about naming variables that might of stopped my original ones from working?
Just wanted to come back and say I got this all working and my mode logic is functioning. Thanks you all for the help!
Hi, can you give some screenshot examples of your rule, the strings, the variables etc etc. I'm trying to get my head around what you have achieved
Sure here is how I did it.
Variable A, B, and C are all different conditions such as time of day, or guests. I then use variable string E to put all those numbers together by writing the rule for variable E. Every time variable E changes, I have a rule that uses that change as a trigger and matches the current value of the string to decide my mode.