How to define a global variable for temperature setpoints?

I have recently installed nine Stella Z radiator valves, each of which has its own temperature sensor. When the temperature drops below its pre-defined setpoint, the valve opens and a z-wave command is relayed for the boiler to start up, via my Veralite.

However, I would like to define a global variable for my veralite that defines the ‘average’ setpoint in the house, and which each radiator valve can access and either add a degree or two to (for rooms I want to be a bit warmer, such as bedrooms) or subtract a few degrees from, for cooler rooms.

I would also like to be able to dynamically change the global ‘average’ temperature setpoint and for each thermostat to respond to the change by modifying their own setpoints. This would allow me, for example, to drop the temperature across the whole house after we’ve been for a run, but still keep each room warmer or cooler, relative to the average.

So… What would be the best way to do this? I can see that it’s possible to define new variables in each device on the Veralite, and that I could use Lua to set the setpoint temperature +/- the average, but I’m not sure about how to define a global variable.

Any suggestions much appreciated.

The easiest way is perhaps to define it in the Lua Startup code…

MyGlobalVariable = 42

Other scenes (and apps) can then simply reference this.
You may care to give a bit of thought to namespace management, in which case you might write:

SWS = {
  MyGlobalVariable = 42,
  -- other variables could go here later
}

and then you would reference it through [tt]SWS.MyGlobalVariable[/tt]