Rachio Smart Sprinkler Controller

I verified what the cloud returns (using bridge option clearAllCallbacks=true cleans up the table when the binding gets initialized)
a) when no registrations are active

curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaa" https://api.rach.io/1/public/notification/dddddddd-dddd-dddd-dddd-dddddddd/webhook

returns 
[]
= empty list

when the binding is initialized:

[{"id":"wwwwwwww-wwww-wwww-wwww-wwwwwwww","url":"http:/markus123,com:51443/rachio/webhook","eventTypes":[{"name":"DEVICE_STATUS","type":"WEBHOOK"},{"name":"ZONE_DELTA","type":"WEBHOOK"},{"name":"ZONE_STATUS","type":"WEBHOOK"},{"name":"SCHEDULE_STATUS","type":"WEBHOOK"},{"name":"RAIN_DELAY","type":"WEBHOOK"},{"name":"DELTA","type":"WEBHOOK"},{"name":"WEATHER_INTELLIGENCE","type":"WEBHOOK"}],"externalId":"hhhhhhhhhhhhhhhhh"}]

aaaaaaaa is the app key
dddddddd is the device id
wwwwww is the webhook id
hhhhhhhh is a hash to be validated on inbound requests

I found a mini bug displaying the clearAllCallbacks setting, but is just cosmetics.

Markus,

I temporarily bypassed my reverse proxy and exposed the ports. I was able to access everything as expected however the response to the curl command is still []. I cant seem to find the init string you mentioned anywhere. Where am I looking for that exactly?

[{"id":"wwwwwwww-wwww-wwww-wwww-wwwwwwww","url":"http:/markus123,com:51443/rachio/webhook","eventTypes":[{"name":"DEVICE_STATUS","type":"WEBHOOK"},{"name":"ZONE_DELTA","type":"WEBHOOK"},{"name":"ZONE_STATUS","type":"WEBHOOK"},{"name":"SCHEDULE_STATUS","type":"WEBHOOK"},{"name":"RAIN_DELAY","type":"WEBHOOK"},{"name":"DELTA","type":"WEBHOOK"},{"name":"WEATHER_INTELLIGENCE","type":"WEBHOOK"}],"externalId":"hhhhhhhhhhhhhhhhh"}]

I tried a grep of my log files and I don’t see it come up.

Here is what I tried…

:/opt/openhab2/userdata/logs$ tail -f *.log | grep WEBHOOK

Important. I opened up a new branch ‘alpha2’ - see below

update for the community while having direct chats with Hector

  • we found the problem preventing registering web hook - he didn’t accepted the linkage of the device thing (only bridge + zone things), this led into missing device initialisation. I’ll add a check on the zone level to block zone initialisation until the device is linked and initialized -> pending
  • we get the events working in his setup with reverse proxy, found a bug in the ipFilter -> solved, now the binding has private IP address ranges as default (10/8, 192.168/16 and 172/12) to simplify setup and support those configurations out-of-the box

Finally it’s now working for @fifo’s setup (including inbound events / webbhooks), so we could move to the next level: user interface
The common goal is to create a HABpanel widget. For this we need some more changes

  • We need to verify which set of channels are really useful - providing information for the device + zone status, having some UI specific information, but don’t overload the user with channels noby needs or don’t provide consistent information,
  • The imageUrl provided by the API is more a key than a file. If you enter the url in the browser it brings up the image as a file to download, but if you use this url und a custom wight it shows the default picture. This needs to type of logic - call the link, download the image and then transform it - maybe as local file, but I don’t like the idea. So maybe other HABpanel developrs can help - this is not binding specific.
  • Implement and map more events (like water budget, rain skip) to channels so they can be processed by the UI.
  • alarming if unusual things happen (e.g. device went offline for a certain time). Some of it could be implemented just by using the expire biding (and provide a how-to)
  • Implement time zone handling (for now all timestamps are related to EDT)
    that will bring us to new ideas :slight_smile:

In regards to the binding / network level:

  • recover on internet connection problems - for now bridge goes down, but don’t recover when connection became available
  • https for webhook - this requires additional investigation. I can’t get the event, because jetty is refusing the certificate. Rachio support is involved, but still no break-through
  • @fifo will document his reverse proxy setup, which adds even more security

And in general: enhancing the documentation (e.g. full example of config) + some refactoring (already mostly done)

So: Don’t hesitate to raise other ideas for smart solutions by integrating other OH features / bindings.

Important. I opened up a new branch ‘alpha2’. So if you want to get access to the latest build you can use this url: https://github.com/markus7017/org.openhab.binding.rachio/blob/alpha2/target/org.openhab.binding.rachio-2.3.0-SNAPSHOT.jar
Once done I’ll go to post this build on the ESH ioT market place.

