A accidentally changed the channel information in a .items file but didn’t realize it at the time. Spent hours trying to determine why a certain light was not turning on. The log showed the command to the item turning on and then showed the item to be off. If we are sending a command to a channel that doesn’t exist - would it be reasonable to generate an error?
It’s currently up to the binding developer to decide whether or not to generate a log message in the Thing handler’s handleCommand
method. Some bindings generate a DEBUG level log for unknown channels; some log at INFO level or greater; others don’t log at all.
Looking at the bindings I’ve written over the past couple years, I see that I’ve successfully covered all the above bases. In one case I log at WARN level, in another case I log at DEBUG level, and in some other cases I don’t log anything at all.
So, to answer your question, yes I think it might make sense to generate a log message. Unfortunately, I don’t think there’s a central place where this can be done.
Hi Mark, so what does OH do if the binding itself does not exist?
It would be nice if this was standardized - ie the binding template included some default behavior that was consistent…
If you mean, what if you have an item that’s linked to a channel for a nonexistent binding. Like this:
Switch TestSwitch "Test Switch [%s]" { channel="some:bogus:thing:sensor_binary" }
If you send a command to it you get… Crickets.
Yes it would.
WARN log is normally rejected by reviewers in such a case. Take a look to the coding rules, it explains when each log level should be used.
Yes, that was the exact problem… I had a working rule and all of a sudden a light wasn’t responding. Spend hours trying to figure out if the Insteon network was screwed up or if the device wasn’t working etc etc etc. and I noticed an extra character in the binding name…
Seems to me that “it’d be nice” if
- openHAB reported (INFO?) if you define Item with channel=“rhubarb.blah”, and no rhubarb binding is loaded.
- individual bindings reported if they get passed garbage parameters.
Whether that is something to happen as Items are initialized or when the binding call is invoked though?