Home Assistant Community Add-on: WireGuard

Hi all,

just tried to use the Wireguard Rest-Api to show the connection status of my devices.
Maybe someone is interested in this:

To get the data of my devices I us the a rest api sensor:

platform: rest
name: wireguard
resource: http://a0d7b954_wireguard
json_attributes:
- client01
- client02
value_template: "OK"

(Where client01 and client02 are the names defined for your wireguard peers)

To render the connection status I use the following template sensor for each device:

platform: template
sensors:
  wireguard_client01:
    friendly_name: "Wireguard Client01"
    value_template: >-
        {% if state_attr('sensor.wireguard', 'client01').latest_handshake > ( as_timestamp(now()) ) -180 %}
            Connected
          {% else %}
            Disconnected
          {% endif %}

Assumption: A Client is disconnected when there was no handshake in the last 3 minutes.

Please let me know what you think, input is more than welcome.

8 Likes