Smart Garden Tap Water - On and Off

I’ve just installed mine 2… It works like a charm!

$150 includes one gateway and one water timer. So one gateway itself costs $50

I have had quite good luck with their support the handful of times ive had obscure API questions.

I wrote my own handler for their API (PHP, not python, so let the flame war begin) so i could setup a single google assistant command with an ingredient for which tap i wanted to use and they were quite helpful.

Ive asked if its possible to gain access directly to the gateway, which would make life easier for automations! However, it seems the gateway is closed, and theres no access to it.

I have written some python based curl requests, using the request module, to talk to the cloud API, but broke HA all kinds of badly when trying to turn it into a custom component for HA

I’ve written an appdaemon app to handle the API call’s and mimic the ECO mode for now (was not possible in the API) but I have on good authority that the next release of their API (tomorrow) will have the eco options aswel. I must say: I’m a big fan.

Any chance you could share? :slight_smile:

Sure!

import appdaemon.plugins.hass.hassapi as hass
import datetime

class taplink(hass.Hass):
    def initialize(self):
        self.arg_switch = self.args["switch"]
        self.listen_state(self.switch_event,self.arg_switch)
        self.log("TapLink is Ready")
        self.handle_water = None
        self.handle_checker = None
        self.handle_stop = None
        
    def switch_event(self, entity, attribute, old, new, kwargs):
        if (new == 'on'):
            self.log("Starting Watering")
            self.duration = int(float(self.get_state(self.args["duration"])))
            flow_interval  = int(float(self.get_state(self.args["interval_on"])))
            stop_interval  = int(float(self.get_state(self.args["interval_off"])))
            total_interval = (flow_interval + stop_interval)*60 
            self.log("Starting with {}m and {}m stop-intervals for {}m".format(flow_interval, stop_interval,self.duration))
            self.notify("Starting watering Procedure", title = "LinkTap Watering", name = "pushover")
            self.handle_stop = self.run_in(self.water_off,(self.duration*60))
            self.handle_water = self.run_every(self.water_on,self.datetime(),total_interval)
        else: 
            self.log("Stopping Watering")
            self.water_off()
            self.cancel_timer(self.handle_stop)

    def water_on(self, kwargs=None):
        self.log("Switching LinkTap on")
        self.call_service("rest_command/linktap_on")

    def water_off(self, kwargs=None):
        self.log("Switching LinkTap off")
        self.call_service("rest_command/linktap_off")
        self.turn_off(self.arg_switch)
        self.notify("Ending watering Procedure", title = "LinkTap Watering", name = "pushover")
        self.cancel_timer(self.handle_water)
        self.cancel_timer(self.handle_stop)

You also need to configure 2 RESTfull commands (rest switches did not work for me)

linktap_on:
  url: https://www.link-tap.com/api/activateInstantMode
  method: POST
  payload:  '{"username": "Your username","apiKey": "your api key","gatewayId": "your gw id","taplinkerId": "your linker id","action": "true", "duration": {{states.input_number.interval_on_water.state}}}'
  headers:
    User-Agent: Home Assistant
    Content-Type: application/json

linktap_off:
  url: https://www.link-tap.com/api/activateInstantMode
  method: POST
  payload: '{"username": "your username","apiKey": "yourkey","gatewayId": "type your gw id","taplinkerId": "type you link id","action": "false","duration":0}'
  headers:
    User-Agent: Home Assistant
    Content-Type: application/json

and 3 input_number slides:

duration_water:
  name: Duration LapLink Watering
  min: 0
  max: 120
  step: 5
  initial: 45
  icon: mdi:clock

interval_on_water:
  name: Interval ON LapLink Watering
  min: 2
  max: 20
  step: 2
  initial: 8
  icon: mdi:timer

interval_off_water:
  name: Interval OFF LapLink Watering
  min: 1
  max: 10
  step: 1
  initial: 2
  icon: mdi:timer

Get your key here: https://www.link-tap.com/#!/api-for-developers

