I am re-implementing a verrrry old PHP/Linux/owfs system that controls my central heating to HA running on Docker a Pi4. I have an EDS OW_SERVER to run my 1-wire networks and an 8-channel relay board based around DS2408.
@larre suggested using a RESTful Sensor against the OW-SERVER’s CSV output, e.g. http owserver.local/gettag.csv?romid=FA0008022A1B3610&tag=Temperature&title=0
@bearfoo showed how to use the RESTful Sensor to pull DS18B20 temperature data using OW-SERVER’s XML output, e.g. http owserver.local/details.xml
David_Lindstrom suggested using OW-SERVER’s SNMP interface (also agreed with by EDS , i.e. Mr OW-SERVER )
Wuellueb suggested running a separate roobbb/owserver container and then connecting to it using the 1-wire Interface support built into HA
So I have two challenges:
how to get the status of the 8 outputs (with bitwise operator to extract each channel from the output latch byte)
how to update the DS2408 to change the output states
I have historically used a little bit of Python to set the state using this URL format http owserver.local/devices.htm?rom=MYDS2408ROM&variable=PIOOutputLatchState&value=128
For the first requirement, I really like the idea of making a call to details.xml and extracting all sensor data in one go - for me it seems fairly easy to understand and saves needing the SNMP MIB etc. However I’m not finding parsing the XML from HA easy to understand - it works a charm with @bearfoo 's example for DS18B20s but when I try to adapt that to owd_DS2408 it struggles to find the sensor data.
So I guess the first thing is whether using a REST Sensor is a good way to go, or maybe I start again with SNMP…? Then I’ll worry about the second requirement…
TIA!
Simon
PS. although I’m on a Pi I don’t want to move away from OW-SERVER as they are a nice way to abstract the vagaries of 1-wire, plus I’ve had a couple for a decade or more and they are super reliable.
PPS. as a new user I’m not allowed to mention more than 2 - thanks to contributions by others too!
The temperature works perfectly, but the the DS2408 sensor is showing as Unknown and in the log I get homeassistant.components.rest.util JSON result was not a dictionary or list with 0th element a dictionary.
I’ve checked the IDs and syntax very carefully but I think my main problem is I don’t understand how HA is managing to parse the XML as if it’s JSON…
I’ve found a handful of topics where people have been trying to parse XML from a RESTful Sensor, though mostly seem to end up doing pattern matching (which sounds like very hard work).
A list of keys to extract values from a JSON dictionary result and then set as sensor attributes. If the endpoint returns XML with the text/xml, application/xml or application/xhtml+xml content type, it will automatically be converted to JSON according to this specification
So it feels like I should be able to extract whatever I need from the OW-SERVER’s details.xml just the syntax is a little tricky.
PS. OW-SERVER is such a good product (prior to that I used to spend ages faffing around with 1-wire adapters & owfs) it would be great if one day @EDS has chance include a REST API… probably harder work than it sounds though…
It seems that @bearfoo 's example works when there are multiple of a specific type of sensor connected to the OW-SERVER. This gets the sensor type structured in an array. I’d expect the following to work if you have multiple DS2408s connected to the OW-SERVER:
Thanks @EDS . I have been a bit distracted with work and realised I’d forgotten this.
I did getting it working (just one DS2408 connected) with this:
- name: "Heating Control Kitchen"
unique_id: owserver2.control.hbc1
value_template: "{{ value_json['Devices-Detail-Response']['owd_DS2408']['PIOLogicState'] | int | bitwise_and(0b00000010) == 0 }}"
force_update: true
json_attributes_path: "$.['Devices-Detail-Response']['owd_DS2408']"
json_attributes:
- Channel
- Health
- ROMId
However, previously I couldn’t get my version which included the ROM ID to work (which could be useful since I have a backup HobbyBoards DS2408). Looking at one of my temperature sensors I’m pretty sure I was trying very similar permutations to yours, but I was getting some weird behaviour as if it was treating all devices, including the DS2408, like an owd_DS18B20.
More urgent is to get HomeAssistant to have a button to send a devices.htm?rom=CF00000009A88829&variable=PIOOutputLatchState&value=113 etc to OWSERVER as I’m currently having to do a binary to decimal conversion to control my heating
Anyway, unfortunately I seem to have paged out the useful information so will have to try to get it back in my head at the weekend!
I’ve used the following RESTful Commands to change the state of a DS18B20’s UserByte1. It should be usable with the obvious substitutions (IP Address, ROM, Variable, and Value).
rest_command:
hvac_off:
url: "http://10.0.10.138/devices.htm?rom=7200000E36D9C528&variable=UserByte1&value=85"
method: get
hvac_on:
url: "http://10.0.10.138/devices.htm?rom=7200000E36D9C528&variable=UserByte1&value=0"
method: get
You can then select the command in the Automation’s Visual Editor by navigating to Add Action>Other actions>RESTful Command. From there, you’ll have the option of selecting which command (and therefore URL) to be sent. The options are “hvac_off” and “hvac_on” in my example.