Save/Restore without Global Variable(s)

It seems that a restore sets Global Variables to their values at the time of backup (whicm may be days ago). For Global Variables that capture a 'state' (e.g. powerwall Site import value at 4PM) this can lead to anamolus results in rules. I'm not sure there is a good fix for this, but the ability to backup/restore without affecting Global Varialble might help (but has its own problems).

I'm new (less than 1yr user) for hubitat and rule machime, so I might easily have missed something and would like to be educated on this aspect.

Hub variables are stored in the hub database, and the backup and restore is for exactly that. So, the behavior you're seeing is definitely expected. Global variables, if you really mean that, are a Rule Machine Legacy feature and would also be backed up and restored like any app as part of a backup and restore (or even an export and import/restore of that parent app).

If you care about specific values, you have the ability manually set the value of a hub variable in Settings > Hub Variables. (Or again, if you really mean global variables, you can do something similar in the Rule Machine Legacy parent app.) Checking there beforehand and manually changing whatever values you care about afterwards is probably your best bet.

Or -- why are you doing so many restores? :slight_smile: Is there a problem you're trying to solve, or could there be some other way to accomplish whatever your goal is there?

  1. I only know how to initialize Hub Variable at creation (without creating a rule to set the value). Is there a way to reiniialze without removing (causing broken rules)?

  2. I do a lot of backup/restore as I continuously develop (improve, change) rules. I;m working with a powerwall and capture states for calculations (e.g., how much power was imported from the grid during Peak (4PM to Midnight yesterday)).

What do you mean with "reinitialize"? You have to set the hub variable to some value on creation. The method I described above lets you set it any time after (Settings > Hub Variables). It makes no difference whether the variable was just created, had already been set via other means, etc.

Have you considered cloning or exporting/importing a single rule rather than your entire hub database? You can do this from the App Status Page for that particular rule.

I understand how to create and set an initial value for a Hub Variable, however, I do not understnd how to go to Setting > Hub Variables and change that value (reinitialize). If I double click on the variable I get a list of rules where it is used and/or I can remove the variable, but to set a new value does not seem to be an option.

I did not know about the App Status Page. I think that might work for my concerns, I'll have to try it and see. Thanks for the education.

On the Settings/Hub Variables page you just click on the Value cell for that variable and it will present a box to enter a new value:

The above method is the way, as described here: Hub Variables (Settings) | Hubitat Documentation

Yes, cloning or exporting an app is almost certainly a better solution than backing up and restoring your entire hub database for just that one thing.