Is there a TP-Link Powerline monitoring tool ? (TP-Link tpPLC for HA ?)

I have various TP-Link Powerline device (AV500/600/100/2000) and in Windows I can monitor rates between them and set LED’s etc from within their Windows tpPLC program, I can also do similar from within their Android tpPLC app. e.g.
Download for TL-WPA8630P KIT | TP-Link United Kingdom for a similar current device, but the software and apps are the same.

I’ve searched the forum for powerline and tplink/tp-link variations but nothing crops up, just questions asking for nice ones to use.
I cannot see anything on github HA either.
or HACS.

Any nudge to where something may be or if there is a generic powerline feature, I can’t believe I’m the only one to want to monitor their powerlines rates and data log, automate failure etc.

:slight_smile:

Running HA-OS
Home Assistant 2021.9.5 rpi3-64

7 Likes

Would also be interested if such an integration was made available.

2 Likes

I’m interested, this devices are bases on same Qualcomm chip’s,
even other brand devices use same protocol.

I am using the P9 Deco mesh that has both wifi and Powerline mesh. I’d be very interested to get scrutiny on the powerline connections between the boxes, but even in the tplink app the reported information is rather fuzzy and unstable.
I think their P9 firmware (and I even tried the latest beta version found on forums) is not finalised (and will never be as the product is obsolete now), it works but is not great, so monitoring was not the priority and never will be…

1 Like

Throwing out a few resources I came across in case it helps push this forward…

Using Python to connect to PowerLine adapters

Wireshark Packet definitions for PowerLine

1 Like

I’ll have a look. :slight_smile: though I’ve almost stopped using my power lines since I have a Mesh setup doing the job and I put a few lines of ethernet cable down to link them too.
But for my longer runs during the summer in the sheds…

I know that I’m being relatively useless in this response but I managed to get a setup going reporting from an rpi feeding data back to hassio. I repurposed the rpi and… might be able to find the scripts but I did keep lots of notes that I am willing to share. It wasn’t difficult in the end, just took a little bit of time to figure the tools out. I switched network monitoring over to an instance of NMIS with ping plots and SNMP on the end-devices and that was more value than powerline monitoring.

1 Like

I too have a TP-Link Powerline AV2000 and I am looking for a way to monitor the data rates in Home Assistant.
Has anyone heard of updates on this, since these older posts?

I did not find any either, so I made one myself using openplc tools and a script which parses openplc output and publishes it on the MQTT broker.

I run a custom script every 60 seconds through the Advanced SSH and Web terminal HA addon: (second line)
image
under my HA config folder I added a shell map where I placed following openplc_ha.sh script and files:

interface is my HA ethernet network port name (my HA crashed last week and I just noticed on reinstalling from a backup, network name changed, so it could not find it, I run HA on a ESXi host)
p is where my files are located

#!/bin/bash

# run thiq script in the SSH/Web addon : add an initial script:
# while [ 1 = 1 ]; do bash /config/shell/openplc_ha.sh && sleep 60; done &

# use dos2unix openplc_ha.sh to remove unwanted <CR> from windows <CR><LF>, only <LF> in Linux

interface="enp2s1"
p="/config/shell"

# Look for PLC devices
plcstat_output=$(/config/shell/plcstat -t -i "$interface" | tail -n +2)

#example output of plcstat -t -i 3
# P/L NET TEI ------ MAC ------ ------ BDA ------  TX  RX CHIPSET FIRMWARE
# LOC STA 001 18:A6:F7:57:B6:AA 38:F3:AB:39:40:BC n/a n/a QCA7500 MAC-QCA7500-2.13.0.30-01-20221117-CS
# REM STA 002 84:16:F9:F3:C4:2D 2C:A5:9C:EC:E8:8F 041 053 QCA7500 MAC-QCA7550-2.13.0.30-01-20221117-CS
# REM CCO 006 18:A6:F7:A2:3D:74 24:A1:60:37:86:58 073 045 QCA7500 MAC-QCA7500-2.13.0.30-01-20221117-CS
# REM STA 013 84:16:F9:F3:BF:28 7C:64:56:F7:BC:A9 227 299 QCA7500 MAC-QCA7550-2.13.0.30-01-20221117-CS

