First post, (hopefully of many), so be gentle.
I’ve got openHabian running on a pi3 and so far so good. I’ve spend a few weeks running through the tutorials and forums and have done the usual install, fiddle, brick, re-install, learn a bit more, brick etc and I’m pretty happy I’ve got my items, things, groups, sitemaps all where I want to be and I’m now writing rules and - as a coder in a previous life - I want some steer as to the concept of variables.
Usually I’d do something like ‘If I’m home set a global variable_home to ‘ON’ or something similar’. Then I’d be using that variable elsewhere to trigger stuff or something. I’ve got in my head that I can create a dummy item in the .items file which I can then use in a .rules file and also in the .sitemap file to give me a switch to have a visual representation of it, and also to give me the ability to toggle it manually.
Now, first part…is this the best way to be going about this or do I need to change my code thinking a bit?
Second part…I’m also used to having a ‘Master’ variable that I use in all if / then type statements so that if everything is going wrong I just set one variable to OFF and then no rules run…kind of a big off switch if you will.
If got this working in principle, I have a variables.items file with an item
Switch MasterSwitch “Master Switch”
The I can use it in rules only if Item MasterSwitch = ON
However, I’m thinking I’d have to add it into every rule that I want to be able to master switch OFF should I need to, and that just seems a lot of work to remember to add it in every time…
Again, am I thinking illogically around this? Is there a better way in openHab?
Thanks in advance