Channels usage examples

Hello,
first off i really like openhab but i am having a hard time getting channels to work how i want them to. Basically i am looking for examples of following scenarios:

Multiple channel configurations for new things. According to my understanding a Thing can have multiple channels, I would like to monitor my computers and need the following channels:

  • wake on lan binding to wake up
  • a rule with network health which updates the wake on lan switch
  • a channel for SNMP for aquiring HDD smart status and disk space to color the text of the host in case of some error

So that would be 3 channels, i am really wondering how to define this manually in text files. Is there a comprehensive description/tutorial/example how to use channels in rules and how to design custom things?

After browsing the web for the second evening about channels (did that for the astro plugin yesterday) i find openhab 2 very cumbersome to configure. I really wanted to use the openhab 2 features to design my smarthome the right way. But in this state i am close to just scripting away in python, using cron and pumping every data into my MQTT. Basically using openhab only for the web ui and app without logic, without rules and with only with the Exec and MQTT binding. But that’s the last resort.

Maybe i am also on a totally wrong track and misunderstood some documents. Any help is apreciated.

Regards

Your understanding is not correct, or at least incomplete. Indeed a Thing can have multiple channels, but those channels are defined by the individual binding the Thing is configured for. You cannot create a Thing that has channels from multiple Bindings. So, for example, an Exec Binding Thing will always and only have input, output, exit, run, and lastexecution channels. You cannot bring in the online channel from the Network binding and include it in this Thing. Instead, you would have a separate Network binding Thing.

Channels and Things are only valid for 2.x version bindings. Not all bindings support them. In this case:

None of these are 2.x version bindings so none of them involve Things or Channels. The way to use these bindings with Items (more on that below) is documented in the links I provided above.

No, because that isn’t how it works. Each binding defines the format and contents for how to define its Things. There are some opportunities for slight customization (e.g. setting an offset in an Astro binging Thing) but for the most part, Things are either automatically discovered or the format to define them yourself in .things files is documented in that Binding’s README (e.g. here is Network Binding’s README.

I think this is the case. What you really are after is Items. The Sitemap, Rules, Persistence, and everything else in OH operates on Items. Items are configured to work with zero or more 1.x bindings and or are linked to zero or more Thing’s Channels.

The most common case though is one-to-one (i.e. one Item linked to one Channel). Ans based on what I can guess from what little you said you are trying to accomplish you want a one-to-one here as well.

  • A Switch Item bound to Wake on Lan for sending the WOL command
  • A Switch Item bound to Network Health, or even better the online channel of a Thing defined for the Network binding to tell when the computer is online/offline
  • A String or Number Item bound to the SNMP binding to tell you the HDD smart status
  • A Number Item bound to the SNMP binding to get the disk space

You would have a rule that triggers when Network Health changes to sendCommand(ON) (or OFF) to your Wake on LAN Switch.

Finally, I’ll make one more comment. If you are after an IT health and status system (which your posting implies) you will be far more happy with a product like Nagios than with openHAB. openHAB is designed for controlling home automation and does not stand up well against products specifically designed to do the sorts of things you are describing.

1 Like

Thank you so much for your explanation. It helped a lot. I was using openhab 1 before and just recently mighrated to openhab 2. My thought was that a thing would be the overarching concept to define behaviours of a real thing… with customizable channels. But apparently i misunderstood that, thanks for clarification. I will try to configure your suggested items.Thank you so much for pointing me into the right direction.

Regarding the approach of using openhab for network status, i just wanted to have a small overview about diskspace for backups and movies in my home. It won’t be a full blown monitoring solution like cacti or nagios. I tried both of them but i recognized it was overkill when i only need 2-3 stats for 6 hosts.

I clearly want openhab to be the automation system. the network health is just a very small part of it and i wanted to configure it while my electronics parts are being shipped to my home :wink:

WakeOnLap might be a good idea as a further extension to the existing network binding. Unfortunately I have no idea how to accomplish this in a platform independent way in Java for Openhab. I recently added arp ping and a lastseen channel to the network binding if that is helpful.

Cheers, David