# Run plcstat to update tplink.network file
while IFS= read -r line; do
    type=$(/bin/echo "$line" | /usr/bin/awk '{print $1}')
    mac=$(/bin/echo "$line" | /usr/bin/awk '{print $4}')
    bda=$(/bin/echo "$line" | /usr/bin/awk '{print $5}')
    tx=$(/bin/echo "$line" | /usr/bin/awk '{print $6}')
    rx=$(/bin/echo "$line" | /usr/bin/awk '{print $7}')
    chipset=$(/bin/echo "$line" | /usr/bin/awk '{print $8}')
    firmware=$(/bin/echo "$line" | /usr/bin/awk '{print $9}')
    case "$mac" in
	  "18:A6:F7:57:B6:AA")
        # Powerline adapter 1
		friendly_name="tpver_801191_180709_915"
		model="TL-PA8010P-V1"
        location="Garage"
        ;;
      "84:16:F9:F3:C4:2D")
        # Powerline adapter 2
		friendly_name="tpver_803112_170426_903_1"
		model="TL-PA8030P-V2"
        location="Storage"
        ;;
      "18:A6:F7:A2:3D:74")
        # Powerline adapter loods Wifi 3
		friendly_name="tpver_863011_180723_002"
		model="TL-WPA8630-V1"
        location="Storage"
        ;;
      "84:16:F9:F3:BF:28")
        # Powerline adapter 4
		friendly_name="tpver_803112_170426_903_2"
		model="TL-PA8030P-V2"
        location="Living Room"
        ;;
      *)
        # Add your default text when Powerline MAC unknown
		friendly_name="Unknown"
		model="Unknown"
        location="Unknown"
        ;;
	esac
	
    plctool_output=$(/config/shell/plctool -I -i "$interface" "$mac")

    # Append unique MAC addresses (excluding the first line) to the tplink.network file
    # Create a temporary file
    tmp_file=$(mktemp)

    # Exclude the line containing the specific value and write the result to the temporary file
    /bin/grep -v -E "^[[:space:]]*$" "$p/tplink.network" | /bin/grep -v "$mac" > "$tmp_file"

    # Overwrite the original file with the modified content
    /bin/mv "$tmp_file" "$p/tplink.network"

    # Append unique MAC addresses (excluding the first line) to the tplink.network file
#    echo "$mac $friendly_name $type" >> "$p/tplink.network"
    /bin/echo "$mac $friendly_name $type $chipset $firmware $model $location" >> "$p/tplink.network"

done <<< "$plcstat_output"

# Run the plcstat command and process the output
while IFS=" " read -r mac friendly_name type chipset firmware model location; do
    # -I: read device identity using VS_MODULE_OPERATION, redirect error output to black hole with 2>/dev/null
	plctool_output=$(/config/shell/plctool -I -i "$interface" "$mac" 2>/dev/null)

    # Extracting type, tx, and rx values from plcstat output
    line=$(/bin/echo "$plcstat_output" | /usr/bin/awk -v mac="$mac" '$0 ~ mac { print $0 }')

    if [ -z "$line" ]; then
        # Plug is offline
        status="off"
    else
        # Plug is online
        status="on"
        read -r type _ _ _ _ tx rx _ <<< "$line"
    fi

    # Generate sensor name by removing unauthorized characters from friendly_name
    sensor_name=$(/bin/echo "$friendly_name" | /usr/bin/tr -cd '[:alnum:]-_')

    # onstate state --------------------------------------------------------------------------------------------------------------------------------------
    # Publish the sensor state to the MQTT state topic
    /usr/bin/mosquitto_pub -h localhost -u username -P password -t homeassistant/sensor/$sensor_name/onstate/state -m "$status"

    # onstate config -------------------------------------------------------------------------------------------------------------------------------------
    # Create the JSON payload for MQTT Discovery configuration
    json_payload=$(jq -n --arg sensor_name "$sensor_name" --arg status "$status" --arg type "$type" --arg friendly_name "$friendly_name" \
       '{"name": "onstate",
         "state_topic": "homeassistant/sensor/'$sensor_name'/onstate/state",
         "icon": "mdi:lan-connect",
         "unique_id": "'$sensor_name'_onstate",
         "device": {"identifiers": ["'$mac'"],
                    "name": "'$friendly_name'",
                    "model": "'$model'",
                    "sw_version": "'$firmware'",
                    "hw_version": "'$chipset'",
                    "suggested_area": "'$location'",
                    "manufacturer": "TPLINK"
                   },
         "json_attributes_topic": "homeassistant/sensor/'$sensor_name'/attributes",
         "json_attributes_template": "{{ value_json.data.value | tojson }}"
       }')
    # Publish the MQTT Discovery configuration to the appropriate topic
    /usr/bin/mosquitto_pub -h localhost -u username -P password -t homeassistant/sensor/$sensor_name/onstate/config -m "$json_payload"

    # TX state --------------------------------------------------------------------------------------------------------------------------------------
    # Check if tx is a numeric value
    if [[ $tx =~ ^[0-9]+$ ]]; then
        /usr/bin/mosquitto_pub -h localhost -u username -P password -t "homeassistant/sensor/$sensor_name/tx/state" -m "$tx"
    fi

    # TX config --------------------------------------------------------------------------------------------------------------------------------------
    json_payload=$(jq -n --arg sensor_name "$sensor_name" --arg status "$status" --arg type "$type" --arg friendly_name "$friendly_name" \
       '{"name": "TX",
         "state_topic": "homeassistant/sensor/'$sensor_name'/tx/state",
         "state_class": "measurement",
         "device_class": "data_rate",
         "unit_of_measurement": "MB/s",
         "unique_id": "'$sensor_name'_tx",
         "device": {"identifiers": ["'$mac'"],
                    "name": "'$friendly_name'",
                    "model": "'$model'",
                    "sw_version": "'$firmware'",
                    "hw_version": "'$chipset'",
                    "suggested_area": "'$location'",
                    "manufacturer": "TPLINK"
                   }
       }')
    # Publish the MQTT Discovery configuration to the appropriate topic
    /usr/bin/mosquitto_pub -h localhost -u username -P password -t homeassistant/sensor/$sensor_name/tx/config -m "$json_payload"

    # RX state --------------------------------------------------------------------------------------------------------------------------------------
    # Check if rx is a numeric value
    if [[ $rx =~ ^[0-9]+$ ]]; then
        /usr/bin/mosquitto_pub -h localhost -u username -P password -t "homeassistant/sensor/$sensor_name/rx/state" -m "$rx"
    fi

    # RX config --------------------------------------------------------------------------------------------------------------------------------------
    json_payload=$(jq -n --arg sensor_name "$sensor_name" --arg status "$status" --arg type "$type" --arg friendly_name "$friendly_name" \
       '{"name": "RX",
         "state_topic": "homeassistant/sensor/'$sensor_name'/rx/state",
         "state_class": "measurement",
         "device_class": "data_rate",
         "unit_of_measurement": "MB/s",
         "unique_id": "'$sensor_name'_rx",
         "device": {"identifiers": ["'$mac'"],
                    "name": "'$friendly_name'",
                    "model": "'$model'",
                    "sw_version": "'$firmware'",
                    "hw_version": "'$chipset'",
                    "suggested_area": "'$location'",
                    "manufacturer": "TPLINK"
                   }
       }')
    # Publish the MQTT Discovery configuration to the appropriate topic
    /usr/bin/mosquitto_pub -h localhost -u username -P password -t homeassistant/sensor/$sensor_name/rx/config -m "$json_payload"

