Problems with exec in oh2

exec
openhab2
Tags: #<Tag:0x00007f1e5c934a78> #<Tag:0x00007f1e5c934938>
(Markus Schneider) #1

Hello,

I’m having problems with my exec binding after moving from oh1 to oh2.
I have installed the exec legacy binding and the regex transformation.

in my items there stands:
Number TEMP_WOHNZIMMER “Temperatur Mein Zimmer [%.1f °C]” (Temperatur) { exec="<[sudo /etc/openhab/scripts/dht22.sh TEMP:60000:REGEX((.*?))]" }

Number LUFT_WOHNZIMMER “Luftfeuchtigkeit Mein Zimmer [%.1f %%]” (Temperatur) { exec="<[sudo /etc/openhab/scripts/dht22.sh HUM:60000:REGEX((.*?))]" }

But i can’t see any data inside my sitemap
And no logging in the openhab.log
Can anybody help me with this problem?

The exec-binding is working very well for my 433mhz sockets.

Thanks for the help
Markus

0 Likes

Exec Binding 2.1: String Calculations
(Markus Schneider) #2

One possible Solution would be using the exec 2.0 binding.
But then I have to manually create things.
Is this possible?

0 Likes

(Rich Koshak) #3

Absolutely. You just need to create a filename.things file in the things folder and use the syntax defined in the readme. But it won’t really work any differently and you will still have to follow the approach outlined above.

0 Likes

(Markus Schneider) #4

In the actual beta there are only 2 exec1.9 binding
How can I get the actual exec2 binding?

0 Likes

(Stefan) #5

The exec2 binding was introduced after the beta4 was released. From my understanding, you have to switch your whole installation from Beta to Snapshot to get the exec2 binding.

But you can easily continue using the exec1 binding in OH2 (so do I!).

0 Likes

(Markus Schneider) #6

I try to do this but my code above is not working and I don’t get any errors or other things
With oh1 it’s working without problems

0 Likes

(Stefan) #7

Have you carefully read Rich’s tutorial?

I see a sudo command in your exec and also a space after the script names. Both may lead into trouble.

And you should set the log level to DEBUG. Maybe this will get you some more information. And do you have a look only at the openhab.log? Or also at the events.log?

0 Likes

(Markus Schneider) #8

Oh my good.
I made such a bad copy and past error
my script is in /etc/openhab2/scripts/dht22.sh

Thanks for your help
I might reply if I have issuses with exec2 if it comes with a new beta or the final release.

0 Likes

(Markus Schneider) #9

I’ve tried exec2 now.
I’m running into some problems:

default.things:

Thing exec:command:TEMP [command="/etc/openhab2/scripts/dht22.sh TEMP", intervavl=60, timeout=10, autorun=false]
Thing exec:command:HUM [command="/etc/openhab2/scripts/dht22.sh HUM", interval=60, timeout=10, autorun=false]

default.items:


Number TEMP_WOHNZIMMER "Temperatur Mein Zimmer [%.1f °C]" <temperature> (Temperatur) {channel="exec:command:TEMP:output"}
Number LUFT_WOHNZIMMER "Luftfeuchtigkeit Mein Zimmer [%.1f %%]" <humidity> (Temperatur) {channel="exec:command:HUM:output"}

openhab.log:

2016-12-26 14:42:50.274 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate update '18.00' for item 'TEMP_WOHNZIMMER' to handler for channel 'exec:command:TEMP_WOHNZIMMER:output', because no thing with the UID 'exec:command:TEMP_WOHNZIMMER' could be found.
2016-12-26 14:42:51.289 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate update '' for item 'LUFT_WOHNZIMMER' to handler for channel 'exec:command:LUFT_WOHNZIMMER:output', because no thing with the UID 'exec:command:LUFT_WOHNZIMMER' could be found.
2016-12-26 14:42:53.856 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate update '18.00' for item 'TEMP_WOHNZIMMER' to handler for channel 'exec:command:TEMP_WOHNZIMMER:output', because no thing with the UID 'exec:command:TEMP_WOHNZIMMER' could be found.
2016-12-26 14:43:54.404 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate update '' for item 'TEMP_WOHNZIMMER' to handler for channel 'exec:command:TEMP_WOHNZIMMER:output', because no thing with the UID 'exec:command:TEMP_WOHNZIMMER' could be found.
2016-12-26 14:43:54.529 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate update '53.50' for item 'LUFT_WOHNZIMMER' to handler for channel 'exec:command:LUFT_WOHNZIMMER:output', because no thing with the UID 'exec:command:LUFT_WOHNZIMMER' could be found.
2016-12-26 14:44:55.390 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate update '' for item 'LUFT_WOHNZIMMER' to handler for channel 'exec:command:LUFT_WOHNZIMMER:output', because no thing with the UID 'exec:command:LUFT_WOHNZIMMER' could be found.
2016-12-26 14:44:56.754 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate update '18.00' for item 'TEMP_WOHNZIMMER' to handler for channel 'exec:command:TEMP_WOHNZIMMER:output', because no thing with the UID 'exec:command:TEMP_WOHNZIMMER' could be found.
2016-12-26 14:45:57.315 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate update '' for item 'TEMP_WOHNZIMMER' to handler for channel 'exec:command:TEMP_WOHNZIMMER:output', because no thing with the UID 'exec:command:TEMP_WOHNZIMMER' could be found.
2016-12-26 14:45:59.633 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate update '53.40' for item 'LUFT_WOHNZIMMER' to handler for channel 'exec:command:LUFT_WOHNZIMMER:output', because no thing with the UID 'exec:command:LUFT_WOHNZIMMER' could be found.

Any Ideas?
My Number is not updating.
The error message is right. But I don’t use the thing exec:command:LUFT_WOHNZIMMER.

0 Likes

(davorf) #10

Hello!

I think you should firstly run the command, and then use result from output. I guess there is no result, because exec command wasn’t called at all.

Best regards,
Davor

0 Likes

(Markus Schneider) #11

But how to do that?
The values I see in the openhab.log don’t go into the value to be displayed

0 Likes

(davorf) #12

Hello!

Try using a switch item witch contains {channel=“exec:command:TEMP:run”}. It should run exec command when the switch is turned on. I haven’t used exec2 binding, but this is my understanding of exec2 readme.

Best regards,
Davor

0 Likes

(Markus Schneider) #13

But it seams, that the script is executed every 60s how I would expect it.
In Habmin it gets updated.
In my sitemap I don’t see anything

0 Likes

(davorf) #14

Well, a readme is not very concise. You say you can see a value in HABMin? What do you get if you try to access an item via Rest interface? Do you get a valid result? Maybe it’s a sitemap problem?

Best regards,
Davor

0 Likes

(Markus Schneider) #15

Ok, it’s now a little bit more clear.
The Items have state null in the rest api
But I can see some old items which I deleted before.
The error messages come from those old links I created before and deleted them.

So I have found a bug, old links and items are not been deleted.

The things in habmin get the value.
In the habmin sitemap there I can see only NULL. After a short time there are the right values.
In the paper UI control the value is also displayed

0 Likes

(davorf) #16

Hello!

I’m not 100% sure about this, but it could be an item type mismatch. Since script returns result as text, you should try using String item instead of Number. It’s String item they use in the exec readme example too.

Best regards,
Davor

0 Likes

(Markus Schneider) #17

I hope it’s not.
I need number for the persistence and my chart.

I changed the ItemStateEvent to debug and now in the events. log I can see every minute:
TEMP_WOHNZIMMER updated to…
LUFT_WOHNZIMMER updated to…

In my sitemap still nothing.

I will give string a try

0 Likes

(Markus Schneider) #18

So, string is working.

That’s very bad.
I ask for a number.
I get a number.
I must say it’s a string…

0 Likes

(davorf) #19

Well, it’s not a number, since script can return any type of data. You could use rules to convert it to number and a proxy Number item.

Best regards,
Davor

0 Likes

(Markus Schneider) #20

How to do that in .sh scripts?

In php i would say floatval…

0 Likes