Smart Garden Tap Water - On and Off

while the standard Zigbee is simply not comprehensive enough for our product scenario

Looking at the range of sensors and actuators supported by zigbee2mqtt, this sounds like BS :wink:
I assume they want to constrain their support use cases, and prevent loss of sales if people buy only the valve not the hub. Which is absolutely fair :slight_smile:

I have a good feeling for the developers of link-tap. They respond quickly to customer enquiries and seem to be switched on about their user community.
I asked them about availability in the UK and got quick reply and followup when stock levels were replenished. They also confirmed for me the LAN API, but were less committal about a HA component.

3 Likes

This is awesome, got it working in my UI now.
any way to add some more info to this?
things like the battery, current work mode, wireless signal strength, watering history(if possible?!)

not sure what changed, but getting errors about the payload in the rest.switch

So I bought a link-tap.
Working great so far on its own.
Next challenge is to get it into HA.

1 Like

I found this very useful. I have it working with two taps. I did make a few tweaks that make it work better for what I wanted, but you got me started in the right direction. Thank you!

Outstanding work. Thanks Sagitt

Hey all! Any code updates to this at all since last year?

Hi Lessmann, any chance you could link the exact components that you used for this very good looking build? I’m in an area with 230v power grid, did you need to do any voltage changes for it to work?

Your original ebay link no longer works, but I found these which have a 220v versions. If I just hook up this to a Sonoff Basic and the tap connectors it should be good to go right? First time with anything like this so would appreciate some laymens terms if possible.

I’m no electrician but the 220v or 240v should work just fine. I think I have a 240v.
The solenoid is one directional so check which way the water flows and make sure the water is flowing when the magnet is “open”. It gets pretty hot after a while if there is no water flowing through it and I did burn one out. Getting the plumbing adaptors down to the tap connection size I needed was the biggest challenge

Great thank you. I’ll pull the trigger on these and see how far this rabbit hole goes :slight_smile:

I’ve just happened to buy this exact junction box and have a very similar solenoid and am struggling to find the right pieces so I can extend out the water connections to the outside of the box. Would you please be able to link me to what you bought to get that perfect length! Thanks again, your build looks spot on and I’m almost there!

This is my approach, a Sonoff 4CH R2 Pro with three 12V solenoid valves (in a 3D printed weatherproof housing)

2 Likes

Great Work! I’m a bit late to the party but just bought a LinkTap G2 so thought I’d have a go at interfacing with the API’s myself.

I have built upon what you started and use two of the API’s to provide a faster update of the watering status and flow rate as well as provide info on connection status, battery level and device fault alarms.

3 Likes

I’ve added the battery. It’s pretty easy to add the work mode and wireless signal strength. Watering history you would probably have to use the homeassistant recorder for - using the watering status. You could totalise the flow rate too, but the flow is updated at every 30 seconds (best API poll time).

Let me know if you still want the work mode and signal strength and I’ll put up a snippet.

1 Like

I was just about to start an update of my own config from last year now that some calls have been added to the API. Would you mind posting your configuration?

1 Like

I created the package as suggested by sagittcyber and modified to:

# LinkTap Package

# Inputs
input_number:
   linktap_duration:
     name: 'Duration'
     icon: mdi:clock
     min: 5
     max: 150
     step: 5

# Switches
switch:
  - platform: template
    switches:
      linktap_sprinkler:
        friendly_name: 'Sprinkler Instant Mode'
        value_template: '{{ is_state("binary_sensor.linktap_sprinker_watering","on") }}'
        turn_on:
          service: script.linktap_on
        turn_off:
          service: script.linktap_off

sensor:
    # Access getalldevices API and read all data
  - platform: rest
    name: linktap_getalldevices
    verify_ssl: true
    scan_interval: 360
    resource: https://www.link-tap.com/api/getAllDevices
    method: POST
    payload: '{"username": "your username", "apiKey": "your api key"}'
    json_attributes:
      - result
      - devices
    value_template: '{{ value_json.result }}'
    headers:
      User-Agent: Home Assistant
      Content-Type: application/json
    # Access getWateringStatus API and read all data - this API can be read every 30 seconds which is more frequent and up to date than the getalldevices API that is 5 mins
  - platform: rest
    name: linktap_getwateringstatus
    verify_ssl: true
    scan_interval: 35
    resource: https://www.link-tap.com/api/getWateringStatus
    method: POST
    payload: '{"username": "your username", "apiKey": "your api key", "taplinkerId": "your taplinker ID"}'
    json_attributes:
      - result
      - status
    value_template: '{{ value_json.result }}'
    headers:
      User-Agent: Home Assistant
      Content-Type: application/json
  - platform: template     
    sensors:
      #Sprinkler Battery Level
      linktap_sprinker_battery:
        friendly_name: Sprinker Battery
        value_template: '{{ states.sensor.linktap_getalldevices.attributes.devices[0].taplinker[0].batteryStatus }}'
        device_class: battery
      #Sprinkler Watering Time Remaining until it stops
      linktap_sprinker_onduration:
        friendly_name: Time Remaining
        unit_of_measurement: mins
        value_template: >-
          {% if states.sensor.linktap_getwateringstatus.attributes.result == 'ok' %}
            {% if states.sensor.linktap_getwateringstatus.attributes.status!=none %}
              {{ states.sensor.linktap_getwateringstatus.attributes.status.onDuration }}
            {% else %}
              0
            {% endif %}
          {% else %}
            0
          {% endif %}
      # The G2 Sprinkler allows for flow rate monitoring
      linktap_sprinker_vel:
        friendly_name: Flow Rate
        unit_of_measurement: ml/min
        value_template: >-
          {% if states.sensor.linktap_getwateringstatus.attributes.result == 'ok' %}
            {% if states.sensor.linktap_getwateringstatus.attributes.status!=none %}
              {{ states.sensor.linktap_getwateringstatus.attributes.status.vel }}
            {% else %}
              0
            {% endif %}
          {% else %}
            0
          {% endif %}