@KidSquid @Agbush @ranielsen @NCO @leadsrating @mjwedeking Do you want to try the latest build? It’s getting pretty stable. I’m interested to get broader test coverage and also improving the setup experience (incl documentation).

https://github.com/markus7017/org.openhab.binding.rachio/blob/alpha2/target/org.openhab.binding.rachio-2.3.0-SNAPSHOT.jar (please note: it’s a new branch ‘alpha2’).

Does anyone already have a Generation 3 controller or the Rachio flow meter? I suppose they will be supported by the same api and would add additional feature to the binding (e.g. send an alarm when flow meter detects a leak).

Sprinkler system (v2) turned back on this weekend. Will download and look. Thank you for getting this far

basic steps for setup

  • obtain an appkey from the Rachio Website
  • create a rachio.things under /things

example:

Bridge rachio:cloud:1 [ apikey="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx", pollingInterval=180]
{
}
  • copy the binding jar to addons folder
  • go to the openhab console and enable debugging:
log:set DEBUG org.openhab.binding.rachio
  • wait a minute
  • check that the bridge thing is online; PaperUI->Configuration->Things
  • Due to the fact that there will be many things/items generated it might be a good idea to enable simple mode for item linking (you could revert it after the thing discovers):
    PaperUI->Configuration->System->Item Linking, Simple Mode on
  • switch to PaperUI->Inbox, press the scan button, select Rachio binding
  • you should get 1 thing for the controller and 1 for each zone
  • make sure that the device thing is initialized and you see all zones
  • now you can go to PaperUI->Control and should see the device & zones status. Click on run and it should run a zone for 2 min (default).

You should allow the binding to receive events from the Rachio cloud. This has some pre-requisites - see README.MD
extending for events signalling (http webhook):

  • create a port forwarding on your router (myport to the OH device:8080)
  • add url to the bridge config
Bridge rachio:cloud:1 [ apikey="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx", pollingInterval=180, callbackUrl="http://mydomain.com:myport/rachio/webhook", clearAllCallbacks=true ]
{
}
  • restart OH so everything gets initialized
  • check openhab.log for inconsistent parameters and errors

Let me know if you can’t get it up. Cheers, Markus

Hi Markus,

thanks for you effort.
I have soved my watering issue in a different way and cannot help testing your new version.
Sorry

thx for responding :slight_smile:

Markus,

Just wanted to give you a heads up that I have tested the webhook URL with a secure url and it is working as expected.

Do you mean https rather than http? Was that in your reverse proxy setup or directly? (I aleay had the problem that jetzy didn’t liked the certificate, but maybe they changed sthg).

I got it to work with https using a letsencrypt cert. Is your cert a self signed certificate? Could that be the issue?

Hi, it’s the inbound certificate, which doesn’t get accpred by jetty, because of cert chain issues - maybe they corrected it in between

Guess that’s possible. I am still good on my end.

a new build is available at
https://github.com/markus7017/org.openhab.binding.rachio/blob/alpha2/target/org.openhab.binding.rachio-2.3.0-SNAPSHOT.jar

Markus,

I installed the new updated binding and so far it looks good. The only thing I noticed is that the image url does not provide the entire URL as we had discussed. This is what I see for image URL.

https://prod-media-photo.rach.io/

verified that the binding is running on OH 2.1, 2.2 and 2.3-SNAPSHOT (Dev)

verified that the JSON returned by the cloud api returns

..."imageUrl":"https://prod-media-photo.rach.io/"

need to investigate / contact Rachio support

alpha2 branch has been merged to master

  • https supported for inbound webhook events
  • more information in the zone event strings
  • image load requests are redirected to the binding to prevent a problem with the Rachio cloud
  • revised exception handling
  • disabled zones don’t create a thing

https://github.com/markus7017/org.openhab.binding.rachio/blob/master/target/org.openhab.binding.rachio-2.3.0-SNAPSHOT.jar

In addition the README is updated to include a how-to setup a reverse proxy based on NGINX or Apache. This makes the webhook events really secure.

Sample rule to catch zone events (replace rachio_zone_1_xxxxxxxx_1_zoneEvent with the connect item name):

var int totalRunTime = 0

/* ------- Alarm handler ----- */
rule "Zone started"
when
	Item rachio_zone_1_xxxxxxxx_1_zoneEvent changed
