eclipse-archived / smarthome

Eclipse SmartHome™ project
https://www.eclipse.org/smarthome/
Eclipse Public License 2.0
862 stars 786 forks source link

No error when Thing is used without binding installed. #5122

Open Josar opened 6 years ago

Josar commented 6 years ago

When a thing is configured but the depending binding is not installed there is not error.

First my things file, all exec things are working. I add astro, airquality and Bridge avmfritz which are not installed. And there is no error ion the log. Also not when rebooting.

astro:sun:home  [ geolocation="52.5200066,13.4049540,100", interval=60 ]

airquality:aqi:home "AirQuality" @ "Krakow" [ apikey="XXXXXXXXXXXX", location="50.06465,19.94498", refresh=60 ]

Bridge avmfritz:fritzbox:1 @ "Office" [ ipAddress="192.168.x.x", password="xxx", user="xxx" ] {
    Thing FRITZ_DECT_200 xxxxxxxxxxxx "FRITZ!DECT 200 #1" @ "Living Room" [ ain="xxxxxxxxxxxx" ]
    Thing FRITZ_Powerline_546E yy_yy_yy_yy_yy_yy "FRITZ!Powerline 546E #2" @ "Office" [ ain="yy:yy:yy:yy:yy:yy" ]
    Thing Comet_DECT aaaaaabbbbbb "Comet DECT #3" @ "Office" [ ain="aaaaaabbbbbb" ]
}

Thing exec:command:cpuTemp [
        // Command to execute
        command="cat /sys/class/thermal/thermal_zone0/temp",
        // interval time in seconds
        interval=30,
        // should it run when input channel is changed
        autorun=false,
        // EXEC transformation to make 44007/1000 => 44.007
        // Using python to calculate
        //transform="EXEC(python3 -c \"print(%s/1000)\")"
        //
        // s/ substitute
        // (.{2})(.{2}) a a number with 5 characte, split in two groups
        // /$1.$2/g   first group then a dor then second group, used to divede by 1000
        transform="REGEX(s/(.{2})(.{3})/$1.$2/g)" ]

Thing exec:command:gpuTemp [
        // Command to execute
        command="/opt/vc/bin/vcgencmd measure_temp",
        // interval time in seconds
        interval=30,
        // should it run when input channel is changed
        autorun=false,
        // REGEX transformation to make "temp=44.0'C" => 44.0
        transform="REGEX(temp=(.*?)'C)" ]

Thing exec:command:ds18b20_1 [
        // Command to execute
        command="cat  /sys/bus/w1/devices/28-0516b0780eff/w1_slave",
        // interval time in seconds
        interval=60,
        // should it run when input channel is changed
        autorun=false,
        // s/ substitute
        // .+\\s.+t=      all char \\s escape a linebreack and all char and t=
        // (.{2})(.{3}) a a number with 5 characte, split in two groups
        // /$1.$2/g   first group then a dor then second group, used to divede by 1000
        transform="REGEX(s/.+\\s.+t=(.{2})(.{3})/$1.$2/g)" ]

Thing exec:command:backup [
        // Command to execute
        command="sudo /usr/share/openhab2/runtime/bin/backup /etc/openhab2/test/%1$tY-%1$tm-%1$td-%1$tH-%1$tM",
        // interval time in seconds
        interval=0,
        // should it run when input channel is changed
        autorun=false]
