Can't get onewire working with OpenHAB on RPi

Hi!

I have for a long time been struggling to get my onewire interface working together with OpenHAB without success. Since I’m out of clues for the moment I’m asking for help here. It’s probably something simple but I just can’t figure it out. Any suggestion on what I have done wrong/missed or how to debug the problem would be appreciated.

I’m using a Raspberry PI with an i2c 1wire expansion module and an USB connected TellStick Duo device for 433MHz units.
It has Raspbian Jessie Lite, owserver, TellStick software and OpenHAB 1.8.1 installed.
Tellstick is working fine together with OpenHAB.
The onewire interface has two DS18B20 temperature sensors connected at the moment.
Owserver seems to be working also since I can use “owread -s localhost …” to read the temperature from the sensors.

When running openhab with start_debug.sh the only sign I can see from onewire is the following two lines:

12:47:02.588 [DEBUG] [b.o.internal.OWServerActivator:34 ] - OWServer binding has been started.
12:47:02.788 [DEBUG] [o.b.o.internal.OWServerBinding:96 ] - OWServer: Activate

Otherwise nada! The rrd4j service is trying to log the temperature from the sensors so I see these lines occurring every minute:

12:49:00.149 [TRACE] [o.c.p.internal.PersistItemsJob:56 ] - Storing item ‘Temperature_OW1’ with persistence service ‘rrd4j’ took 7ms
12:49:00.159 [TRACE] [o.c.p.internal.PersistItemsJob:56 ] - Storing item ‘Temperature_OW2’ with persistence service ‘rrd4j’ took 7ms

but no temperature is logged. At least the bindings seems to have been recognized somehow.

According to the One wire binding page caching could be a problem so I have tested the “onewire:post_only_changed_values=false” openhab.cfg and with the “Switch OneWireClearCache “OneWireClearCache” {onewire=“control=CLEAR_CACHE”}” but with no success.

I have tried both “onewire:ip=localhost” and “onewire:ip=127.0.0.1” in the openhab.cfg file.

Previously I was using OpenHAB 1.7.1 with same problems (never got onewire working).

OpenHAB has the following addons installed:
org.openhab.binding.http-1.8.1.jar org.openhab.persistence.exec-1.8.1.jar
org.openhab.binding.ntp-1.8.1.jar org.openhab.persistence.logging-1.8.1.jar
org.openhab.binding.owserver-1.8.1.jar org.openhab.persistence.rrd4j-1.8.1.jar
org.openhab.binding.tellstick-1.8.1.jar

Onewire configuration in openhab.cfg file looks like this:
############################## OneWire Binding ########################################

OwServer IP address

onewire:ip=localhost

OwServer Port (optional, defaults to 4304)

#onewire:port=

the retry count in case no valid value was returned

upon read (optional, defaults to 3)

#onewire:retry=

defines which temperature scale owserver should return temperatures in. Valid

values are CELSIUS, FAHRENHEIT, KELVIN, RANKINE (optional, defaults to CELSIUS).

#onewire:tempscale=

only changed values are posted to the event-bus, (optinal, defaults to true - values true or false)

onewire:post_only_changed_values=false

########################### NetworkHealth Binding #####################################

My .items file looks like this:
Group Home
Group gBF (Home) /* Basement floor /
Group gGF (Home) /
Ground floor /
Group gFF (Home) /
First floor /
Group gOutdoor (Home) /
Outdoor */

Group gBF_Living “Living Room” (gBF)

Group gGF_Living “Living Room” (gGF)
Group gGF_Kitchen “Kitchen” (gGF)
Group gGF_Toilet “Toilet” (gGF)
Group gGF_Hall “Hall” (gGF)

/* Onewire fix */
//Switch OneWireClearCache “OneWireClearCache” {onewire=“control=CLEAR_CACHE”}

/* Lights */
Switch Light_GF_Living “Window” (gGF_Living) { tellstick=“Relay 1:Command” }
Switch Light_BF_Living “Window” (gBF_Living) { tellstick=“Relay 2:Command” }

