WIP: Replacing onewire with an owserver-based library

@brano1990 One tip on the owserver. It is possible to use an alias file so instead of the long serial number you can use short names that you can remember. I recently file a issue to have this added as it was not in the documentation. Write my if it is not in and I can tell you were the file needs to go and what it needs to look like.

The alias used on owserver will then show up in Home Assistant as well.

1 Like

There’s also the interesting feature of telling all 20-or-however-many of your temperature sensors to do their measurement in the background. When you read them the naïve way each access blocks the whole bus for a second or so.

My asyncowfs Python library can do that but it’s not integrated into HA. I planned to do it but had no free time.

So that’s why I have reading errors

recommend a separate DS18b20?
and another separated on ds2408?

according to the manual from @frederickjh it works for me but it’s slow

I will try to disconnect the DS18b20 as recommended

@brano1990 I am not sure you comprehend the 1-wire technology. It is an old technology. It needs only two wires but can use a third for sending power to devices.

With only a two wire data bus it can only poll one device at a time. The topography of your wiring in your 1-wire network can also affect the speed at which a device can respond.

If you are trying to do time critical switching of devices on and off, I am pretty sure that 1-wire is the wrong choice for this application. Bus timing on newer devices has made this better, but I am not sure this is fast enough for your application. Check the documentation at Maxim Integrated’s website for the details.

I have only 3 wires in each room on the wall, (bus connection) my solution how to control 3 buttons and 3 LEDs is to use 1-wire

i2c needs 4 wire

my old installation was a KNX bus
it is very expensive to repair, so I’m trying to change it

I welcome any solution
without wifi

@brano1990 What is your use case that you need such quick responses from your sensor and switches?

When I did this, with a proximity sensor, my use case was to poll the sensor every 1/10th second.

If you don’t have anything else on the bus this even works. Mostly.

The sensible thing is to add a diode, capacitor, and resistor to each button so that pressing the button discharges the capacitor, which then gets recharged during the next two seconds or so. You can now get away with the occasional half second without polling the button.

The even more sensible thing is to not do this in Home Assistant, because consistent sub-second timing is not what it’s built for. Instead use an external program. I’d take distmqtt + asyncowfs and write a few lines of Python to interface the two. (Actually I’m using distkv-owfs … which is probably severe overkill for your use case.)

NB: instead of reading the temperature from each sensor, you need to write 1 to /simultaneous/temperature, wait a second or two, and then read each temperature sensor’s latesttemp attribute. This avoids blocking the whole bus during temperature conversions. (asyncowfs does this for you in the background.)

You also need to supply 5V to your sensors instead of relying on parasite power.

I estimated only 50ms i can use the update about 200ms i have to try it

I use multi click button
now i am using ADS1115 update_interval: 50ms


the problem is that I can’t use the LED to output from the HA to the “information LED on the button” button

for ADS I can’t use ttp223 touch button over 6pcs

I don’t know programming in python

@frederickjh @MatthiasU do you have any binary sensor connected to DS2408?
The HA sensor is read slowly for 30 seconds

The switch is beautiful fast, it’s not a problem, it’s

when i read 1pc ds2408 via node red so it read me 50ms quote is ok

I have a problem with a server loss error message on red nodes, where can be the problem? even though I read 10s,
I still get an error from the server, when I use solo 10ks DS18b20 I have no problem with the server

i have ds2408 involved
with pullup 2.2k on 1-wire

I use a logic level converter DS2482 i2c pullup 2.2k to 3.3v and I have a pullup 2.2k to 5Vzapojenie

Hi @frederickjh @MatthiasU

A bit off-topic, but it’s regarding my OWFS (ow-server) setup. Got a problem since a couple of days regarding reading the USB bus master. This must be related to the Zigbee2Mqtt installation I was working on (see the set permissions chapter below in the link).

I have OWFS running on my Ubuntu 20.04, everything worked fine but for Zigbee2Mqtt I needed to change a bit regarding premissions and now OWFS is telling me not to work regarding (the same?) premissions. Do you know how to undo / fix this premissions issue?

SSH Log:

sudo /opt/owfs/bin/owfs u -m /mnt/1wire/
<LIBUSB_ERROR_ACCESS> Could not open the USB bus master. Is there a problem with permissions?
DEFAULT: ow_usb_msg.c:(188) <LIBUSB_ERROR_ACCESS> Could not open the USB bus master. Is there a problem with permissions?
DEFAULT: owlib.c:(208) Cannot open USB bus master
DEFAULT: owlib.c:(52) No valid 1-wire buses found

