Confused about new syntax and documentation not working

  • Platform information:
    • Hardware: Odroid C1
    • OS: Ubuntu 14
    • Java Runtime Environment: Zulu
    • openHAB version: 2
  • Issue of the topic: Confused about new syntax and documentation not working

Hello everyone.

I was an user of openhab2 a year ago or so. I don’t remember which version, but it worked very well until my SD-card got corrupted (about 4 months ago).
Now I just re-installed my system and Openhab2 with the latest version on the package repositories, and I’m very confused about many things.

Let me make some sections about it:

Z-Wave and items:

I was surprised how fast Z-Wave devices were detected. For my surprise, I was able to open a Thing and see all the available channels, that should be new! If I click on any channel it gets linked. I think this means that a new item is created automatically. I was used to create the items manually, and this new feature raises questions on my head:

  • Can I use those items directly ?
  • Should I create my own items ?
  • Can I backup the automatically created items ?
  • Does this apply for all the item types (mqtt, network, etc) or just for those linked to physical things (switches, light bulbs)

To be honest, I think I prefer to create my own items to give them better names, is it a good practice ?

Items syntax:

Seems that items syntax has changed. I had my items created like this:

Number	Smart6_Volts	"Smart6 voltage [%.2f V]"	(ALL,power)		{ zwave="2:command=METER,meter_scale=E_V" }

But this does not work anymore. Looks like I have to use the channel keyword and assign an UUID channel name to it:

Number  Smart6_Amps "Consumo Corriente [%.2f A]"    (ALL,power)  { channel="zwave:device:15f8bb842d1:node2:meter_current" }

Is this official new way? I see lots of references with my old way.

Persistence:

I’m using the rr4j persistence. According to the documentation I can persist an entire group. However, in practice this is not working and on the console I’m getting a weird syntax error.
This is what I try:

Items {
    power* :strategy = everyChange, everyMinute, restoreOnStartup
}

Where power is a group. As I said, this does not work and I have to use a comma separated list of items. However the group syntax seems to work for Charts. There is maybe a bug on the documentation ?

Groups:

According to documentation I can define an icon for a group. In practice, this does not work at all:

Group power <energy>

Using the same icon for an item does work. Is this supposed to work ? What are the restrictions ? What if I define an icon both on a thing and a group ?

Sorry for asking so many questions on a single post, but It feel that opening one topic for each problem may be too much and it may lack the required context.

Yes.

Up to you. If you have a lot of rules this may be easier, because you don’t have to change the rules.
If you want your own item names, change the settings (“Simple Mode”) accordingly:
http://docs.openhab.org/tutorials/beginner/configuration.html

That is done for you automatically in the jsondb:
http://docs.openhab.org/administration/jsondb.html

Only for 2.x bindings.

Correct.

Hello @sihui

I read about the jsondb, but I never made the mental link between it and the automatically created items. Many thanks.

When did this changed ?

So, for the mqtt binding for example, I have to create my own items. Do they have also the old syntax or the new one using channel ?

Thank you for your responses, they were very clarifying.

A loooong time ago (don’t remember how long). I guess since the binding changed from version 1 to version 2.

All 1.x bindings are using the “old” syntax, because there is no “new” syntax. :grin:

I recommend to also read the migration tutorial:

http://docs.openhab.org/tutorials/migration.html

2 Likes

If you have Simple Mode enabled each Channel automatically gets an Item created for it. The Item name will match the Channel ID.

If you do not have Simple Mode you need to create Items yourself and you will see the following when you click on the + next to a channel:

image

Yes. you can use all Items directly, whether they are defined automatically, defined by you through PaperUI, or defined by you in .items files.

You will probably get to a point where Simple Mode will not provide the flexibility you desire. At that point you will want to create your own Items.

Yes, they are stored in /var/lib/openhab2/jsondb.

Items are only automatically created for Things. Bindings that are 1.x versions like MQTT cannot be used within PaperUI and you must create those Items in .items files.

That is probably what the majority of users do.

Please review the Migration Tutorial. The syntax didn’t change so much as a whole new Zwave binding was created for OH 2.0. The differences are the difference between 1.x style bindings and 2.x style bindings. In 1.x verison bindings you need to configure the binding on each Item. For 2.x verison bindings you just need to link to a Channel on a Thing and the specific configuration is defined at the Thing which, in most cases now, are automatically created for you.