/* Temperatures */
Group gTempChart
Number Temperature_OW1 “Temperature [%.1f °C]” (gTempChart, gOutdoor) {onewire=“deviceId=28.576FE0000000;propertyName=temperature;refreshinterval=30”}
Number Temperature_OW2 “Temperature [%.1f °C]” (gTempChart, gOutdoor) {onewire=“deviceId=28.3597E0000000;propertyName=temperature;add=0.0;multiply=1.0;refreshinterval=60;ignore85CPowerOnResetValues”}
Number Temperature_GF_Loft “Temperature [%.1f °C]” (gTempChart, gGF_Living) { tellstick=“11:Temperature:Temperature:mandolyn” }
Number Temperature_Outdoor “Temperature [%.1f °C]” (gTempChart, gOutdoor) { tellstick=“12:Temperature:Temperature:mandolyn” }
Number Temperature_GF_Kitchen “Temperature [%.1f °C]” (gTempChart, gGF_Kitchen) { tellstick=“13:Temperature:Temperature:mandolyn” }

/* NTP binding demo item */
DateTime Date “Date and Time: [%1$tA, %1$tY-%1$tm-%1$td %1$tR]” { ntp=“Europe/Stockholm:se_SE” }
//DateTime Date “Date [%1$tA, %1$td.%1$tm.%1$tY]” { ntp=“Europe/Stockholm:se_SE” }

I would recommend to separate possible onewire and persistense issues.
Check with “tail -f /var/log/openhab/events.log” to see if there are any temperature updates.

BTW, in the regular openhab log you should see something like

[INFO ] [o.o.b.o.i.c.OneWireConnection ] - Connected to owserver [IP ‘127.0.0.1’ Port ‘4304’]

Hi Andrew and thanks for your reply!

I renamed the onewire bindings in the .items file to prevent rrd4j to log data from the onewire sensors however it’s still logging temperature data from my 433 MHz sensors so I don’t know if it’s good enough. Now the bindings look like this:
Number OW1 “Temperature [%.1f °C]” {onewire=“deviceId=28.576FE0000000;propertyName=temperature;refreshinterval=30”}
Number OW2 “Temperature [%.1f °C]” {onewire=“deviceId=28.3597E0000000;propertyName=temperature;add=0.0;multiply=1.0;refreshinterval=60;ignore85CPowerOnResetValues”}

I restarted openhab, still running it from the console with start_debug.sh.
Still there is no sign of onewire activity in the events.log file. It basically looks like this:
2016-03-13 16:00:05 - Light_BF_Living received command ON
2016-03-13 16:00:06 - Light_GF_Living received command ON
2016-03-13 16:00:07 - Light_BF_Living state updated to ON
2016-03-13 16:00:07 - Light_GF_Living state updated to ON
2016-03-13 16:00:27 - Temperature_GF_Kitchen state updated to 21.0
2016-03-13 16:00:50 - Temperature_Outdoor state updated to 3.3
2016-03-13 16:00:52 - Temperature_GF_Loft state updated to 20.2
2016-03-13 16:01:27 - Temperature_GF_Kitchen state updated to 21.0
2016-03-13 16:01:50 - Temperature_Outdoor state updated to 3.2
2016-03-13 16:01:50 - Temperature_Outdoor state updated to 3.3
2016-03-13 16:01:52 - Temperature_GF_Loft state updated to 20.2
2016-03-13 16:02:13 - Date state updated to 2016-03-13T16:02:13
2016-03-13 16:02:27 - Temperature_GF_Kitchen state updated to 21.0
2016-03-13 16:02:50 - Temperature_Outdoor state updated to 3.2
2016-03-13 16:02:50 - Temperature_Outdoor state updated to 3.3
2016-03-13 16:02:52 - Temperature_GF_Loft state updated to 20.2
2016-03-13 16:03:27 - Temperature_GF_Kitchen state updated to 21.0
2016-03-13 16:03:50 - Temperature_Outdoor state updated to 3.2
2016-03-13 16:03:50 - Temperature_Outdoor state updated to 3.3
2016-03-13 16:03:52 - Temperature_GF_Loft state updated to 20.2
2016-03-13 16:04:27 - Temperature_GF_Kitchen state updated to 21.1
2016-03-13 16:04:50 - Temperature_Outdoor state updated to 3.2
2016-03-13 16:04:50 - Temperature_Outdoor state updated to 3.3
2016-03-13 16:04:52 - Temperature_GF_Loft state updated to 20.2

