Since I didn't find an existing driver, I'm in the early stages of developing a driver for HA7Net devices . I've looked at a lot of driver examples, but I still have some basic questions about how I should be implementing an HE driver for this device. These questions are less about dealing with the HA7Net specifically and more about working with devices that need to be polled for information.
Update
Since creating this post, I've worked through the majority of the issues I was facing with this driver. The initial iteration is working for both standalone temperature and combined humidity and temperature sensors supported by the HA7Net.
The released HA7Net drivers were announced in this thread:
A few highlights on my learning:
- The 500 error was due to a
@Grab
statement that was attempting to include an external library. I've since removed that statement in deference to relying on thehttpPost()
method to automatically parse the HTML response. - Once I got past the 500 error, useful error messages were displayed when I attempted to add the driver to HE.
- Since I didn't initially realize that the built-in
httpPost
method existed, I was attempting to use thejava.net.URL
package to support the POST operation. Since this package is not allowed on HE, I migrated to using the built-inhttpPost()
method.
Driver Code in Development
Here's the working driver code:
https://github.com/ckamps/hubitat-drivers-ha7net/blob/master/ha7net-temp-humidity.groovy
Questions
Q: Target End User Experience
Update: I'm planning to get the basic driver working and then quickly migrate to implementing a parent-child driver so that the HA7Net device is treated as a parent device and children devices are automatically created for each sensor known to the parent HA7Net.
I assume that once I get this driver deployed and tested, the end user experience will be for the user to:
- Deploy the temperature + humidity and/or the temperature only driver(s).
- Create a virtual device for each 1-Wire sensor and associate one of the two drivers with each of those virtual devices.
- Enter the unique sensor ID.
- Enter the HA7Net's IP address.
- Assign a name to the virtual device that represents the location and perhaps the type of the sensor.
- Define one or more rules in RM to force a periodic refresh of the devices' status.
- Implement other rules to take actions based on temperature and humidity values being reported by the sensors.
Does this sound right in terms of overall user experience?
If there was sufficient metadata for each sensor maintained in the HA7Net, for example, the logical name and location of each sensor, then I could see developing an HE app to auto discover and register the sensors as virtual devices. However, there is insufficient metadata managed in HA7Net.
Q: Including External Modules
Update: Unfortunately, but understandably, use of @Grab
does not appear to be supported in HE. The good news is that the built-in method httpPost
automatically parses the HTML response.
Is the use of @Grab
to grab external modules supported in HE drivers?
Since this driver does screen scrapping of HTML responses from the HA7Net, I'm using a tagsoup XML parser that is more lenient that stock parsers.
Q: Required Methods
In the case of this type of device where Hubitat will need to poll the HA7Net to obtain sensor data, what is the minimum set of methods needed in the driver?
install()
,updated()
, andinitialize()
- I implemented these methods, but they are very basic.refresh()
- Already implemented with the code to send aPOST
to the HA7Net and send events back to HE, but I have a question (see next one) about how to properly send the required data back to HE.poll()
- It looks like I should implement thepoll()
method and simply have it callrefresh()
.parse()
- I've seen other drivers implement theparse()
method, but this method seems to be needed for devices that proactively send data. I'm assuming that this method does not apply to the HA7Net.
Q: Sending Data Back to Hubitat
Update: The `sendEvent() method appears to be working as expected.
The driver's refresh()
method is currently using sendEvent()
to send temperature and humidity data back to HE. Is this the proper way to send data back to HE in this scenario?
I've declared the following capabilities for this driver:
RelativeHumidityMeasurement
TemperatureMeasurement
Refresh
.
Q: Debugging Error 500 Issues
Update: After removing the @Grab
line, the 500 error went away and useful error messages started appearing. I'll consider filing a bug with HE about generation of a 500 error under this circumstance.
Is there anything I can do to help debug the 500 error when registering this driver?
The logs don't appear to have any data in them related to failed addition of the driver.
Device Background
An HA7Net device can support up to 100 1-Wire sensors. It has an ethernet interface and a built-in web application that enables a browser-based view of sensor data. To obtain sensor data, client applications need to perform screen scrapping via POST requests including whether the request is for temperature only or temperature + humidity data and the sensor ID.
The 1-Wire devices I currently have on hand are:
- AAG TAI-8540 - Humidity + temperature (includes an embedded DS18B20 temp sensor)
- DS18B20 - Temperature