then
	var jsonString = rachio_zone_1_xxxxxxxx_1_zoneEvent.state.toString
	logDebug("RachioEvent", "Event triggered (JSON='" + jsonString + "')")
	
	var eventTimestamp = transform("JSONPATH","$.timestamp",jsonString);
	var eventType = transform("JSONPATH","$.type",jsonString)
	var eventSubType = transform("JSONPATH","$.subType",jsonString)
	var eventSummary = transform("JSONPATH","$.summary",jsonString)

	if (eventType == "ZONE_STATUS") {
		var zoneName = transform("JSONPATH","$.zoneName",jsonString)
		var zoneNumber = transform("JSONPATH","$.zoneNumber",jsonString)
		var runState = transform("JSONPATH","$.zoneRunState",jsonString)
		var runStart = transform("JSONPATH","$.startTime",jsonString)
		var runEnd = transform("JSONPATH","$.endTime",jsonString)
		var runDuration = transform("JSONPATH","$.duration",jsonString)
		var scheduleType = transform("JSONPATH","$.scheduleType",jsonString)
		logInfo("RachioEvent", eventTimestamp + " " + zoneName + "[" + zoneNumber + "]: " + eventSummary + "(type='" + scheduleType + "', state='" + runState + "')")
		if (eventSubType == "ZONE_COMPLETED") {
			totalRunTime = totalRunTime + Integer::parseInt(runDuration)
			logInfo("RachioZone", "Zone [" + zoneNumber + "]: start: " + runStart + ", end: " + runEnd + ", duration: " + runDuration + " => Total run time = " + totalRunTime)
		}
	} 
	else {
		// generic message
		logInfo("RachioEvent", eventTimestamp + " [" + eventSubType + "]: " + eventSummary)
	}

end

see openhab.log

2018-05-13 18:11:59.659 [INFO ] [e.smarthome.model.script.RachioEvent] - 2018-05-13T22:11:52Z Driveway-rechts[1]: Driveway-rechts completed watering at 06:11 PM (EDT) for 2 minutes.(type='FIXED', state='COMPLETED')
2018-05-13 18:11:59.683 [INFO ] [se.smarthome.model.script.RachioZone] - Zone [1]: start: 2018-05-13T22:09:55.968Z, end: 2018-05-13T22:11:55.968Z, duration: 120 => Total run time = 120

using a OH item for totalRunTime and making it persistent will provide the total run time (if you lile per zone and on the controller and you could combine this with a Garfana graph).

Sniplet 1 for HABpanel template / widget: show zone event and properties

<div class="text-left" ng-init="event=$eval(itemValue('rachio_zone_1_xxxxxxxx_1_zoneEvent'))"> 
Zone [{{itemValue('rachio_zone_1_F0038CC690BE_1_number')}}]: {{itemValue('rachio_zone_1_F0038CC690BE_1_name')}}<br/>
{{event.summary}}<br/>
Last run: {{event.startTime}} for {{event.duration}}s<p/>
</div>

Sniplet 2 - “dump” event attributes

<div class="text-left" ng-repeat="(key, value) in $eval(itemValue('rachio_zone_1_xxxxxxxx_1_zoneEvent'))">
{{key}}:{{value}}
</div>
<p/>

Good news:
Rachio support came back on the problem with missing mime types on image downloads:
“New images have the correct mime-type. This week we will be updating existing images with the correct mime-type. Thanks for pointing this out. The new images now with directly from the URL.”
This means
a) the OH community is helping Rachio to improve their product (this was the 2nd time)
b) I could remove the image loader servlet in a upcoming release of the binding (after Rachio fixed their database internally)

Next: I requested information how to catch the WEATER_INTELLEGENCE events. This would allow to track those events and process the information in a dashboard of Garfana histogramm.

1 Like

@Agbush, @KidSquid Any feedback / test results from your side?

Latest build:

Known issues

  • a access failure to the cloud (e.g. Internet connection is down) forces the thing to become offline (which is correct), but there is no recovery when the cloud connection was restored, so thing doesn’t become online
  • sometimes inbound webhook events are not processed (ignore due to “unknown device” / “unknown zone” messages)
  • device discovery sometimes fails - no clue why
  • timestamps are not adapted to local timezone, even the Rachio cloud returns different formats - all of them need to be unified

Open to discuss

  • simplify schema of item naming (currently they include the mac address of the controller, which makes rules & widget code installation specific)
  • do we need seperated zone events or is a consolidated device event channel the better way. Even if I want to filter by zone this information is included in the zone events (see sample sniplets). Having only a single event channel per device also means a way easier way to catch all zone events (one rule rather than one for the device and one for each zone).

Need help

  • Who could help to develop a cool HABpanel widget?
  • Does anyone already has a Gen3 controller? and/or Rachio Flow Meter?
  • Does anyone has attached sensors to the controller?

Next step: with beta1 I’ll move to the ESH IoT market to get more testers.