Like I said, it is the difference between 1.x and 2.x version bindings. The main purpose of the introduction of Things was to replace the binding config at the Item so that most of that could be automatically discovered and created for you. There are still a bunch of 1.x verison bindings around so you will see a mix for the foreseeable future.

You don’t post the actual error. If that is your full rrd4j.persist file then it is incomplete. You are missing the strategies section. Here is my complete influxdb.persist file using Groups.

Strategies {
  default = everyChange
}
Items {
        gChart*,gIndoorTemps,gIndoorHumidity,vIsCloudy : strategy = everyUpdate
        gHistory: strategy = everyUpdate
}

In order for the Group to have a State you need to give the Group a type. For example:

Group:Number power <energy>

For something like power it is better to also give it a function to calculate that state.

Group:Number:SUM power <energy>

It doesn’t make sense to define an icon on a Thing.

Yes. Channels are the 2.x way of linking a Thing to an Item. In 1.x there is no Things or Channels so one has to define all the binding config at the Item.

Yes, I have it activated. I first I had it deactivated, then I activated it, then I deactivated it again, and finally I left it activated. At first it was not clear what was it for. Now I know thanks to the answers on this thread.

I did that a couple of times. But to be honest, it’s a bit overwhelming at first. You have to create a new item, with a big set of options that you have no idea about. That’s why I turned simple mode on again.

I think my confusion was motivated because I didn’t understand that the created items were, well, items. I though they were the channel. As I said, OH2 can be a bit confusing at first.

This is the second time someone recommends me this. Now I understand why, but at first I though that I didn’t explained myself well since I am using openhab2 and I am not migrating any old configuration, because before I was also using openhab2. Now that I know that some bindings are 1.X and some others are 2.X and that I got trapped in the middle it makes sense.

Yes, my bad, I didn’t wanted to make the post too long. My configuration is indeed complete, here it is:

Strategies {
    everyHour : "0 0 * * * ?"
    everyDay  : "0 0 0 * * ?"
    everyMinute : "0 * * * * ?"

    default= everyChange
}

Items {
    Oficina_currentPower,Smart6_Power :strategy = everyChange, everyMinute, restoreOnStartup
}

And this is the error I’m getting right now:

2017-11-10 09:36:03.593 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'rrd4j.persist' has errors, therefore ignoring it: [1,1]: mismatched input '<EOF>' expecting 'Strategies'

2017-11-10 09:36:03.634 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'rrd4j.persist'

If I change the items section to a group like this power* : strategy = everyChange, everyMinute, restoreOnStartup

I get the same error. However, seems that it is working. Strange right ? At least for me.

Sorry, I may fail explaining what I’m actually trying to do. I want to store the value for all the items belonging to that group, not the group itself neither a sum of all the items on the group. I though this was possible. Am I wrong ?

Many thanks to all the members that are helping me so fast and so well. You have helped me a lot already.

If you are editing the file over samba or using certain editors this is a well known warning. When you save the file there are two events, one when the file is starting to be saved and one when it is done. OH can’t tell the difference and tries to load the file on both events. Obviously, on the first event the file is empty or partially written so OH sees the file as invalid. On the second event the file is complete and it loads successfully.

To store the states of all the members of a group you use MyGroup* . To store the state of the group you use MyGroup.

However, you are talking about trying to sign an icon to a group for display on your sitemap. The only way for that to work is in your group has a State and the only way to make your group have a State is to give it a type.

Oh ! That is key ! Yes, I’m using samba for editing the files from my desktop . It may be a well known issue here on the community, but I didn’t and it was driving me crazy on several config files. Thanks for pointing it out. Is it documented at any place ?

Yes, that is one of my questions too. Please correct me if I misread the documentation, but I don’t want to directly display the group. I want to assign an icon to the group to say “hey, all items on this group should use this icons unless they specify another one”. Maybe this is not possible and the icon on the group is only if you want to display the group itself.

Thanks again

I don’t think so because they’re is an open issue to fix it I think.

This is not supported. You have to define the icon on each item individually. As you guess, the icon on the Group is to display the Group.

1 Like