[SOLVED] Too dumb to work with files :-( ? stuck at getting started with files

I’ve become interested in smarthome/Domotica recently and decided to try it out using some Ikea stuff. So bought a Tradfri hub + some bulbs, a raspberry pi version 3. Installed raspbian on it and then used a tutorial to install Openhab2. Did try some other options (like homeassistent) but they seemed to have a VERY steep learning curve. Also I liked the overall look&feel of Openhab better :slight_smile: .

After a lot of trying and a lot of time spent I’m starting to get a bit disillusioned with this entire endeavour :frowning: . Sure I got some successes, and at first it seemed to go alright, but now I’m stuck and cannot for the life of me find good information, video’s and/or clear unambiguous documentation. /rantoff.
To keep things positive and geared toward solutions I will give a short description of where I’m at and what my specific hurdle/problem is:

  • Platform information: Raspberry pi 3 running Raspbian GNU/Linux 9
    • openHAB version: 2.2 *(updated at 27th april)

Where am I at right now:

  • Installed Openhab2 on the pi, got it working
  • Set up integration with Ikea tradfri hub
  • Succeeded in adding lights and switching them manually (all within Paper UI)
  • Installed bindings for Astro, Plex, Chromecast etc
  • Created a rule to switch on an outside light at dusk (civil event) and switching it off at 22:30 (this works fine btw, quite happy with this result)
  • Use programmes putty and winscp to get access to filesystem and commandline/terminal
  • Installed Visual code studio + the openhab addon, pointed it to a samba share on the pi with alle the files. Seems to do spell/syntax checks, but am not sure

What do I want to achieve

  • define lights using items file (rather not actually, but I read that at some point it gets to be necessary)
  • group items to I can switch them together (say multiple lamps on a landing)
  • configure rule to dim lights when plex/chromecast/netflix starts playing (webbased rule engine won’t let me do that, or haven’t found it)
  • set rule where I can access dim lights settings (ie dim lights to 20%, does not seem to be possible through webbased rule engine)
  • configure scenes where I can trigger multiple settings at once, so ‘watch movie’ (where lights dim, TV is switched on, etc)
  • Use rules with detected presence, so someone arrives at house: --> outside light is switched on; but only after dark

As I found the webinterface lacking in features and after doing extensive reading up on this forum I tried my hand at configuration using files. And that is where it gets interesting and frustrating. I must be dumb, because I cannot get this to work nor do I understand how to create files. Sure there is documentation on how to create files and proper syntax, but I simply dont get it. When I make an item in a file I don’t see it pop up in any of the interfaces. Searched for example items files,
things, rules etc, but still I’m stuck. Completely in the dark on what I’m doing too. Only thing that I did get working is to generate a sitemap file, but no items are visible in there.

So who can point me to a good source for clear and non-tech documentation?

Thanks so much

Kind regards,

Did you see the docs at docs.openhab.org?
You may benefit from reading the whole thing, but how to work with files is explained in some detail here:
https://docs.openhab.org/tutorials/beginner/sitemap.html
Another good way to get used is to look at the demo installation (and play around with it), but you may have to start fresh again.
Hope that helps.

Thanks for your reply. I did read that documentation, quite extensively too. Information about item/file syntax and format seems comprehensive but is not helping me.

not sure I am understanding everything here: if you define items in your item file and refer to these items in the sitemap, you should either see error messages or new entries in your sitemap. Did you check your error logs?

I get stuck way before I could even hope to check error logs :slightly_frowning_face:. Truth is that I honestly dont know where to begin with making config files. Is the intended audience programmers, or could someone with some computer skills also pull this off? That is why I mentioned not being able to find helpful ( for me that is) information or documentation. And I am now at a crossroads, so: learning curve too steep? Or dig in and continue?

Hi,

The answer is: Yes, you absolutely can pull this off with some computer skills. When I got to know openhab, I had no clue of programming anything whatsoever and Linux was a mistery.

The subsequent answer is: Yes, you need to do a lot of digging and reading. The link which @lipp_markus posted above is a good start. Youtube videos exist and sites like https://www.npmjs.com/package/generator-openhab did a lot to hep me at the start.
Have a look here as well: openHAB generator - design your smart home in no time!
For me, openHabian was and still is the optimal solution, as it’s simple to use and the openhabian-config tool is a marvel to setup add-ons and apply tweaks to the system.

The forum here is an excellent source of knowledge to help you out to accomplish your to-do-list above.
And yes: There are points in time where frustration is high, but at the end you’ll overcome those :slight_smile:

Kurt

1 Like

Thanks for your kind words of advice :wink:. I’ll give it another shot then

Maybe a short hint may push you in the right direction, as I struggled just as you did with unclear documentation.
Basically the docs are clear but some mandatory information for beginners is missing (my opinion).
First of all: when you set up something with bindings or graphically the corresponding items and things will be in the Openhab database but will have no configuration files in the file system such as you have when adding something manually.
Second, if you define an Item in an .items file it will be available to the system but show up nowhere. But you could already set up rules to control the item(s).
Third, anything you want to see (eg a Switch so that you can control it with the openhab app from your mobile) needs to be put in a .sitemap file.
You may put all necessary information about an item in the line where you defined it in the .items file such as (in .items file):

Switch livingroom_lamp1 "Lamp besides Couch" <light> (gLights, gPresence) [“Lighting“] {mqtt=">[broker: home/commands/MQTTto433:command:ON:131523], >[broker: home/commands/MQTTto433:command:OFF:131526]“, autoupdate="true"}

Just to give a full example.
In the .sitemap you would then only have to put:

sitemap Livingroom label=“Chief office control” icon=“sofa”
{
Frame label=“My chief lights”
{
Switch item=livingroom_light1
}
}

In the openhab app it would then show up with the name „Lamp besides couch“ as specified in .items file and with the lamp icon because you specified in .items

If you put additional definitions in .sitemap file this will override your settings in .items, such as:

sitemap Livingroom label=“Chief office control” icon=“sofa”
{
Frame label=“My chief lights”
{
Switch item=livingroom_light1 label=“Cool lamp besides master couch” icon=“switch”
}
}

Which would result in a switch icon with the name „cool lamp besides master couch“ that would of course still switch your livingroom_light1.

So in short you need -in most cases- both, an .items file and also at least one .sitemap (note the „S“ - remember that it’s not .sitemaps but .sitemap but on the other hand it’s .items for the filenames!)

Let’s think of another case where you need NO entry in a .sitemap file:
For example you have defined an outdoor lamp “outdoor_lamp1” {channel=“zwave:device:e8713b47:node12:switch_binary” }
in .items file but do not need manual control. Then this is just enough and you could still set up a .rules file like this:

rule "outdoor_rule“
when
Item livingroom_light1 changed from OFF to ON
then
outdoor_lamp1.sendcommand(ON)
Thread::sleep(22000)
outdoor_lamp1.sendcommand(OFF)
end

this would switch on the outdoor lamp when you switch on your living room lamp and switch it off 22 seconds later.

You need to use code fences when posting rules it makes it easier for people too read

It would be really awesome if you took a look at the beginner’s tutorial and submitted any additions or changes you think would help. The tutorial is incomplete.

Keep in mind that logs are not just for errors, they also give information about what OH2 does (loading items files, installing bindings, etc). Equally helpful can be the events.log file that keeps track of all events that OH2 “sees”.
In your case, you could watch whether the items file gets loaded (if not, you have an issue with file name or permissions), if it parsed correctly (the absence of any entry would tell you that), etc

If you expect trouble with your samba connection or similar, you may want to directly work on your RPi, just go to the right location (see docs) and create a file with a file editor (e.g., nano); if you only create an empty file, OH2 will attempt to read it and tell you that it is empty, if you put something in it, OH2 will parse it. This may help locate any problems, on the long run using visual studio code with its built-in syntax checker will help a lot.

Somehow I missed to use code fences yesterday, absolutely right. Sorry for that :wink:

Thanks for posting this item. I’m a software architect with 45+ years of experience and I too am stuck. There really is too much old stuff(video/docs/posts/etc…) available that causes confusion when trying to determine what’s required vs a best practice. I got a lot from following this thread.

1 Like

Been out of town a couple of days, but thanks a lot to all who have contributed and replied to my ‘cry for help’ :wink: . This encourages me to get stuck in, will start by using the tips and links provided! (keep you posted of my progress)

Get stuck in. It won’t work the first time (It never does :wink:)
Look at the docs, again and again
Keep an eye on the logs, they will give you a clue about your errors
Look at the docs, again
Search the forum, don’t ask for help if someone had the same problem before (Best bet is that someone had). The solution to your problem will likely be in the forum already.
Look at the docs, again…
Then post your code with a problem and we’ll do our best to help…

Enjoy, break things and learn
Good luck
Welcome to OH

Ok, I’ve had another go, and got some positive results too :slight_smile: . What went well:

  • was successful in creating first filebased items + sitemap switch entries in custom sitemap. yay! and visible through basicui too. Breakthrough!
  • successful in grouping items :slight_smile: took me 2 hours trying different entries, testing, and retrying. In the end I made numerous mistakes, most important is I did not define the actual group that I assigned the lights into! Stupid in hindsight, but ok
  • Succesful in defining Tradfri light brightness and color temperature through items file and sitemap
  • Success in adding chromecast as a thing through item files;
  • Succeeded in creating a rule/scene to dim lights, and detect switching of a dummy switch. First file based rule!

Took many hours, and a lot of wtf’s, but am happy with this result. Getting a better feel for the system as well. I want to thank all contributants to this thread, for taking the time to help me and make suggestions for further reading.

Ofcourse, for every solution and answer there are also new questions:

  • paperui is not picking up any implemented stuff, be it sitemaps, items, etc. Is this intentional? what am i doing wrong. Is the ?sitemap=XXX URLkey supported? Edit: After defining stuff in my custom sitemap (and by files) I see some stuff appearing twice/double. Can this be managed, or should i just remove the file-defined items in paperui? (Not a big problem as other UI do work)
  • Groups need to be defined before they can be used. Can they be the same as sitemap groups? Or is that the whole idea?
  • Paperui rules remain ‘uninitialized’ after reboot (done a couple of times while tinkering with settings/files etc). Note to self: open, then save them manually in paperui to fix this
  • Log files were helpful in finding out what was going wrong. Snag: spent quite a bit of time with system not logging after manual emptying the log. It got so big that is was cumbersome to open and look through
  • new issue: when I switch the two lights together the individual switches do not update in basicui? I would expect them to sort of 'slave’switch to the corresponding on/off position? Edit: works as expected in classicui, not in basicui
  • Edit: interface in iphone App is quirky, in the sense that flipped switches tend to switch back. And you would have to flip them again, and even then they will switch back to off. In general they dont reflect the actual status of lights (on/off position)
  • I cannot detect actual state of chromecast anywhere. not in interface nor logs. Need this to build my rule for: ‘PLAY video --> dim lights’ This for me is a big hurdle, should I proceed along an API/MQTT type solution? Or should the openhab2 binding support this
  • Presence detection. I found numerous sources and content in this forum about detecting phones, but there seems to be more to it than meets the eye. Is there an accepted and documented method for this, so I can use this in rules?
  • Error when updating my raspberry pi, I get a public key ‘launchpad ppa’ error

Safe to say that I can spend quite some more time into this new hobby of mine.

First of all, well done. Glad you stuck it through. As you said you are learning the system.

The paperUI will pick the things and items generated in the paperUI. Any items manually created will not appear in the paperUI. (You can still link them to channels)

Group are a bit like any other items. Yes they need to be created before they can be used. If you define an item as part of agroup that doesn’t exist, it will be ignored. So if you want an item to belong to a group, Yes the group needs to exist. What do you mean by sitemap group? If you put a group in a sitemap, clicking on it will display the items in that group in no particular order.

You can use a tail command to see what is happening in the log in real time. It will only display the latest. tail has many options. Google it.
tail /var/log/openhab2/openhab.log

That’s a know issue hopefully being resolved

Get a real phone :laughing:

Click on the show more bit of the chromecast thing
There are more channels available

Basically NO, but there are some very good template, like:

Don’t know, sorry

1 Like

:+1: fair point :slight_smile:

About groups versus sitemap groups: I meant that in sitemaps you can define groups for visual display in clusters. For example GF_livingroom, or FF_bathroom. I created separate groups in items files to switch lights in pairs, thinking that the two might be separate in usage. Now i’m thinking maybe these are in fact 1 and the same? So groups defined in items files can be identical as the groupings you use in sitemaps/clusters?

They are one and the same. If you define a lights group as a switch:

Group:Switch gLights

And put that in the sitemap as a

Switch item=gLights

Then it will appear as a switch and action the two lights together
If you put it in the sitemap as follow:

Group item=gLights

Then it will appear as a link to the two lights inside a “sub-window”

It depends on where you are looking. If you have Simple Mode turned off then there will be an Items menu under Configuration. And that Items menu will list ALL the Items, including those that are defined in .items files. What you can’t do is make any changes to those Items in PaperUI though. I think you will get a 404 or a 500 error.

What controls what appears under Control in PaperUI is what Items are linked to a Thing’s Channel. This is true even for links created through the .items files. Put another way, only the Channels that are lined to an Item appear in the Control tab in PaperUI.

If you are using openHABian, there will also be a frontail entry on the dashboard which will let you view and follow the logs in your browser. A lot of people prefer that to ssh and tail -f. frontail can be installed separately if you are not using openHABian.

Look in events.log and verify that the switches are not actually flipping back. There are some devices that behave like this for some reason. The problem may be the device or the binding and not the iOS UI. But I will say that the project has had some problems getting people to contribute to the iOS app so it is not keeping up with or getting as many new features as the Android app.

Presence detection is hard and particularly hard with iOS devices. You will probably have the best luck using the iCloud binding. Search that and you will see several threads on how to use it for presence detection.