Smart Garden Tap Water - On and Off

Ahh yep i learnt that lesson the hard way.

It doesnt register a tap until the tap itself checks in – if they are off, they wont appear.

I had one who had a flat battery the same time as i was trying to get MQTT working way back when. I banged my head against it for hours only to finally check the app and it was offline there too!

1 Like

Im struggling to get the duration to set properly from HA.

I thought i had something that set the failsafe, but im not sure failsafe is what i want to use, as its designed for a global catch all and its possible i might want to manually run a watering job for longer than that.

So the duration is what im trying to use.
Has anyone got a template switch working, using the Linktap switch as a state, but using a script as the action for turn on ? In theory, it should work.

When setting the total duration, via a MQTT message, is the mobile app supposed to also reflect that time ? I can see that the MQTT payload has the total_duration value set correctly, but the app still says the default 1400 odd minutes.

Hey, did you read the linktap documentation. I think page 28 has some home assistant script/automation code.

Otherwise, this is the template switch I use:

switch:
  - platform: template
    switches:
      linktap_bot:
        friendly_name: 'LinkTap Bot'
        value_template: '{{ is_state("binary_sensor.xxxlinktapIDxxx_is_watering","on") }}'
        turn_on:
          - service: script.linktap_bot_on
        turn_off:
          - service: script.linktap_bot_off

script:
  linktap_bot_on:
    alias: 'Activate LinkTap Bot'
    sequence:
      - service: rest_command.linktap_activateinstantmode
        data:
          username: !secret linktap_name
          apikey: !secret linktap_apikey 
          gatewayId: !secret gatewayId
          taplinkerId: xxxlinktapIDxxx
          duration: '{{ [states("input_number.linktapwateringduration1") | int(1),15]|min }}' #default is 1 minute, max 15 min
          durationSec: 0
    mode: single
  linktap_bot_off:
    alias: 'Deactivate LinkTap Bot'
    sequence:
      - service: rest_command.linktap_deactivateinstantmode
        data:
          username: !secret linktap_name
          apikey: !secret linktap_apikey 
          gatewayId: !secret gatewayId
          taplinkerId: xxxlinktapIDxxx
    mode: single

rest_command:
  reboot_linktap:
    url: 'http://xxxlocal_gateway_ipxxx/index.shtml?flag=0'
    method: GET
  linktap_setwebhookurl:
    url: 'https://www.link-tap.com/api/setWebHookUrl'
    method: POST
    content_type: 'application/json; charset=utf-8'
    headers:
      User-Agent: Home Assistant
      Content-Type: application/json
    verify_ssl: true
    payload: '{"username": "{{ username }}", "apiKey": "{{ apikey }}", "webHookUrl": "{{ webhookurl }}"}'
  linktap_activateinstantmode:
    url: https://www.link-tap.com/api/activateInstantMode
    method: POST
    content_type: 'application/json; charset=utf-8'
    headers:
      User-Agent: Home Assistant
      Content-Type: application/json
    verify_ssl: true
    timeout: 10
    payload: '{"username": "{{ username }}", "apiKey": "{{ apikey }}", "gatewayId": "{{ gatewayId }}", "taplinkerId": "{{ taplinkerId }}", "action": "true", "duration": "{{ duration }}", "durationSec": "{{ durationSec }}" , "autoBack": "true"}'
  linktap_deactivateinstantmode:
    url: https://www.link-tap.com/api/activateInstantMode
    method: POST
    content_type: 'application/json; charset=utf-8'
    headers:
      User-Agent: Home Assistant
      Content-Type: application/json
    verify_ssl: true
    timeout: 10
    payload: '{"username": "{{ username }}", "apiKey": "{{ apikey }}", "gatewayId": "{{ gatewayId }}", "taplinkerId": "{{ taplinkerId }}", "action": "false", "duration": "0", "durationSec": "0", "autoBack": "true"}'

As you see, I am using the web api instead of the mqtt command right now, but I want to change to mqtt at some point. This is working quite well for me.
The only issue that I keep having is that the first api command every morning seem to get lost somehow. Maybe switching to mqtt will solve that.

Let me also include my front end card, I have three linktaps and I use some custom card types

