Found better way to get PiHole versions

This commit is contained in:
Burningstone91
2020-10-08 18:47:38 +02:00
parent c5230454ee
commit 0888f41302
4 changed files with 142 additions and 44 deletions

View File

@@ -2094,12 +2094,12 @@ Add the following in the `sensor:` section of the system_monitoring.yaml file:\
Installed:
```yaml
- platform: version
name: HASS Installed
name: current_version_homeassistant
```
Latest(example for docker install, showing beta versions):
```yaml
- platform: version
name: HASS Available
name: latest_version_homeassistant
source: docker
beta: true
```
@@ -2112,7 +2112,7 @@ Add the following in the `sensor:` section of the system_monitoring.yaml file:
```yaml
- platform: command_line
name: AppDaemon Available
name: latest_version_appdaemon
command: >-
curl -L
-H "User-Agent: Home Assistant"
@@ -2127,24 +2127,51 @@ To get the installed version:
Restart Home Assistant.
#### PiHole
To get the installed and latest available version of Pi Hole we can use the [command line sensor integration](https://www.home-assistant.io/integrations/sensor.command_line/). Before creating the sensor, make sure that you copied the SSH keys (as describted [here](#create-and-distribute-ssh-keys)) from the machine running Home Assistant to the machine running PiHole.
To get the installed and latest available version of Pi Hole we can use the [rest sensor integration](https://www.home-assistant.io/integrations/rest/).
Add the following in the `sensor:` section of the system_monitoring.yaml file:\
Installed:
Core Installed:
```yaml
- platform: command_line
name: current_version_pi_hole
command: 'ssh -i /root/.ssh/id_rsa -o StrictHostKeyChecking=no -q pi@10.10.0.8 pihole -v -p -c | grep -Po "\d.\d.\d"'
scan_interval: 3600
- platform: rest
resource: http://10.10.0.8/admin/api.php?versions
name: current_version_pihole_core
value_template: "{{ value_json.core_current[1:] }}"
```
Latest:
Core Latest:
```yaml
- platform: command_line
name: latest_version_pi_hole
command: 'ssh -i /root/.ssh/id_rsa -o StrictHostKeyChecking=no -q pi@10.10.0.8 pihole -v -p -l | grep -Po "\d.\d.\d"'
scan_interval: 3600
- platform: rest
resource: http://10.10.0.8/admin/api.php?versions
name: latest_version_pihole_core
value_template: "{{ value_json.core_latest[1:] }}"
```
Web Installed:
```yaml
- platform: rest
resource: http://10.10.0.8/admin/api.php?versions
name: current_version_pihole_core
value_template: "{{ value_json.core_current[1:] }}"
```
Web Latest:
```yaml
- platform: rest
resource: http://10.10.0.8/admin/api.php?versions
name: current_version_pihole_web
value_template: "{{ value_json.web_current[1:] }}"
```
FTL Installed:
```yaml
- platform: rest
resource: http://10.10.0.8/admin/api.php?versions
name: current_version_pihole_ftl
value_template: "{{ value_json.FTL_current[1:] }}"
```
FTL Latest:
```yaml
- platform: rest
resource: http://10.10.0.8/admin/api.php?versions
name: latest_version_pihole_ftl
value_template: "{{ value_json.FTL_latest[1:] }}"
```
In the `command` field in the part `root@10.10.40.6`, replace root with the username used to SSH into the machine running PiHole and 10.10.40.6 with the IP of the machine running PiHole.
Restart Home Assistant.

View File

@@ -548,10 +548,10 @@ views:
- type: markdown
content: >
<center>
<h5>Installed:
{{ states('sensor.hass_installed') }}<br>
Newest:
{{ states('sensor.hass_available') }}</h5>
<h5>Current:
{{ states('sensor.current_version_homeassistant') }}<br>
Latest:
{{ states('sensor.latest_version_homeassistant') }}</h5>
</center>
style: |
ha-card {
@@ -1050,7 +1050,7 @@ views:
- type: markdown
content: >
<center>
<img width="50" src="https://upload.wikimedia.org/wikipedia/commons/6/6e/Home_Assistant_Logo.svg">
<img width="50" src="https://github.com/AppDaemon/appdaemon/blob/dev/appdaemon/assets/images/android-chrome-512x512.png?raw=true">
</center>
style: |
ha-card {
@@ -1060,10 +1060,10 @@ views:
- type: markdown
content: >
<center>
<h5>Installed:
<h5>Current:
{{ states('sensor.docker_appdaemon_image').split(':')[1] }}<br>
Newest:
{{ states('sensor.appdaemon_available') }}</h5>
Latest:
{{ states('sensor.latest_version_appdaemon') }}</h5>
</center>
style: |
ha-card {
@@ -3153,16 +3153,67 @@ views:
margin-top: 15.5px;
}
####################################################
# Unavailable #
# Versions #
####################################################
- type: 'custom:auto-entities'
show_empty: false
card:
type: entities
show_header_toggle: false
filter:
include:
- state: unavailable
- type: entities
entities:
- entity: sensor.current_version_pihole_core
type: custom:multiple-entity-row
name: Pi Hole Core
show_state: false
entities:
- entity: sensor.current_version_pihole_core
name: Installed
- entity: sensor.latest_version_pihole_core
name: Latest
- entity: sensor.current_version_pihole_core
type: custom:multiple-entity-row
name: Pi Hole Web
show_state: false
entities:
- entity: sensor.current_version_pihole_web
name: Installed
- entity: sensor.latest_version_pihole_web
name: Latest
- entity: sensor.current_version_pihole_core
type: custom:multiple-entity-row
name: Pi Hole FTL
show_state: false
entities:
- entity: sensor.current_version_pihole_ftl
name: Installed
- entity: sensor.latest_version_pihole_ftl
name: Latest
####################################################
# Network Throghput #
####################################################
- type: vertical-stack
cards:
# WAN In
- type: custom:mini-graph-card
name: Ads Blocked Today
icon: mdi:network
entities:
- sensor.pi_hole_ads_blocked_today
height: 40
line_width: 2
font_size: 70
hours_to_show: 168
points_per_hour: 1
show:
extrema: false
fill: true
state: false
legend: false
style: |
ha-card {
--paper-item-icon-color: rgb(47,186,229);
margin-top: 5px;
margin-bottom: 10px;
height: 80px;
margin-right: 20px;
margin-left: 20px;
}
####################################################
# #
# Unifi Router #

View File

@@ -35,6 +35,7 @@ recorder:
- light.office
- media_player.buero_musik_main
- media_player.receiver_livingroom
- sensor.pi_hole_ads_blocked_today
history:

View File

@@ -127,14 +127,14 @@ sensor:
####################
# Home Assistant
- platform: version
name: HASS Available
name: latest_version_homeassistant
source: docker
beta: true
- platform: version
name: HASS Installed
name: current_version_homeassistant
# AppDaemon
- platform: command_line
name: AppDaemon Available
name: latest_version_appdaemon
command: >-
curl -L
-H "User-Agent: Home Assistant"
@@ -143,15 +143,34 @@ sensor:
value_template: '{{ value_json.info.version }}'
scan_interval: 3600
# Pi-hole
- platform: command_line
name: current_version_pi_hole
command: 'ssh -i /root/.ssh/id_rsa -o StrictHostKeyChecking=no -q pi@10.10.0.8 pihole -v -p -c | grep -Po "\d.\d.\d"'
scan_interval: 3600
- platform: command_line
name: latest_version_pi_hole
command: 'ssh -i /root/.ssh/id_rsa -o StrictHostKeyChecking=no -q pi@10.10.0.8 pihole -v -p -l | grep -Po "\d.\d.\d"'
scan_interval: 3600
# Mosquitto
## Pi-hole Core
- platform: rest
resource: http://10.10.0.8/admin/api.php?versions
name: latest_version_pihole_core
value_template: "{{ value_json.core_latest[1:] }}"
- platform: rest
resource: http://10.10.0.8/admin/api.php?versions
name: current_version_pihole_core
value_template: "{{ value_json.core_current[1:] }}"
## Pi-hole Web
- platform: rest
resource: http://10.10.0.8/admin/api.php?versions
name: latest_version_pihole_web
value_template: "{{ value_json.web_latest[1:] }}"
- platform: rest
resource: http://10.10.0.8/admin/api.php?versions
name: current_version_pihole_web
value_template: "{{ value_json.web_current[1:] }}"
## Pi-hole FTL
- platform: rest
resource: http://10.10.0.8/admin/api.php?versions
name: latest_version_pihole_ftl
value_template: "{{ value_json.FTL_latest[1:] }}"
- platform: rest
resource: http://10.10.0.8/admin/api.php?versions
name: current_version_pihole_ftl
value_template: "{{ value_json.FTL_current[1:] }}"
# Mosquitto
- platform: mqtt
state_topic: "docker-image-updates/mosquitto"
name: Update Mosquitto