Link between Velserver & Openhab

Hello
I’m trying to implement the integration between velserver & openhab.
But I seem to have an issue with my sitemap.

What I did till now:

Checked if this file exists and is up to date
/home/velbus/velserver/etc/openHAB.cfg
Content:
GROUP_G_DIMMERS_ALL = %^Dimmer.+
GROUP_G_BLINDS_ALL = %^Blind.+
GROUP_G_TEMPERATURE_ALL = %^Temperature.+
GROUP_G_HEATER_ALL = %^Heater.+
GROUP_G_RELAY_ALL = %^Relay.+
GROUP_G_COUNTER_ALL = %^Counter.+ %^Divider.+
GROUP_G_COUNTERCURRENT_ALL = %^CounterCurrent.+
GROUP_G_BUTTON_ALL = %^Button.+
GROUP_G_ALL = %.

Checked if this file exists and is up to date
/etc/openhab2/items/velbus_group.items
Content:
Group G_DIMMERS_ALL
Group G_TEMPERATURE_ALL
Group G_HEATER_ALL
Group G_BUTTON_ALL
Group G_RELAY_ALL
Group G_BLINDS_ALL “Blinds”
Group G_COUNTER_ALL
Group G_COUNTERCURRENT_ALL
Group G_ALL

If I then take an example from my velbus.items then I see the next line
Switch Relay_20_01 “V Berging” (G_ALL,G_RELAY_ALL)

For testing purposes I created a sitemap with below content:
sitemap demo label=“My home automation” {
Frame label=“Date” {
Text item=Date
}
Frame label=“Demo” {
Switch item=Relay_20_02 icon=“light”
Text item=Woonkamer label=“Woonkamer [%.1f °C]”
Group item=Heating
}
}

But nothing happens when I flip the switch in the openhab website.
What am I doing wrong or what did I forget?
Thanks a lot

Can you check BASE_URL in openHAB.cfg?
That should point to your velserver URL. Depending on your setup (apache + cgi-bin or webserver.pl) this should be changed.
You can check the URL with the command wget. Just do execute wget and pas the BASE_URL setting.
It should connect and download something.

Stef

Hey Stef

This is the output of the wget command.

[07:26:41] openhabian@openHABianPi:~$ wget http://localhost:81/service
–2018-05-04 07:27:43-- http://localhost:81/service
Resolving localhost (localhost)… ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:81… failed: Connection refused.
Connecting to localhost (localhost)|127.0.0.1|:81… connected.
HTTP request sent, awaiting response… 200 OK
Length: unspecified
Saving to: ‘service’

service [ <=> ] 2 --.-KB/s in 0s

2018-05-04 07:27:44 (25.5 KB/s) - ‘service’ saved [2]

Can you confirm the setting WEBSERVERPORT = 81 in velserver.cfg?
If so, start the script bin/webserver.pl in a second window and try the wget again.

And you also need to run bin/logger.pl to monitor changes on the bus.

Stef

Hey Stef

Setting of webserverport=81 was correct.
So when I start the webserver.pl then I get this error : Web server not started on port 81: HTTP::Daemon: Address already in use.
But in the output of the wget you see that the second attempt is ok on port 81.
So not sure why I need to run this again?

These 3 services are running
screen -dmS velbusd /usr/local/bin/velbusd -f -s /dev/ttyUSB0 -b [::]:[8445]
screen -d -m -S logger /home/velbus/velserver/bin/logger.pl
screen -d -m -S velserver /home/velbus/velserver/bin/webserver.pl

Also I see all the data in the openhab file logger page.
There I see all the changes on my velbus in the events.log.

Sorry, my mistake. I saw a connection refused in your post but looking again, there is a second attempt to the ipv4 address that was OK.
So forget my previous post.

If you click on the sitemap, you should see an event in /var/log/openhab2/events.log.
This in turns triggers an HTTP GET. You can simulate this by opening the velbus.items file, go to the Relay line you are testing and copy the http:// statement.
You can do a wget of this http:// statement but you have to change the value=%2$s to value=ON or value=OFF
This in turns does a request to webserver.pl and this should be logged in the log/webserver.log.
Webserver.pl will send the relevant messages to the bus and this in turn will be logged in log/logger.pl by the bin/logger.pl script
And to be complete, bin/logger.pl will forward changes to openhab and this can be seen in log/openHAB.log and /var/log/openhab2/events.log.