sudo /usr/bin/owfs -u --allow_other /mnt/1wire/
Segmentation fault

Schermafbeelding 2021-02-24 om 00.02.14

@bernd Yes, it is off topic but I will humor you as I think I know what your issue is. From the page you linked to, I am guessing you have two usb devices plugged into the computer one for the 1-wire and one for Zigbee. On the page you linked to there is a section in the instructions titled 2. UDEV Rules. They don’t really explain what this is doing but I recognized it.

When you plug a USB device on Linux that is a USB serial connection, it creates a devices like /dev/ttyUSB1. However when you plug and unplug or plug them in a different order or reboot they may get assigned to a different device. The number at the end changes.

My guess is that in your current 1-wire owserver configuration (/etc/owfs.conf) you have a line with a device like this:

device = /dev/ttyUSB1

You need to add a UDEV rule so that the 1-wire USB devices serial port is always reachable at the same device, just like you did for the Zigbee devices serial port and change the device in /etc/owfs.conf.

My 1-wire setup worked fine until I also plugged a 3D printer with a USB serial interface into the same computer. Then I had to setup these UDEV rules to make the USB serial devices always be named the same. Here are my notes on how to do this.

Create persistent USB serial device names on Linux: how to force a USB device to use the same ttyUSB number
Based on information from:

Used with OneWire USB devices for owserver part of owfs when using it with Home Assistant.

  1. find out what’s on ttyUSB:

dmesg | grep ttyUSB

  1. list all attributes of the device:

udevadm info --name=/dev/ttyUSBx --attribute-walk

(with your device number(s) instead of x, of course). Pick out a unique identifier set, eg idVendor + idProduct. You may also need SerialNumber if you have more than one device with the same idVendor and idProduct. SerialNumbers ought to be unique for each device.
3. Create a file /etc/udev/rules.d/99-usb-serial.rules (or your own .rule file see examples below) with something like this line in it:

SUBSYSTEM=="tty", ATTRS{idVendor}=="1234", ATTRS{idProduct}=="5678", SYMLINK+="your_device_name"

(assuming you don’t need a serial number there, and of course with the numbers for idVendor and idProduct that you found in step 2.
4. Load the new rule:

sudo udevadm trigger

  1. Verify what happened:

ls -l /dev/your_device_name

will show what ttyUSB number the symlink went to. If it’s /dev/ttyUSB1, then verify who owns that and to which group it belongs:

ls -l /dev/ttyUSB1

Then just for the fun of it:

udevadm test -a -p $(udevadm info -q path -n /dev/your_device_name)

in /etc/udev/rules.d/62-fjh-persistant-x1-sidewinder-3d-printer.rules
SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", SYMLINK+="x1sidewinder"

in /etc/udev/rules.d/62-fjh-one-wire-usb-adapter.rules
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", SYMLINK+="USBonewire"

Then run sudo udevadm trigger to load the new rule(s).

You need to add a UDEV rule so that the 1-wire USB devices serial port is always reachable at the same device, just like you did for the Zigbee devices serial port and change the device in /etc/owfs.conf .

That, or take advantage of the already-existing udev ruleset in /lib/udev/rules.d/60-serial.rules which creates a guaranteed-stable-and-unique link to your device in /dev/serial/by-path/. There’s also a by-id directory but given that some manufacturers take a rather dim view of writing actual serial numbers to their firmware I wouldn’t depend on that.

I’m running Home Assistant on a raspberry pi using the “official” image for hass.

Is there a way to install ofws/owserver on that unit to access 1-Wire devices through a USB-stick connected to the pi?
(I find old posts mentioning owserver as an addon, but I cannot find any such addon in the HMI.)

also looking for a way to install OWServer onto

 OS Version:               Home Assistant OS 7.6
  Home Assistant Core:      2022.4.6


and can still not get it working as I can not find the devices

I am concerned that I will not get 1wire working on owserver before the sys/bus option is removed. I installed the owserver on my system with no problem until I used the 1 wire integration to find my 1wire sensors. I use a Rasperry Pi4 and run supervised Hassio. Owserver only found on sensor and it did not give the correct reading it was more like Fahrenheit even though the owserver setting was Celsius. I had to revert back to sysbus. Has anyone had a similar problem or know of a fix?