type: vertical-stack
cards:
  - type: entities
    entities:
      - type: custom:fold-entity-row
        head:
          entity: binary_sensor.xxxlinktap1xxx_is_rf_linked
          type: custom:multiple-entity-row
          name: LinkTap's
          show_state: false
          state_color: true
          entities:
            - entity: binary_sensor.xxxlinktap1xxx_is_rf_linked
              name: Bot
            - entity: binary_sensor.xxxlinktap2xxx_is_rf_linked
              name: Top
            - entity: binary_sensor.xxxlinktap3xxx_is_rf_linked
              name: Garage
        entities:
          - entity: binary_sensor.xxxlinktap1xxx_is_rf_linked
            type: custom:multiple-entity-row
            name: LinkTap Bot
            secondary_info: last-changed
            show_state: false
            state_color: true
            entities:
              - entity: sensor.xxxlinktap1xxx_battery
                name: Battery
              - entity: sensor.xxxlinktap1xxx_signal
                name: Signal
              - entity: binary_sensor.xxxlinktap1xxx_is_flm_plugin
                name: Flow Meter
              - entity: binary_sensor.xxxlinktap1xxx_is_manual_mode
                name: Manual
          - entity: alarm_control_panel.xxxlinktap1xxx_broken_alarm
            type: custom:multiple-entity-row
            name: Alarm
            show_state: false
            state_color: true
            entities:
              - entity: alarm_control_panel.xxxlinktap1xxx_broken_alarm
                name: Broken
              - entity: alarm_control_panel.xxxlinktap1xxx_cutoff_alarm
                name: Cutoff
              - entity: alarm_control_panel.xxxlinktap1xxx_fall_alarm
                name: Fall
          - entity: binary_sensor.xxxlinktap1xxx_is_watering
            type: custom:multiple-entity-row
            name: Watering
            show_state: false
            state_color: true
            icon: mdi:water
            secondary_info: last-changed
            entities:
              - entity: sensor.xxxlinktap1xxx_remain_duration
                name: Remaining
              - entity: sensor.xxxlinktap1xxx_total_duration
                name: Total
              - entity: sensor.xxxlinktap1xxx_speed
                name: Velocity
              - entity: sensor.xxxlinktap1xxx_volume
                name: Volume
          - entity: switch.linktap_bot
            icon: mdi:water-outline
            active_icon: mdi:water
            type: custom:multiple-entity-row
            name: Switch
            toggle: true
            state_color: true
            secondary_info: last-changed
            show_state: true
            confirmation:
              text: Please Confirm
            entities:
              - entity: input_number.linktapwateringduration1
                name: Duration
              - entity: timer.linktapwatertimer1
                name: Timer
                attribute: duration
          - entity: input_number.linktapwateringduration1
            name: Duration
          - type: divider
          - entity: binary_sensor.xxxlinktap2xxx_is_rf_linked
            type: custom:multiple-entity-row
            name: LinkTap Top
            secondary_info: last-changed
            show_state: false
            state_color: true
            entities:
              - entity: sensor.xxxlinktap2xxx_battery
                name: Battery
              - entity: sensor.xxxlinktap2xxx_signal
                name: Signal
              - entity: binary_sensor.xxxlinktap2xxx_is_flm_plugin
                name: Flow Meter
              - entity: binary_sensor.xxxlinktap2xxx_is_manual_mode
                name: Manual
          - entity: alarm_control_panel.xxxlinktap2xxx_broken_alarm
            type: custom:multiple-entity-row
            name: Alarm
            show_state: false
            state_color: true
            entities:
              - entity: alarm_control_panel.xxxlinktap2xxx_broken_alarm
                name: Broken
              - entity: alarm_control_panel.xxxlinktap2xxx_cutoff_alarm
                name: Cutoff
              - entity: alarm_control_panel.xxxlinktap2xxx_fall_alarm
                name: Fall
          - entity: binary_sensor.xxxlinktap2xxx_is_watering
            type: custom:multiple-entity-row
            name: Watering
            show_state: false
            state_color: true
            icon: mdi:water
            secondary_info: last-changed
            entities:
              - entity: sensor.xxxlinktap2xxx_remain_duration
                name: Remaining
              - entity: sensor.xxxlinktap2xxx_total_duration
                name: Total
              - entity: sensor.xxxlinktap2xxx_speed
                name: Velocity
              - entity: sensor.xxxlinktap2xxx_volume
                name: Volume
          - entity: switch.linktap_top
            icon: mdi:water-outline
            active_icon: mdi:water
            type: custom:multiple-entity-row
            name: Switch
            toggle: true
            state_color: true
            secondary_info: last-changed
            show_state: true
            confirmation:
              text: Please Confirm
            entities:
              - entity: input_number.linktapwateringduration2
                name: Duration
              - entity: timer.linktapwatertimer2
                name: Timer
                attribute: duration
          - entity: input_number.linktapwateringduration2
            name: Duration
          - type: divider
          - entity: binary_sensor.xxxlinktap3xxx_is_rf_linked
            type: custom:multiple-entity-row
            name: LinkTap Garage
            secondary_info: last-changed
            show_state: false
            state_color: true
            entities:
              - entity: sensor.xxxlinktap3xxx_battery
                name: Battery
              - entity: sensor.xxxlinktap3xxx_signal
                name: Signal
              - entity: binary_sensor.xxxlinktap3xxx_is_flm_plugin
                name: Flow Meter
              - entity: binary_sensor.xxxlinktap3xxx_is_manual_mode
                name: Manual
          - entity: alarm_control_panel.xxxlinktap3xxx_broken_alarm
            type: custom:multiple-entity-row
            name: Alarm
            show_state: false
            state_color: true
            entities:
              - entity: alarm_control_panel.xxxlinktap3xxx_broken_alarm
                name: Broken
              - entity: alarm_control_panel.xxxlinktap3xxx_cutoff_alarm
                name: Cutoff
              - entity: alarm_control_panel.xxxlinktap3xxx_fall_alarm
                name: Fall
          - entity: binary_sensor.xxxlinktap3xxx_is_watering
            type: custom:multiple-entity-row
            name: Watering
            show_state: false
            state_color: true
            icon: mdi:water
            secondary_info: last-changed
            entities:
              - entity: sensor.xxxlinktap3xxx_remain_duration
                name: Remaining
              - entity: sensor.xxxlinktap3xxx_total_duration
                name: Total
              - entity: sensor.xxxlinktap3xxx_speed
                name: Velocity
              - entity: sensor.xxxlinktap3xxx_volume
                name: Volume
          - entity: switch.linktap_garage
            icon: mdi:water-outline
            active_icon: mdi:water
            type: custom:multiple-entity-row
            name: Switch
            toggle: true
            state_color: true
            secondary_info: last-changed
            show_state: true
            confirmation:
              text: Please Confirm
            entities:
              - entity: input_number.linktapwateringduration3
                name: Duration
              - entity: timer.linktapwatertimer3
                name: Timer
                attribute: duration
          - entity: input_number.linktapwateringduration3
            name: Duration
          - type: custom:uptime-card
            entity: binary_sensor.xxxlinktap1xxx_is_rf_linked
            hours_to_show: 96
            bar:
              amount: 96
              height: 15
              round: 1
              spacing: 1
            title_template: Top
            icon: mdi:water
            title_adaptive_color: true
            status_adaptive_color: true
            icon_adaptive_color: true
            tooltip_adaptive_color: true
            tap_action:
              action: more-info
            alignment:
              header: spaced
              status: spaced
              icon_first: false
              tooltip_first: false
          - type: custom:uptime-card
            entity: binary_sensor.xxxlinktap2xxx_is_rf_linked
            hours_to_show: 96
            bar:
              amount: 96
              height: 15
              round: 1
              spacing: 1
            title_template: Bot
            icon: mdi:water
            title_adaptive_color: true
            status_adaptive_color: true
            icon_adaptive_color: true
            tooltip_adaptive_color: true
            tap_action:
              action: more-info
            alignment:
              header: spaced
              status: spaced
              icon_first: false
              tooltip_first: false
          - type: custom:uptime-card
            entity: binary_sensor.xxxlinktap3xxx_is_rf_linked
            hours_to_show: 96
            bar:
              amount: 96
              height: 15
              round: 1
              spacing: 1
            title_template: Garage
            icon: mdi:water
            title_adaptive_color: true
            status_adaptive_color: true
            icon_adaptive_color: true
            tooltip_adaptive_color: true
            tap_action:
              action: more-info
            alignment:
              header: spaced
              status: spaced
              icon_first: false
              tooltip_first: false