So the flow is:
1: sitemap click -> /var/log/openhab2/events.log
2: http request to webserver.pl by OpenHAB: log/webserver.log
3: Messages on the bus by webserver.pl are seen by bin/logger.pl: log/logger.log
4: OpenHAB item updated by bin/logger.pl: log/openHAB.log and /var/log/openhab2/events.log

Stef

Hey Stef

Sorry for the late reply but I was in holiday.
So I just checked and it already stops at the first log.

When I change the switch in openhabian I only see something in the /var/log/openhab2/events.log where I see
2018-05-18 20:06:13.180 [ome.event.ItemCommandEvent] - Item ‘Relay_20_02’ received command ON
2018-05-18 20:06:13.203 [vent.ItemStateChangedEvent] - Relay_20_02 changed from OFF to ON

In the other logs webserver.log, logger.log & openHAB.log there is nothing that gets in there.

FYI: if I give this in my browser the lights go on/off http://openhabianpi:81/service?address=12&channel=04&type=Dimmer&action=Set&value=ON

Mhh, so openHAB logs something in the events.log.
Normally, it should call the corresponding http URL that can be found in the items file.
You did that manually so that’s also working.

Have you enabled the http binding?
You can do this by adding http to the binding variable in openhab2/services/addons.cfg
Or via Paper UI.

Stef

That’s then installing HTTP Binding : binding-http1 - 1.11.0 in paperui?
No that is not yet the case

I just installed it and wanted to check the change in the addons.cfg. But there is no change there. Do I also need to update the addons.cfg file?

ALLRIGHT

This works now.
Thanks a lot for your patience and help stef :metal:

Stef

I was to enthousiastic
Next issue is that when I now startup my velbus software and want to connect to my environment that velbusd crashes all the time. I’ve tried stopping the logger but that doesn’t help.

Any ideas?

These are the errors I see in the openhab log viewer web interface.

2018-05-19 13:11:48.305 [WARN ] [.core.transform.TransformationHelper] - Cannot get service reference for transformation service of type JSONPATH

2018-05-19 13:11:48.311 [WARN ] [ab.binding.http.internal.HttpBinding] - Couldn’t transform response because transformationService of type ‘JSONPATH’ is unavailable

Ok so it seemed I had to install JSONPath Transformation in paper ui => add-ons => transformations
Done and it seems stabilized.

:slight_smile:
Indeed, you also need jsonpath.

For installing bindings, you can user Paper UI or add it to the config file.
Both methods works.
I prefer the config file method.

Stef

Hey Stef

I have now another issue.
Velbusd crashes everytime I want to connect to my velbus.
This is what I see in the openhab log viewer on http://openhabianpi:9001/

2018-05-25 14:39:17.434 [ERROR] [ab.binding.http.internal.HttpBinding] - No response received from ‘http://localhost:81/service?address=40&channel=31&type=Switch&action=Get

2018-05-25 14:39:19.429 [ERROR] [org.openhab.io.net.http.HttpUtil ] - Fatal transport error: org.apache.commons.httpclient.NoHttpResponseException: The server localhost failed to respond

2018-05-25 14:39:19.432 [ERROR] [ab.binding.http.internal.HttpBinding] - No response received from ‘http://localhost:81/service?address=40&channel=21&type=Switch&action=Get

2018-05-25 14:39:21.478 [ERROR] [org.openhab.io.net.http.HttpUtil ] - Fatal transport error: org.apache.commons.httpclient.NoHttpResponseException: The server localhost failed to respond

What do you mean with velbusd?

And if http://localhost:81 is not reachable, that means webserver.pl is not running or that’s running on an other port.
The port can be changed in velserver.cfg with setting WEBSERVERPORT.

Stef

Dear Stef,

First of all a warm thanks for all your coding and documentation.
I am adding to this thread since I have some permission issues leading to the same problem: when I actuate a button on the sitemap, it does not get executed on Velbus.

I am running velserv on a Raspberry Pi 3B, and the webserver.pl (I couldn’t get the apache+cgi-bin up and running due to lack of skills :slight_smile: ).

Issue °1 (non-blocking):
<Solved, my rc.local syntax was not correct>

Issue °2 (blocking)

After starting the three components (Velsrv, logger, webserver), I am getting statuses of items displayed accurately.

Here’s the item definition for the switch I’m controlling:

Switch Relay_04_02 “Ceder” (G_ALL,G_RELAY_ALL,Verlichting_boven) {http="<[http://localhost/velserver/service.pl?Item=Relay_04_02&Action=Get:3600:JSONPATH($.Status)] >[*:GET:http://localhost/velserver/service.pl?Item=Relay_04_02&Action=Set&Value=%2$s]", autoupdate=“false”}