2 Likes

awesome, thanks!
i might see if i can extend it to also track the status – i have a schedule setup in the linktap app, but its not the most user friendly thing, and id like to actually track watering etc.

I havent used appDaemon before, but im sure i can work it out :slight_smile:

So i ended up having a change of tact.

I spent ages trying to get a restful switch working, but couldnt.
So, using yours as inspiration, i setup a restful switch to my existing API handler i wrote for google assistant, and after modifying it a little to always return the current status, it works great!

1 Like

Hi. I bought the taplink watering system and sort of starting with HA and use Hass.io but I am a bit lost with your code. I get that the number slides have to be in configuration.yaml but what about the 2 others?

Ah, yes… I see what you mean… I’ve split up all my configuration and these 2 other are REST commands…

So in my configuration.yaml is says:

rest_command: !include rest_command.yaml

and if you put the 2 rest commands in the file rest_command.yaml you will be set. Otherwise you need to do something like:

rest_command:
  linktap_on:
    url: https://www.link-tap.com/api/activateInstantMode
    method: POST
    payload:  '{"username": "","apiKey": "","gatewayId": "","taplinkerId": "","action": "true", "duration": {{states.input_number.interval_on_water.state}}}'
    headers:
      User-Agent: Home Assistant
      Content-Type: application/json

  linktap_off:
    url: https://www.link-tap.com/api/activateInstantMode
    method: POST
    payload: '{"username": "","apiKey": "","gatewayId": "","taplinkerId": "","action": "false","duration":0}'
    headers:
      User-Agent: Home Assistant
      Content-Type: application/json

Thanks. What about the first part of your code?

The one that starts with import appdaemon …
Where should that be?
And do I need to install or set up something for appdaemon?

Sorry for my lack of knowledge, just starting and trying to figure out things but it is not that easy so appreciate your help. I am sure a lot of other users will benefit from this as well.

Thx!

Just installed Addpaemon for Hass IO

And how do you connect the boolean “Tap Link Watering” to do instant on and off?

This is the code I have so far

In config. yaml:

input_boolean:
taplink:
name: TapLink Watering
initial: off
icon: mdi:water

input_number:
duration_water:
name: Duration LapLink Watering
min: 0
max: 120
step: 5
initial: 45
icon: mdi:clock

interval_on_water:
name: Interval ON LapLink Watering
min: 2
max: 20
step: 2
initial: 8
icon: mdi:timer

interval_off_water:
name: Interval OFF LapLink Watering
min: 1
max: 10
step: 1
initial: 2
icon: mdi:timer

In groups.yaml:
Outside:
name: Outside
view: yes
entities:
- group.gardenwatering

Gardenwatering:

  • input_boolean.taplink
  • input_number.interval_on_water
  • input_number.interval_off_water
  • input_number.duration_water
1 Like

It’s controlled by the AppDeamon app. Oh and when you quote config in this forum, you might want to use 4 backquotes, that helps with the formatting.

Great. can you please check my other question about where to put the add daemon code?

That’s a bit to much to answer in the forum. I think it’s best to read the documentation: Getting started — AppDaemon 4.4.3 documentation

I don’t really knows how this works in hass.io as I’ve installed HA on a linux box.

ok. Maybe my question should be, in which file is that code saved?

Ah, yes I see what you mean, but you still need to read the documentation to understand how that works :slight_smile:
You need a .yaml file with the app configuration and that points to a .py file with the code.

In my case:
pick_a_name.yaml

TapLink Watering:
  module: taplink
  class: taplink
  duration: input_number.duration_water
  interval_on: input_number.interval_on_water
  interval_off: input_number.interval_off_water
  switch: input_boolean.watering

taplink.py
{insert the python code}

I am stuck as I use hass.io but thanks anyway

If someone else can help, it would be great

If you have a web server running somewhere (even just a pi you can throw raspbian + nginx + php on) i can share the PHP classes i wrote, and you can then setup each linktaper as a rest switch in HA.

1 Like