1 Like

I did, but I don’t want to rely on HA to turn it off.
In a similar vein to the mobile app, I want to say hey turn on for x, not turn on, wait x, turn off.

The difference is subtle but important.

I’ve been liasing with their support team as allegedly it’s possible via MQTT, but I haven’t been able to get it to work yet.

I updated my reply with more details. The web api also allows the duration parameter, so you do not need to rely to HA, but you need internet access.
Otherwise, I also want to completely switch to mqtt, but I didn’t have the time yet.
I think you can just replace my linktap_bot_on script with the script from their documentations page 28 and it should work. Well, you also need to add the time as a parameter as I did for my script.

Yeah the duration thing via mqtt hasn’t ever worked for me.

I already have an implementation of their rest api, maybe I’ll just use that to turn on via a template switch or something.

I would certainly be interested in this as well.

IN THEORY sending this message to the configured downlink topic is supposed to work, but I havent had any luck as yet.

'{"cmd":6,"gw_id":"<gateway_id>","dev_id":"<tap_id>","duration":30}'

Im hoping theres some weird and wonderful combination of settings that will make it work… Their support have been pretty good so far!

So it turns out that linktap has 2 totally different modes of operation when it comes to MQTT

“Home Assistant” mode is greatly simplified, and means the gateway stops listening to the more detailed MQTT requests.