[WARN ] [del.core.internal.ModelRepositoryImpl] - Configuration model 'exec.things' is either empty or cannot be parsed correctly!
[INFO ] [del.core.internal.ModelRepositoryImpl] - Loading model 'exec.things'
[INFO ] [smarthome.event.ThingUpdatedEvent    ] - Thing 'exec:command:cpuTemp' has been updated.
[INFO ] [org.eclipse.xtext.build.Indexer      ] - Creating Deltas for changes. Deleted : [], Changed : [file:///etc/openhab2/things/exec.things].
[INFO ] [smarthome.event.ItemStateChangedEvent] - System_Temperature_CPU_out changed from 60.686 to 60.148
[INFO ] [clipse.smarthome.model.script.Convert] - Item System_Temperature_CPU state 60.148
[INFO ] [er$InternalStatefulIncrementalBuilder] - Starting validation for input: 'exec.things'
[INFO ] [smarthome.event.ItemStateChangedEvent] - System_Temperature_CPU changed from 60.686 to 60.148
[INFO ] [smarthome.event.ThingUpdatedEvent    ] - Thing 'exec:command:gpuTemp' has been updated.
[INFO ] [smarthome.event.ThingUpdatedEvent    ] - Thing 'exec:command:ds18b20_1' has been updated.
[INFO ] [smarthome.event.ThingUpdatedEvent    ] - Thing 'exec:command:backup' has been updated.
[INFO ] [del.core.internal.ModelRepositoryImpl] - Refreshing model 'exec.things'
[INFO ] [smarthome.event.ThingUpdatedEvent    ] - Thing 'exec:command:cpuTemp' has been updated.
[INFO ] [smarthome.event.ThingUpdatedEvent    ] - Thing 'exec:command:gpuTemp' has been updated.
[INFO ] [smarthome.event.ThingUpdatedEvent    ] - Thing 'exec:command:ds18b20_1' has been updated.
[INFO ] [smarthome.event.ThingUpdatedEvent    ] - Thing 'exec:command:backup' has been updated.
[INFO ] [smarthome.event.ItemStateChangedEvent] - System_Temperature_CPU_out changed from 60.148 to 60.686
[INFO ] [clipse.smarthome.model.script.Convert] - Item System_Temperature_CPU state 60.686
[INFO ] [smarthome.event.ItemStateChangedEvent] - System_Temperature_GPU_out changed from 60.7 to 60.1
[INFO ] [smarthome.event.ItemStateChangedEvent] - System_Temperature_CPU changed from 60.148 to 60.686
[INFO ] [smarthome.event.ItemStateChangedEvent] - System_Temperature_GPU changed from 60.7 to 60.1
[INFO ] [clipse.smarthome.model.script.Convert] - Item System_Temperature_GPU state 60.1
[INFO ] [org.eclipse.xtext.build.Indexer      ] - Creating Deltas for changes. Deleted : [], Changed : [file:///etc/openhab2/things/exec.things].
[INFO ] [er$InternalStatefulIncrementalBuilder] - Starting validation for input: 'exec.things'
[ERROR] [nhab.binding.exec.handler.ExecHandler] - An exception occurred while waiting for the process ('cat  /sys/bus/w1/devices/28-0516b0780eff/w1_slave') to finish : 'null'
[WARN ] [nhab.binding.exec.handler.ExecHandler] - Forcibly termininating the process ('cat  /sys/bus/w1/devices/28-0516b0780eff/w1_slave') after a timeout of 15000 ms
kaikreuzer commented 6 years ago

If a binding isn't installed, Things stay in UNINITIALIZED status, so this is a clear indication in the UI that these things are not active.

Once we have a solution for https://github.com/eclipse/smarthome/issues/1896 in place, we could add a warning log message for all things that are still uninitialized after the system has started to cover your request. We should not have a warning message on every single item event as it might be expected that a certain binding is (temporarily) not present.

Josar commented 6 years ago
  1. It does not reflect on the UI. As the Items are just not displayed in paperUI. Or which UI do you mean?
  2. I don't expect the user to look to paper UI.
  3. Is there a possibility to retrieve binding state?
    String ItemState "[%s]" {thing="astro:status"}
kaikreuzer commented 6 years ago
  1. Paper UI -> Configuration -> Things
  2. I don't expect a user to look at log files
  3. There is no binding state, only Thing statuses
Josar commented 6 years ago
  1. Yes but as I said there is no thing listed when the depending binding is not installed.
  2. User can't find this info either log nor paperUI. Only if he knows for what he has to search. Then he will go to the Bindings in PaperUI and see oh the binding is not installed.
  3. How to retrieve a thing status to an item? And how to determine from that if the binidng is available?

The Problem is that the Things which cannot be linked do not throw an error. The items linkt to channels of this thing just don't change. And the user sits in front gets no errors and expect it to work.

Or the Bindings gets miraculously uninstalled and i sit in front of y syste which worked flawlessly but then my grafana sharts stopped to show values.

No errors, the log entry which was issued when the binding got uninstalled is gone, burried in the log or deleted as i restarted. Because a restart is the first thing to do if something went bad.

And teh new log from the restart doesn't show any error. After hours then then starting to just follow all step neccessary to get things working i see in Karaf/paperUI oh my Bindings are gone where are they?

Question is how why can an item be initialized when the depending Binding is not available? And why is there no error?

triller-telekom commented 6 years ago
  1. Yes but as I said there is no thing listed when the depending binding is not installed.

image

That is a screenshot with an uninstalled astro binding. As you can see the thing is marked as UNINITIALIZED.

Question is how why can an item be initialized when the depending Binding is not available?

Items are a functional layer which is fully independent of the physical layer.

Josar commented 6 years ago

Sorry not for me in my openhab PaperUI. A could make a screenshot but i think you can believe me.

It is a seperate layer but should it not at least trigger a warning, Item x uses a binding which is uninitialized?

When I have the Binding installed and then uninstall it then the things are listed as offline. But if I Have a clean installation and try to link Things to a binding they don't appear. Maybe try it be clearing the cache.

Sound like: when starting, the things are not instantiated when the binidng is not available. But when the binding was available and dissapears they are listet as uninitialized.

Still one question open. Is there a possibility to retrieve binding state to an item?

Josar commented 6 years ago

@triller-telekom could you at least reproduce this 2 behaviours?

triller-telekom commented 6 years ago

@Josar Please see https://github.com/eclipse/smarthome/issues/5149#issuecomment-369559264