The basic logic with config?

Being new to openHAB seems to have put me back to an early beginner stage – all previous knowledge ever gained, out of the window.

There is documentation, and I’m reading it, however…

Being a big picture guy, I am missing something.

I installed openHAB 1.8.x; see a configurations directory – all good.
Created my own sitemap as max01.sitemap
put in some groups, added the weather, by simply copying the demo.sitemap weather section, and it works. But why does it work. I have not defined any items, rules, or else for that matter.
Why does this work? Is this build-in functionality, or does it pick up stuff from the demo.* files?
Are all these config files read and interpreted together?
I though all demos.* work together and all max01.* work together, but it does not look that way.
I only have one binding (MQTT), does the weather not need one?
I feel soo stupid… sorry. :frowning:

Take a look at the layout/example.html (this is the one you refer to from sitemap). This document refers directly to data from the weather binding, so you don’t need any items for displaying values. However, if you want to build rules which need forecast, you need to define the items

Thanks Udo… but where do I find example.html?
It is not in /opt/openhab/*

It should be in ./webapps/weather/layouts/

I have installed 1.8.3 which has a directory /openhab/webapps, one README and two directories named static and images… but no file example.html even when 'find’ing from /

when you did install the weather binding, didn’t you install this? How do you see any weather data in the UI, if you didn’t setup any items or pagelets?

Thanks Udo… no, never heard or seen this file. (I have a look at what it does shortly.)

I installed openHAB based on the OH Getting started http://www.openhab.org/getting-started/ page.
It says, download .zip, install in /opt/openhab which I did. Downloaded the demo.zip, unzip. All good.

Looked at demo and started building my own max01.sitemap and max02.items.

I copied this section from demo.sitemap, without any changes to (the default) openhab.cfg
Frame label=“Somerset Weather” {
Text item=Weather_Temperature valuecolor=[Weather_LastUpdate==“Uninitialized”=“lightgray”,Weather_LastUpdate>90=“lightgray”,>25=“orange”,>15=“green”,>5=“orange”,<=5=“blue”] {
Frame {
Text item=Weather_Temp_Max valuecolor=[>25=“orange”,>15=“green”,>5=“orange”,<=5=“blue”]
Text item=Weather_Temp_Min valuecolor=[>25=“orange”,>15=“green”,>5=“orange”,<=5=“blue”]
/* Text item=Weather_Humidity /
/
Text item=Weather_Humidex /
Text item=Weather_LastUpdate visibility=[Weather_LastUpdate>30] valuecolor=[Weather_LastUpdate>120=“orange”, Weather_LastUpdate>300=“red”]
}
Frame {
Switch item=Weather_Chart_Period label=“Chart Period” mappings=[0=“Hour”, 1=“Day”, 2=“Week”]
Chart item=Weather_Chart period=h refresh=6000 visibility=[Weather_Chart_Period==0, Weather_Chart_Period==“Uninitialized”]
Chart item=Weather_Chart period=D refresh=30000 visibility=[Weather_Chart_Period==1]
Chart item=Weather_Chart period=W refresh=30000 visibility=[Weather_Chart_Period==2]
}
}
}
… and changed the URL in demo.items to:
Group Weather_Chart (Weather)
Number Weather_Temperature “Outside Temperature [%.1f °C]” (Weather_Chart) { http="<[https://query.yahooapis.com/v1/public/yql?q=select+
+from+weather.forecast+where+woeid%%3D1097507+and+u%%3D%%27C%%27:60000:XSLT(yahoo_weather_temperature.xsl)]" }
Number Weather_Humidity “Outside Humidity [%.1f %%]” (Weather) { http="<[http://weather.yahooapis.com/forecastrss?w%%3D638242&u%%3DC:60000:XSLT(yahoo_weather_humidity.xsl)]" }

basically changing the URL format and woeid

Since I do not have this in max01.files, I can only assume if not assert that the various .items and .sitemaps seem to work together. E.g what is defined in one file, is working for the other – or more clearly, what is defined in demo.items, seem to impact max01.items.

Is this assumption correct?

what I planned for today is remove all files (demo, default.) and only leave my max01. files and see what happens. Again, I assume the weather would not function any more.

Yes. When something is defined in any file in items, that item is then available to any sitemap and any rule by the same name. So since you have the demo items in your items directory, you can use them in your max sitemap…

…which makes sense, when you think about it. I have all my dimmers in a file called dimmers.items. But I want to be able to include dimmers in my main sitemap and not just a special dimmers-only sitemap. Since any items file is available to any sitemap, I only have to define my dimmers one time and can use them multiple places.

1 Like

Thank you, very helpful and makes sense… I stepped away from openHAB for a day, just to clear my mind, and removing the ‘other’ config files would have been the next step. As expected, the files are all considered together.

Yes. the thing about multiple files is a bit tricky, because it depends on the file…

Multiple .items files can be used to organize your items. You can make a groups.items and put all groups in it, one file for switches, one file for rollershutters, or one file for knx items, one for onewire and so on. But as openHAB has exactly one event bus, all items will be available at any part of openHAB.
Be aware that all .items will be reread if one .items file will be touched and thus all items will be unintialized if one .items file is touched. This due to the data consistency.

Multiple .sitemap files, in contrary can be used to split the access to items. you will only see the items for which there are configured widgets in a .sitemap. If you change anything in one .sitemap, only this one will be reread, because it’s only for displaying the UI and changes can’t carry weight in other sitemaps.

Multiple .rules files can come in handy when the rules grow. The Designer will take a long time to open and verify a rule file, but will be fast if the file is small. On the other hand, if you change a .rules file, this will be completely reread and some rules might be executed because of the trigger system started, but others in other .rules files might not. This is very important to know, beause there can be strange effects if openHAB is restarted “partly”. As a second point to be aware, any variable defined outside a rule will be available only to rules in this file, but strange effects can occur if you use identical variables in different .rules files. To use global variables, try to use items whenever possible.

In question of .persist files, there is exactly one .perstist file for each persistence service, so every item can be persisted in different ways per persistence service.
This applies respectively for other special files like transformation and scripts.

1 Like

Well, couldn’t resist and am back at it… I deleted the ‘other’ config files, other than the ones I newly created, and it makes much clearer.
Also actually reading README in these folders would have told me that the files ‘dumped’ in here are automatically updated… duh :slight_smile:

Thank you for the detailed explanation!