“Regular MQTT” has is far more feature rich, allows definiing of schedules, instant water for a set duration, things like that.

It should be possible to use the regular mode, AND get that working via MQTT. I have a single mqtt switch working at the moment, and all the associated sensors for that tap.

Its not quite as nice as MQTT Discovery, but I dont use it anyway!

2 Likes

I have all my sensors configured, and have one of the taps working, but does anyone know if its possible to use a template in an mqtt payload definition ?

Is this what you are looking for? …it’s a link to the MQTT section of the templating page.

probably – i hadnt had a chance to go looking and given it wasnt mentioned in the mqtt documentation itself, i wasnt sure it was possible.

The Auto mqtt stuff is perfectly fine if you want to just turn taps on and off. I learnt the hard way that wasnt ideal when i had a power outage and water kept running for many hours as the gateway went offline so never received the request to turn it off.

The manual MQTT stuff is — complicated but seems to work as expected.
Ive decided to write a custom componet using the local HTTP API – its almost ready for testing. Whether I use it or the manual MQTT configuration remains to be seen :slight_smile:

1 Like

I have a working custom component that uses the local HTTP API – making setup a lot simpler.
The component sets up a number entity, and thats whats used when you turn the switch on to turn on the tap.

It also pulls in all the same sensors and binary_sensors that mqtt auto discovery publishes.

The only annoying thing is you have to define each tap, rather than just the gateway

ie set the IP address, the ID of the tap (found in the mobile app) and declare a friendly name. The API doesnt supply any of that information unfortunately.

If anyone wants to have a go, let me know and ill pass on the details.

Is this using using the gateway even though it is HTTP?

Yeah. They have a local HTTP api.

I’d check it out. Is it on GitHub?

But why are you not just sending the following like linktap suggests in the manual?
{ "tag":"total_duration", "id": "{{ taplinkerId }}", "duration": {{ duration }} }

I haven’t tested it via hacs yet but in theory it should work if you add the repository.

DM me if you have any issues

Because it doesnt seem to work!
It sets the value — the value doesnt actually DO anything.

Its possible its device specific.

Their support team was really good, as i mentioned.
Their suggestion was to use the regular MQTT mode, which I did get working, but the setup was very complicated and lots of duplication.

So – Thats where the local HTTP integration came from.

I have just today switched over my MQTT implementation to the HTTP one.

That looks great. I will try to test it on the weekend.
I think the sensors volume units should be “L” and one could add the volume watering mode in the future.