Following the troubleshooting advice above, I did a wget on the local
This is the output from the wget command you recommend in a previous thread:

[13:45:42] openhabian@openHABianPi:~$ wget http://localhost/velserver/service.pl--2019-03-03     13:45:53--  http://localhost/velserver/service.pl
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:80... failed: Connection refused.
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1066 (1.0K)
Saving to: ‘service.pl’

service.pl          100%[===================>]   1.04K  --.-KB/s    in 0s

2019-03-03 13:45:53 (45.9 MB/s) - ‘service.pl’ saved [1066/1066]

Http binding is enabled as well as jsonpath.

Next I should check the webserver.log, right?

Best regards,

Ward

Some tips: If you do a wget, use quotes. If not, the & will be interpreted by the shell:
wget ‘http://localhost/velserver/service.pl?Item=Relay_04_02&Action=Get

And if you add -O-, the data will printed on STDOUT:
wget -O- ‘http://localhost/velserver/service.pl?Item=Relay_04_02&Action=Get

And if you add &html, the output will be in an easy-to-read format:
wget -O- ‘http://localhost/velserver/service.pl?Item=Relay_04_02&Action=Get&html

Stef

OK, I got this:

[13:46:11] openhabian@openHABianPi:~$ wget -O- 'http://localhost/velserver/servi                                                                                                             ce.pl?Item=Relay_04_02&Action=Get&html'
--2019-03-03 14:02:18--  http://localhost/velserver/service.pl?Item=Relay_04_02&                                                                                                             Action=Get&html
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:80... failed: Connection refused.
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1066 (1.0K)
Saving to: ‘STDOUT’

-                     0%[                    ]       0  --.-KB/s               <                                                                                                             !DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>Velbus</title>
<link rel="stylesheet" type="text/css" href="include/jquery.dataTables.min.css"                                                                                                              />
<script src="include/jquery-3.3.1.min.js" type="text/javascript"></script>
<script src="include/script.js" type="text/javascript"></script>
<script src="include/jquery.dataTables.min.js" type="text/javascript"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<p>
<a href=?appl=scan_for_modules>Scan the bus for modules</a> || <a href=?appl=pri                                                                                                             nt_found_modules>Found modules</a> || <a href=?appl=print_channel_tags>Channel t                                                                                                             ags</a> || <a href=?appl=generate_openHAB_items>Generate openHAB items file</a>                                                                                                              || <a href=?appl=empty_database>Empty the database</a> <br />
<a href=?appl=print_velbus_protocol>Velbus protocol</a> || <a href=?appl=print_v                                                                                                             elbus_messages>Velbus messages</a> || </p>

</body>
-                   100%[===================>]   1.04K  --.-KB/s    in 0s

2019-03-03 14:02:18 (10.3 MB/s) - written to stdout [1066/1066]

And for the set action:

[14:03:23] openhabian@openHABianPi:~$ wget -O- 'http://localhost/velserver/service.pl?Item=Relay_04_02&Action=Set&Value=ON&html'
--2019-03-03 14:09:02--  http://localhost/velserver/service.pl?Item=Relay_04_02&Action=Set&Value=ON&html
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:80... failed: Connection refused.
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1066 (1.0K)
Saving to: ‘STDOUT’

-                                                 0%[                                                                                                     ]       0  --.-KB/s               <!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>Velbus</title>
<link rel="stylesheet" type="text/css" href="include/jquery.dataTables.min.css" />
<script src="include/jquery-3.3.1.min.js" type="text/javascript"></script>
<script src="include/script.js" type="text/javascript"></script>
<script src="include/jquery.dataTables.min.js" type="text/javascript"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<p>
<a href=?appl=scan_for_modules>Scan the bus for modules</a> || <a href=?appl=print_found_modules>Found modules</a> || <a href=?appl=print_channel_tags>Channel tags</a> || <a href=?appl=generate_openHAB_items>Generate openHAB items file</a> || <a href=?appl=empty_database>Empty the database</a> <br />
<a href=?appl=print_velbus_protocol>Velbus protocol</a> || <a href=?appl=print_velbus_messages>Velbus messages</a> || </p>

</body>
-                                               100%[====================================================================================================>]   1.04K  --.-KB/s    in 0s

2019-03-03 14:09:03 (51.6 MB/s) - written to stdout [1066/1066]

If I check Velbuslink, Relay 04_02 is still off.

Best regards,
Ward