So as I sad, all the Things, Items, Graphs are working, but the actual number (e.g. temperature) is not displayed.
If I execute the script by hand it will return the result (e.g. 22.17)
Sadly the log file has no recent entrys, and I was not able to figure out why it stopped filling it.
I hope I included all the information needed, otherwise please ask.
You only show the thing. However Things are not displayed in the sitemap. You have to link your things to items. However I assume you did that since you are saying that
For your items: Try a label transormation.As a example see my definition for a temperature item:
Number RPi2Helper_Temperatur "CPU Temperatur [%.1f °C]"
Another idea is to get the measurements via a cronjob on the maschine you are executing the command on (192.168.178.33). See this example:
script:
#!/bin/bash
OHIP="192.168.178.108"
send(){
curl -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "$state" "http://$OHIP:8080/rest/items/$item/state"
}
item="RPi2Helper_Temperatur"
state=$(vcgencmd measure_temp | sed 's/temp=//' | sed "s/'C//" )
send
cronjob which runs the script once per minute and sends the temp to the OH server:
I recommend this method since you are not getting any errors if the OH server can’t connect to 192.168.178.33. Furthermore you dont have to deal with SSH Keys. (I assume you have SSH Keys, right? Otherwise your implemented solution can’t work)
There is a space missing in the first thing between the IP and the command.
Are you sure that the ssh command is executed as it is being started as user openhab and needs to have the openhab public key iimported into authorized_keys of user pi while I assume that your manual test was executed as user pi.
Besides that the command is in the whitelist ?
Any error message in the openhab.log file ?
Thats why I assume, that everything else is working (since I got all of it from a tutorial).
Is the time running the script not defined by the interval=60 command in the Thing?
So this is the item configuration
Group Weatherstation_Chart (System, Charts)
Number Weatherstation_Chart_Period "Periode" (System)
Number Weatherstation_Temperature "Temperatur [%.1f °C]" <temperature> (Weatherstation_Chart)
Number Weatherstation_Humidity "Luftfeuchtigkeit [%.1f %%]" <humidity> (Weatherstation_Chart)
Number Weatherstation_Pressure "Luftdruck [%.1f hPa]" <pressure> (Weatherstation_Chart)
String temperature_out { channel="exec:command:weatherstation_temperature:output" }
String humidity_out { channel="exec:command:weatherstation_humidity:output" }
String pressure_out { channel="exec:command:weatherstation_pressure:output" }
This the rule
rule "Weatherstation Temperature"
when
Item temperature_out received update
then
Weatherstation_Temperature.postUpdate(
( ( Float::parseFloat(temperature_out.state.toString) as Number ) * 10 ) / 10
)
end
rule "Weatherstation Humidity"
when
Item humidity_out received update
then
Weatherstation_Humidity.postUpdate(
( ( Float::parseFloat(humidity_out.state.toString) as Number ) * 10 ) / 10
)
end
rule "Weatherstation Pressure"
when
Item pressure_out received update
then
Weatherstation_Pressure.postUpdate(
( ( Float::parseFloat(pressure_out.state.toString) as Number ) * 10 ) / 10
)
end
As I said before, the log has no entries since yesterday… could I have turned it off accidentally?
Where can I check the whitlist of the command?
[edit]
the space was a copy error, sorry
yes the ssh keys are working
files are owned by openhab user and ar executable
[\edit]
The whitelist is the file /etc/openhab2/misc/exec.whitelist
In case there is no entry for your command in the whitelist and no entry in the log file then it looks like the command is not executed.
Ok, so I found the log file which is updated regularly.
It seems that on the synology install, the whole folder structure is quite different…
2020-11-17 22:52:26.448 [WARN ] [ng.exec.internal.handler.ExecHandler] - Tried to execute '/volume1/SmartHome/openHAB/conf/scripts/weather.sh', but it is not contained in whitelist.
2020-11-17 22:52:26.449 [WARN ] [ng.exec.internal.handler.ExecHandler] - Tried to execute '', but it is not contained in whitelist.
2020-11-17 22:52:26.488 [WARN ] [ng.exec.internal.handler.ExecHandler] - Tried to execute 'ssh pi@192.168.178.33 ./weatherSensor temp', but it is not contained in whitelist.
You also may try to add the path to the executable ( ssh ) in the exec command line as well as in the bash script. This would help in case the exec environment does not have a search path included.
so it is. for security reasons there is no default content / file available.
The documentation of the binding at the top in the binding-configuration section
states:
For security reasons all commands need to be whitelisted. Allowed commands need to be added to the misc/exec.whitelist file in the configuration directory. Every command needs to be on a separate line.
Example:
/bin/echo “Hello world!”
/usr/local/bin/apcaccess status
php ./configurations/scripts/script.php %2$s
Linux: Note that the commands are executed in the context and with the privileges of the process running the Java Virtual Machine. On a Linux system the system user openhab needs to have the privileges needed to execute your intended command. It is advised to test the correct operation of the command in the scope of the openhab user on the command line first:
sudo -u openhab
It is not advised to run the virtual machine as superuser/root.
Hm ok, so I thought it didn’t work with the examples which were provided in the doc…
The log file always tells me
Tried to execute '/bin/echo '42.2'', but it is not contained in whitelist.
So could it be that on the Syonology install the directories are different?
Is there a way to find out where it looks for the whiteliste file?
I know placed the misc folder in the conf folder which seems to make sense, but all the commands I tried it told me that it was not present in the whiteliste…
I would expect that this fine.
How did you create, edit the file ? Did you create/edit it with a windows editor or in a linux environment ? Could be that it is a problem of line feeds/carriage return which are different / depending on the OS.
I created it, logged in as the user which will execute it (openhab). Directly with vim on the linux system (synology NAS). So I think that should be fine…