done < "$p/tplink.network"

I downloaded the openplc linux binaries from here: Example for a SLAC Association with the INSYS Powerline GP

3 Likes

Hi!

Nice script and implementation, but I could not find the working plctool and plcstat binaries that you downloaded from the external link.

Could you share them directly here?

Thank you!!!

Picking up on this topic: I just built an integration that can do this! I ported pla-utils to python and then integrated it into homeassistant, so that it does not depend on any external dependencies. It’s pretty rudimentary and might not be stable, but you can check it out here:

let me know if you encounter any issues!

1 Like

Thanks. I just installed it and it seems to work well.
Only thing is that you probably need to update the install instructions as it doesn’t appear as HomePlug-AV but as Powerline Stats.

1 Like

thanks for reporting! I have updated the name to homeplug-av everywhere. (powerline stats was the working title for the project)

Works like a charm - thanks! <3

1 Like

hey I just tried your integration but can’t get it to work.
if I add it, I get following IP ports and I selected enp3s0 (with HA IP 192.168.178.20).
But the integration can’t seem to find any PowerLAN adapters.

I also tried the other LAN adapters, but enp3s0 is the right one. (ESXi).
Maybe it’s because I reflashed my TPLink PowerLAN’s with other more rescent PowerLAN firmware (CHIPSET: QCA7500 firmware: MAC-QCA7500-2.13.0.30-01-20221117-CS) .
Strange because my scripts (see a couple of posts above) do work and return info with PLCstat tools (openPLC).

also when i try to “configure” an existing entry I get error :

to debug this further: could you check if your adapters are discovered by pla_util?
My Integration uses the same protocol.

according to this: Powerline Connection Speed Monitoring via pla-util · peanball.net

pla_util is for Broadcom chipset based powerline adapters, while my TPLink Powerline adapters are Qualcomm Atheros chipset based powerline adapters. Mine work with open-plc-utils.
So maybe that’s the problem ?

Hi! I wonder if someone could help me out a bit with this. I am using a TP-Link PA9020 kit , which should be supported by pla_util. I have installed the Homeplug AV integration to scan eno1 (actually I have tried every interface available) but I also get the same error as monty above!

I have tried to install and run the pla_utils from within the homeplug_av directories. It runs but does not display any result.

From the HA debug i get:

TypeError: HomeplugAVConfigFlow.async_get_options_flow() missing 1 required positional argument: ‘config_entry’

Can anyone help me get this working?

I should say that I run HA in a docker compose environment!!!

Same here… :frowning:

Home assistant over Proxmox