Aliases for slave IDs

Motivation

Here is my problem, I'm human

The original motivation for this feature comes from a forum request:

By: charly86
Hi all,
I would like to know if there is a specific configuration or possibility to
replace the 1W device-ID by an alias in the owfs system

Here is my problem, I'm human and it's very difficult to me to remember which
device as this or this ID owfs is mounted in /mnt/owfs
So I created a new folder /mnt/hcontrol and made some sym links. This is working
fine. like the structure below (when ls -al /mnt/hcontrol)
office -> /mnt/owfs/12.0AB668000000/PIO.B
bedroom -> /mnt/owfs/12.A97F68000000/PIO.B
living -> /mnt/owfs/12.FEB568000000/PIO.A

Any magic idea to solve my problem ?
Thus was born the alias file.

Alias File


The file itself is a simple text file with the format:
SlaveID1 = human_readable_name
SlaveID2 = human_readable_name

As an example (from the request above):
12.0AB668000000 = office
12.A97F68000000 = bedroom
12.FEB568000000 = living
  • The SlaveID is in hexidecimal in any format that owfs accepts
    • dots are optional
    • CRC8 is optional but must be accurate if specified
    • Initial / in the path is allowed
    • hexidecimal upper or lower case
  • The separator between ID and name can be any combination of spaces, tabs and the = sign
  • Empty lines are ignored
  • Bad lines are ignored

Command line

Use either the short form
owfs -a myaliases.txt -d /dev/ttyS0 -m /mnt/1wire
or the long form
owhttpd --alias=fancynames.txt -u -p 4444
or add the alias file to the configuration file

Limitations

There are some caveats:

  • Only devices can get human readable names, not individual properties.
    So in the example above
    12.0AB668000000 = office
    NOT
    12.0AB668000000/PIO.B = office
  • Alias names can't interfere with "reserved words" like uncached, statistics, alarm...
  • Alias names can't be a directory. E.g no "bedroom/light"
  • Spaces in names might be confusing to some of the programs.
  • Alias files must be specified locally (more on that below).

Example

Initial setup

Let's use a simple 1-wire setup: USB adapter and some slaves: (Note, I've added /opt/owfs/bin to my path for convenience).
>sudo owserver -u -p 4304
owdir / > alias.txt

We get the alias.txt file:
/2C.66FE04000000
/2C.1B7900000000
/22.367A03000000
/12.C4DF1F000000
/01.5F50CA090000
/81.6B1B24000000
/89.BD29C300705E
/bus.0
/settings
/system
/statistics
/structure
/simultaneous
/alarm

I can edit out the non-slave entries, or use the more elegant:
owdir / | grep "^/[0-9A-F]\" > alias.txt
to get:
/2C.66FE04000000
/2C.1B7900000000
/22.367A03000000
/12.C4DF1F000000
/01.5F50CA090000
/81.6B1B24000000
/89.BD29C300705E
We now add readable names to some devices:
/2C.66FE04000000 Window
/2C.1B7900000000 Door
/22.367A03000000 Vacant_room
/12.C4DF1F000000 Hall closet
/01.5F50CA090000
/81.6B1B24000000 BusMasterID
/89.BD29C300705E Light


Using from the shell

Restart owserver:
> sudo killall owserver
> sudo owserver -a alias.txt -u -p 4304
> owdir /
/Window
/Door
/Vacant_room
/Hall closet
/01.5F50CA090000
/BusMasterID
/Light
/bus.0
/settings
/system
/statistics
/structure
/simultaneous
/alarm
This works as you would expect:
> owdir /Door
/Door/address
/Door/alias
/Door/chargepump
/Door/crc8
/Door/family
/Door/id
/Door/locator
/Door/present
/Door/r_address
/Door/r_id
/Door/r_locator
/Door/type
/Door/wiper

You can still use the hex name of course:
> owread 2C.66FE04000000/alias
Window

Gotta be local

Suppose you want to link the web server to this owserver. You might think it's as easy as
> owhttpd -s 4304 -p 4444
But You'll be surprised when you see:
OWFS on 4304 Bus listing OWFS homepage Dallas/Maxim by Paul H Alfille

directory


top highest level directory
2C.66FE04000000 2C.66FE04000000 directory
2C.1B7900000000 2C.1B7900000000 directory
22.367A03000000 22.367A03000000 directory
12.C4DF1F000000 12.C4DF1F000000 directory
01.5F50CA090000 01.5F50CA090000 directory
81.6B1B24000000 81.6B1B24000000 directory
89.BD29C300705E 89.BD29C300705E directory
bus.0 bus.0 directory
uncached uncached directory
settings settings directory
system system directory
statistics statistics directory
structure structure directory

Not our pretty names! 
Instead you have to use
> owhttpd -a alias.txt -s 4304 -p 4444
OWFS on 4304 Bus listing OWFS homepage Dallas/Maxim by Paul H Alfille

directory


top highest level directory
Window Window directory
Door Door directory
Vacant_room Vacant_room directory
Hall closet Hall closet directory
01.5F50CA090000 01.5F50CA090000 directory
BusMasterID BusMasterID directory
Light Light directory
bus.0 bus.0 directory
uncached uncached directory
settings settings directory
system system directory
statistics statistics directory
structure structure directory
The general point is that all the big programs (the ones that link in libow to be technical) have to specify the alias file as well. The includes owfs, owhttpd, owftpd, owserver, owperl, ...

File system

> owfs -s 4304 -m 1wire -a alias.txt
> ls 1wire/uncached
01.5F50CA090000  bus.0  BusMasterID  Door  Hall closet  Light  settings  statistics  structure  system  Vacant_room  Window

The light-weight programs that only function as network clients don't need an alias file, they use owserver's alias file instead.  (That's why I used the shell programs owdir and owread for the examples, it's simpler).

It has to do with the internal communication and whether the program really knows anything about 1-wire or just passes requests along.

Previous page: Testing without hardware
Next page: Alias improved