HestiaPi / hestia-touch-openhab

OpenHAB2 files for HestiaPi Touch model
GNU General Public License v3.0
60 stars 17 forks source link

Cleaned up default.things #29

Closed rkoshak closed 4 years ago

rkoshak commented 4 years ago

default.things was generating a bunch of parsing warnings every time it was loaded so I took some time to clear up those warnings. In the process, I also reorganized the Things to follow best practices:

So I gave each Thing a meaningful name. And I reworked the Generic MQTT Things so similar Channels are grouped into one Thing. For example, all the heating controls are in one Thing, all the Network info Channels are in another Thing and so on.

This reorganization required changing the channel links in the default.items. So I took this opportunity to apply the follow profile which allowed the elimination of a number of Items and Rules whole sole purpose was to publish changes to an Item to an MQTT Topic. Not only does this remove unnecessary Items and Rules but it also means those messages will be published even when the .rules file is waiting to be loaded. And fewer Items, Things, and lines of .rules files should lower the boot time a little.

Finally, these changes make the Configuration -> Things and Control pages in PaperUI much more usable.

image

Signed-off-by: Richard Koshak rlkoshak@gmail.com

rkoshak commented 4 years ago

One note: there was a known bug in OH 2.4 that has since been fixed I believe that caused a warning in the logs when the .items file is loaded complaining about "Cannot add "Metadata" with key ..." for Items using a profile. These should go away on an upgrade to OH 2.5.

gulliverrr commented 4 years ago

@rkoshak Could you apply your changes to the latest files to avoid manual merging?

rkoshak commented 4 years ago

Sure. What I'm not sure about is the best way to do it. I imagine closing this PR and opening a new one?

gulliverrr commented 4 years ago

Whatever is the easiest for you. Not very fluent in GitHub's approach in resolving these situations so just do what you prefer. Eager to time a boot after all these changes... :)

rkoshak commented 4 years ago

Eager to time a boot after all these changes... :)

Don't get too excited. I think I've only shaved a few minutes from the boot time between this and the Rules merging. It's still too long. I should have taken a benchmark before time. Maybe I still have logs I can use to recover it. The other PR didn't save as many lines of code as I would have liked, but I've some more ideas there too (we should be able to get away with just using C in the rules and a visibility flag in the sitemap to show C or F based on the temp setting using UoM which will save some code, some scripts, and some Items. I think the main benefit to these changes will be maintenance.

For example, if you add a Schedule mode (looks like one was started but never completed) you just need to do it once and it will be active for all the devices. Testing should be easier now because there is so much shared code you only have to test certain things on only one device type.

Anyway, I'll look to see how difficult it is to bring the latest from ONE into this branch. If it's a pain I'll close this and build a new branch and PR.

rkoshak commented 4 years ago

Assuming I didn't mess something up this PR should now be merged with the latest ONE branch with the new changes applied. Everything looks right in the Changed files tab so I think this is good for review and test.

BTW, the following commands work, assuming you set up the upstream (see https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/configuring-a-remote-for-a-fork).

// Merging changes from latest ONE branch in this repo with my fork
git checkout ONE
git fetch upstream
git merge upstream/ONE
git add . // not certain this is needed
git commit -m "Merged with upstream"
git push

// Merging latest ONE with thing-cleanup branch
git checkout thing-cleanup
git merge ONE

Then I used git mergtool to resolve the conflicts. There was only one file that had a real conflict, the .items file.