Send wireguard client info to HA with mqtt + template sensor to show active clients

Thanks for the link. I am using this in a slightly changed version:

...

sensor:
- platform: rest
    name: WireGuard peers status API
    resource: http://a0d7b954-wireguard
    value_template: "OK"
    json_attributes:
      - peer00
      - peer01
...

template:
  - binary_sensor:
      - name: WireGuard Peer peer00
        state: "{{ state_attr('sensor.wireguard_peers_status_api', 'peer00').latest_handshake > as_timestamp(now()) - 180 }}"
      - name: WireGuard Peer peer01
        state: "{{ state_attr('sensor.wireguard_peers_status_api', 'peer01').latest_handshake > as_timestamp(now()) - 180 }}"

(Edit: Had used the endpoint attribute checked against "(none)" before, but this apparently never resets…)

1 Like