"#define" or "var = " in .items file?

I am currently working my way through adding items to my .items file. Thankfully, I have a DarkSky account from way back, so I’m adding the rules on this page. https://www.openhab.org/addons/bindings/darksky/ There are a lot of them. I am typing them all in by hand so that I really get it my head.

However, I find myself typing (copying and pasting) this quite a bit.


I think it would help clean up the .items file if the parser would let us make a line like this at the beginning of the file.

#define darkSkyAccLoc = “darksky:weather-and-forecast:dark_sky_account:local”

So then later on I could do $$darkSkyAccLoc, or something like that.

Maybe a “var” statement like in the rules files, since the parser is kind of like that.

Thank you for this awesome application.

I wouldn’t spend much time on DarkSky right now. They are shutting down their API for all users in about a year I think.

As for your suggestion, all I can say is you can open an issue on Github and see if anyone wants to work on that. I think the general overall direction is to move away from text based configs (i.e. .items files, .things files, etc.) so I can’t say whether it would be adopted.

I’ve had some cases where having a feature like this would have been useful (e.g. when moving from DarkSky to OpenWeatherMap when DarkSky announced they were acquired by Apple and is shutting everyone else out of the service) but over all, linking Items to Channels is something that is usually done once or at the very least rarely. I’m not sure how much it’s worth it to spend a whole lot of time developing stuff to aide that when there are other areas that are a more persistent and common problem.

What I would probably do is just define all your items in the file using the $$darkSkyAccLoc placeholder or even simpler, something like AAA and before the final save, just do a quick global search and replace with the proper value

1 Like