# Binary Sensors
binary_sensor:
#Linktap Derived Sensors
  - platform: template     
    sensors:
      #Gateway connected
      linktap_gateway:
        friendly_name: Gateway Status
        value_template: '{{ states.sensor.linktap_getalldevices.attributes.devices[0].status=="Connected" }}'
        device_class: connectivity
      # G2 Tap Connected
      linktap_sprinker:
        friendly_name: Sprinker Status
        value_template: '{{ states.sensor.linktap_getalldevices.attributes.devices[0].taplinker[0].status=="Connected" }}'
        device_class: connectivity
      linktap_sprinker_fall:
        friendly_name: Fall Alarm
        value_template: '{{ states.sensor.linktap_getalldevices.attributes.devices[0].taplinker[0].fall=="true" }}'
        device_class: problem
      linktap_sprinker_valvebroken:
        friendly_name: Valve Broken Alarm
        value_template: '{{ states.sensor.linktap_getalldevices.attributes.devices[0].taplinker[0].valveBroken=="true" }}'
        device_class: problem
      linktap_sprinker_nowater:
        friendly_name: No Water Alarm
        value_template: '{{ states.sensor.linktap_getalldevices.attributes.devices[0].taplinker[0].noWater }}'
        device_class: problem
      # API has null in status if no watering is occuring, therefore a none null response means that the device is watering
      linktap_sprinker_watering:
        friendly_name: Watering
        value_template: '{{ states.sensor.linktap_getwateringstatus.attributes.status!=none }}'
        device_class: moisture

# REST Commands
rest_command:
  linktap_on:
    verify_ssl: true
    timeout: 10
    url: https://www.link-tap.com/api/activateInstantMode
    method: POST
    payload: '{"username": "your username", "apiKey": "your api key", "gatewayId": "your gateway ID", "taplinkerId": "your taplinker ID", "action": "true", "duration": {{ states.input_number.linktap_duration.state }}, "autoBack": "true"}'
    content_type: 'application/json; charset=utf-8'
    headers:
      User-Agent: Home Assistant
      Content-Type: application/json
  linktap_off:
    verify_ssl: true
    timeout: 10
    url: https://www.link-tap.com/api/activateInstantMode
    method: POST
    payload: '{"username": "your username", "apiKey": "your api key", "gatewayId": "your gateway ID", "taplinkerId": "your taplinker ID", "action": "false", "duration": 0, "autoBack": "true"}'
    content_type: 'application/json; charset=utf-8'
    headers:
      User-Agent: Home Assistant
      Content-Type: application/json

# Scripts
script:
  linktap_on:
    alias: 'Activate LinkTap'
    sequence:
    - service: rest_command.linktap_on

  linktap_off:
    alias: 'Deactivate LinkTap'
    sequence:
    - service: rest_command.linktap_off

  linktap_update:
    alias: 'Update LinkTap'
    sequence:
    - service: homeassistant.update_entity
      entity_id: sensor.linktap_getalldevices

My lovelace entities card:

entities:
  - entity: binary_sensor.linktap_sprinker_watering
  - entity: sensor.linktap_sprinker_onduration
  - entity: sensor.linktap_sprinker_vel
  - entity: switch.linktap_sprinkler
  - entity: input_number.linktap_duration
  - entity: binary_sensor.linktap_gateway
  - entity: binary_sensor.linktap_sprinker
  - entity: binary_sensor.linktap_sprinker_fall
  - entity: binary_sensor.linktap_sprinker_nowater
  - entity: binary_sensor.linktap_sprinker_valvebroken
  - entity: sensor.linktap_sprinker_battery
title: Sprinkler
type: entities
5 Likes

Thanks. Looks great, @TDM . I’ll give it a try.

3 Likes

Awesome
Just got a linktap2

Will give this a try too /
I have 2 devices and 2 hubs, any issues with that?

1 Like

I’m getting a 400 on activateInstantMode.

I wanted to check if you are supposed to include dashes in the IDs and if anyone had to change anything in reaction to any API changes.

Edit: nevermind, found the docs. You don’t include dashes.

1 Like

I haev found they like to make API changes and the old methods dont work.

Ive had a taplinker for about 3 years now, and I reckon its happened 4-5 times.

Thats far more “clever” than my solution.
I ended up rolling my own API connector in php, and HA interfaces with that.

1 Like