TP Link Deco HACS Integration

Does anyone have a Tp Link integration?
Im getting an invalid authentication error when I put the password for configuring.

Though I’m putting the right password. Does this integration work for all decos? I have a deco x20 and it doesnt have a Web portal. The router can only be managed through the app. So maybe this is what’s causing the issue?

The purpose of this is so that I can track presence when my phone is connected to the router. It means I’m home. Are there any alternative ways.

Any help would be greatly appreciated

With my x20 I use the HA-TPLink-Deco custom integration which is available in HACS. It has worked reliably for me… it does, however, have a slightly convoluted login setup process

Never mind its working now, I think the problem was; I was using a complex password and it only accepts passwords below 20 characters

Do you know how I can set up a presence detection using the deco, so when my phone connects to the wifi, it can change the state to “home” or vice versa “away”

if you look at the integration, it should list the related entities. there should be a device_tracker.whatever for each connected device. this will change from home to away when you leave, and back to home when it re-connects

1 Like

Oo thanks Chris! That was easier than I thought.

1 Like

It seems the device tracker is not working properly. My phone was connected to the deco and the person tracking showed “home” but after turning off my phones wifi and disconnecting it from deco. The entity was still set to “home” rather than “away”. I waited for 5 minutes and still it did not chance.

However when I went to developer options and changed the device.tracker.phone entity to “not_home” Only then did the person tracking showed “away”

Any idea whats going on?

1 Like

Is the router-based device tracker the only one attached to the person entity?

Yes. Only the router based tracker

The only thing I can think of is that you may be running into this behavior based on Person vs. User.

How long does it take for your entity to change?
From home to not home when you disconnect your phone.

With “Seconds to wait…” set to 180, the device tracker switches to not_home after 3 minutes and the person entity immediately after that.

Did you check if your person entity has the Allow person to login option checked?

Yes I have allowed the login. But does it matter if login is allowed or not? I don’t see how this could be related.

If I decrease the time from 180 seconds to a lower number. Does it work faster? And if so whar are the drawbacks.

If “Allow person to login” is enabled, when you log in on a mobile app device, it attaches that mobile apps device tracker to the person logging in. So, it’s possible your testing method is being thwarted, because your phone’s GPS location ( or a tablet, etc) will still be reporting you as within the home zone. However, you should see that the device tracker has been added to the person entity…

If you want to do a quick test of the TP Link integration just create a test person entity, do not allow it to login, and add the phone’s router-based device tracker to it. Then repeat your “turn off the phone’s wifi” test.

It will register you as not_home sooner, but the drawback is false positive triggers of automations. It is very common for WiFi devices to fall off network every so often. Different devices will have their own settings for how long they wait to try to reconnect. If you set the “seconds to wait…” shorter than your device’s reconnect interval your person entity will occasionally switch from home to not_home, seemingly at random, and trigger any presence based automations you have.

Thanks for explaining Drew. I’ve managed to set it up and its working very well now!
Do you know how the notify on new entries works?

What changes do I need to make to the code for my case.

  • alias: Notify New Wifi Device
    mode: parallel
    max: 100
    trigger:
    • platform: event
      event_type: entity_registry_updated
      event_data:
      action: create
      variables:
      id: “{{ trigger.event.data.entity_id }}”
      condition:
    • condition: template
      value_template: “{{ id.split(’.’)[0] == ‘device_tracker’ }}”
    • condition: template
      value_template: “{{ id in integration_entities(‘tplink_deco’) }}”
      action:
    • alias: Wait a little while to make sure the entity has updated with new state
      wait_template: “{{ states(id) not in [‘unknown’, ‘unavailable’] }}”
      timeout:
      minutes: 1
    • service: notify.mobile_app_phone
      data:
      title: “{{ state_attr(id, ‘friendly_name’) or id }} connected to WiFi”
      message: >-
      {{ id }} connected to
      {{ state_attr(id, ‘interface’) }}
      {{
      state_attr(id, ‘connection_type’)
      | regex_replace(‘band’, ‘’)
      | regex_replace(’_’, ‘.’)
      | regex_replace(’$’, ‘G’)
      }}
      through
      {{ state_attr(id, ‘deco_device’) }}
      data:
      group: wifi-new-device
      clickAction: “entityId:{{ id }}”

The automation looks fine, but I couldn’t get it to trigger when adding new wifi devices.

The only thing I can see that you likely need to change is the notification service. Beyond that, there are a couple of tweaks that could be made to update the templates, but nothing critical.

Tweaked Automation
- alias: Notify New Wifi Device
  mode: parallel
  max: 100
  trigger:
    - platform: event
      event_type: entity_registry_updated
      event_data:
        action: create
  variables:
    id: "{{ trigger.event.data.entity_id }}"
  condition:
    - condition: template
      value_template: |
        {{ id is search('device_tracker.') and
        id in integration_entities('tplink_deco') }}
  action:
    - alias: Wait a little while to make sure the entity has updated with new state
      wait_template: "{{ not is_state(id, ['unknown', 'unavailable'] }}"
      timeout:
        minutes: 1
    - service: notify.mobile_app_#YOUR_DEVICE#
      data:
        title: "{{ states[id].name }} connected to WiFi"
        message: |
          {{ id }} connected to 
          {{- state_attr(id, 'interface') }}
          {{- state_attr(id, 'connection_type') | regex_replace('band', '')
              | regex_replace('_', '.') | regex_replace('$', 'G') }}
          through
          {{ state_attr(id, 'deco_device') }}
        data:
          group: wifi-new-device
          clickAction: "entityId:{{ id }}"

Yep it isnt working for me either. Like you said, I changed the entity of the phone in the automation. But when I register a new wifi device. Theres no notification message…