Building on this, and for whoever is interested, a few more sensors that tap into the RestAPI:
- platform: rest
name: wireguard
resource: http://a0d7b954-wireguard
json_attributes:
- PeterCellphone
- PeterLaptop
- PeterTablet
value_template: "OK"
- platform: template
sensors:
wireguard_petercellphone_status:
friendly_name: "Wireguard PeterCellphone Status"
value_template: >-
{% if state_attr('sensor.wireguard', 'PeterCellphone').latest_handshake > ( as_timestamp(now()) ) -180 %}
Connected
{% else %}
Disconnected
{% endif %}
wireguard_petercellphone_lastseen:
friendly_name: "Wireguard PeterCellphone Last Seen"
value_template: >-
{% if state_attr('sensor.wireguard', 'PeterCellphone').latest_handshake > ( 0 ) %}
{{ (state_attr('sensor.wireguard', 'PeterCellphone').latest_handshake ) | int | timestamp_custom('%d.%m.%Y, %H:%M') }}
{% else %}
N/A
{% endif %}
wireguard_petercellphone_tx:
friendly_name: "Wireguard PeterCellphone TX"
value_template: >-
{% if state_attr('sensor.wireguard', 'PeterCellphone').transfer_tx > ( 0 ) %}
{{ (state_attr('sensor.wireguard', 'PeterCellphone').transfer_tx ) | int | filesizeformat() }}
{% else %}
N/A
{% endif %}
wireguard_petercellphone_rx:
friendly_name: "Wireguard PeterCellphone RX"
value_template: >-
{% if state_attr('sensor.wireguard', 'PeterCellphone').transfer_rx > ( 0 ) %}
{{ (state_attr('sensor.wireguard', 'PeterCellphone').transfer_rx ) | int | filesizeformat() }}
{% else %}
N/A
{% endif %}
wireguard_peterlaptop_status:
friendly_name: "Wireguard PeterLaptop Status"
value_template: >-
{% if state_attr('sensor.wireguard', 'PeterLaptop').latest_handshake > ( as_timestamp(now()) ) -180 %}
Connected
{% else %}
Disconnected
{% endif %}
wireguard_peterlaptop_lastseen:
friendly_name: "Wireguard PeterLaptop Last Seen"
value_template: >-
{% if state_attr('sensor.wireguard', 'PeterLaptop').latest_handshake > ( 0 ) %}
{{ (state_attr('sensor.wireguard', 'PeterLaptop').latest_handshake ) | int | timestamp_custom('%d.%m.%Y, %H:%M') }}
{% else %}
N/A
{% endif %}
wireguard_peterlaptop_tx:
friendly_name: "Wireguard PeterLaptop TX"
value_template: >-
{% if state_attr('sensor.wireguard', 'PeterLaptop').transfer_tx > ( 0 ) %}
{{ (state_attr('sensor.wireguard', 'PeterLaptop').transfer_tx ) | int | filesizeformat() }}
{% else %}
N/A
{% endif %}
wireguard_peterlaptop_rx:
friendly_name: "Wireguard PeterLaptop RX"
value_template: >-
{% if state_attr('sensor.wireguard', 'PeterLaptop').transfer_rx > ( 0 ) %}
{{ (state_attr('sensor.wireguard', 'PeterLaptop').transfer_rx ) | int | filesizeformat() }}
{% else %}
N/A
{% endif %}
wireguard_petertablet_status:
friendly_name: "Wireguard PeterTablet Status"
value_template: >-
{% if state_attr('sensor.wireguard', 'PeterTablet').latest_handshake > ( as_timestamp(now()) ) -180 %}
Connected
{% else %}
Disconnected
{% endif %}
wireguard_petertablet_lastseen:
friendly_name: "Wireguard PeterTablet Last Seen"
value_template: >-
{% if state_attr('sensor.wireguard', 'PeterTablet').latest_handshake > ( 0 ) %}
{{ (state_attr('sensor.wireguard', 'PeterTablet').latest_handshake ) | int | timestamp_custom('%d.%m.%Y, %H:%M') }}
{% else %}
N/A
{% endif %}
wireguard_petertablet_tx:
friendly_name: "Wireguard PeterTablet TX"
value_template: >-
{% if state_attr('sensor.wireguard', 'PeterTablet').transfer_tx > ( 0 ) %}
{{ (state_attr('sensor.wireguard', 'PeterTablet').transfer_tx ) | int | filesizeformat() }}
{% else %}
N/A
{% endif %}
wireguard_petertablet_rx:
friendly_name: "Wireguard PeterTablet RX"
value_template: >-
{% if state_attr('sensor.wireguard', 'PeterTablet').transfer_rx > ( 0 ) %}
{{ (state_attr('sensor.wireguard', 'PeterTablet').transfer_rx ) | int | filesizeformat() }}
{% else %}
N/A
{% endif %}
Then you’ll have all sensors available to plug them into a card or such:
type: vertical-stack
cards:
- type: entities
entities:
- entity: sensor.wireguard_petercellphone_status
name: 'Status:'
icon: mdi:lock
- entity: sensor.wireguard_petercellphone_lastseen
name: 'Last Handshake:'
- entity: sensor.wireguard_petercellphone_tx
name: 'Transmitted:'
icon: mdi:upload-lock
- entity: sensor.wireguard_petercellphone_rx
name: 'Received:'
icon: mdi:download-lock
title: Peter Cellphone
- type: entities
entities:
- entity: sensor.wireguard_peterlaptop_status
name: 'Status:'
icon: mdi:lock
- entity: sensor.wireguard_peterlaptop_lastseen
name: 'Last Handshake:'
- entity: sensor.wireguard_peterlaptop_tx
name: 'Transmitted:'
icon: mdi:upload-lock
- entity: sensor.wireguard_peterlaptop_rx
name: 'Received:'
icon: mdi:download-lock
title: Peter Laptop
- type: entities
entities:
- entity: sensor.wireguard_petertablet_status
name: 'Status:'
icon: mdi:lock
- entity: sensor.wireguard_petertablet_lastseen
name: 'Last Handshake:'
- entity: sensor.wireguard_petertablet_tx
name: 'Transmitted:'
icon: mdi:upload-lock
- entity: sensor.wireguard_petertablet_rx
name: 'Received:'
icon: mdi:download-lock
title: Peter Tablet