Mostly updates from my 433MHz sensors as you can see. I haven’t noticed any onewire activity in the events.log file before either.
The “[INFO ] [o.o.b.o.i.c.OneWireConnection ] - Connected to owserver [IP ‘127.0.0.1’ Port ‘4304’]” (or anything similar as far as I can see) does not appear in the openhab.log file, the only onewire activity to be found is this:
16:20:43.267 [DEBUG] [b.o.internal.OWServerActivator:34 ] - OWServer binding has been started.
16:20:43.454 [DEBUG] [o.b.o.internal.OWServerBinding:96 ] - OWServer: Activate
which appears once among other messages when starting openhab.

I guess that the absence of “[INFO ] [o.o.b.o.i.c.OneWireConnection ] - Connected to owserver [IP ‘127.0.0.1’ Port ‘4304’]” is a clue tough… Is it possible to enable some more debug information somehow or do you know what the problem could be?

The formatting of my onewire configuration settings in the openhab.cfg file got a bit messed up above but basically the only two active lines are these:
onewire:ip=localhost
onewire:post_only_changed_values=false

I replaced “onewire:ip=localhost” with “onewire:ip=127.0.0.1” again but this makes no difference.

Br,
Roger

Roger,
you don’t have the binding installed :wink:
You need org.openhab.binding.onewire-1.8.1.jar

Hi Andrew,

Thanks! I missed that, didn’t realize that there existed two binding files for one wire, Shame on me! :pensive:
I have added org.openhab.binding.onewire-1.8.1.jar to addons so now I get a little step further. But it’s still not working. Now I get the following in the log file:

2016-03-19 13:27:34.833 [ERROR] [o.o.b.o.i.c.OneWireConnection ] - Couldn’t connect to owserver [IP ‘localhost’ Port ‘4304’]:
2016-03-19 13:27:34.852 [WARN ] [o.o.b.o.i.c.OneWireConnection ] - Inital connection to owserver failed!

There are no onewire entries appearing in the events.log file.
Openhab seems to recognize that files are updated but to be on the safe side I’m restarting openhab and that doesn’t make any difference.
I have tried with both “onewire:ip=localhost” and “onewire:ip=127.0.0.1” in the openhab.cfg but with same negative result. The port number should be OK since “owread -s localhost:4304 28.3597E0000000/temperature” responds with the temperature. Could it be that I’m missing some more binding files? I added the “org.openhab.binding.tcp-1.8.1.jar” but that didn’t help. Some security settings in linux preventing openhab to access the port perhaps?

Br,
Roger

I suggest to delete the wrong binding file and check for possible duplicates of port 4304 in openhab.cfg
In my setup the port is not even specified:

############################## OneWire Binding ########################################
#
# OwServer IP address
onewire:ip=127.0.0.1

# OwServer Port (optional, defaults to 4304)
#onewire:port=

Also check with “ip a” for possible loopback ip misconfiguration.

Hi Roger,
for me it worked to change the last line of the file /etc/owfs.conf from

server : port = localhost:4304

to

server : port = 4304

I know that the first is the preset, but for me it helped to change it. Hope it helps you, too.

4 Likes

that did the trick for me as well!

Been going over this today as well - owserver by default is launched on localhost. There are two parameters server : server = ... and server : port = ..... Default configuration file in my case was misleading and both parameters contained host and port number. For just clearness, setting server : server = 0.0.0.0 causes owserver listening on all network interfaces on specified port.

This can be verified via lsof:

COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
owserver 31135 root    6u  IPv4  76145      0t0  TCP *:4304 (LISTEN)
owserver 31135 root   10u  IPv4  76151      0t0  TCP raspberry1.local:4304->openhab.local:46446 (ESTABLISHED)```

The one-wire binding worked for me with the setting: OwServer IP ::1 and port 4303.
I.am not a expert but it has something to do with the IPv6 protocol on the Pi

Thanks, that fixed my problem that the binding dosn’t keep online.:+1: