mirror of
https://github.com/skalavala/mysmarthome.git
synced 2025-08-28 16:57:02 +00:00
micor changes and clean up.
This commit is contained in:
@@ -2,17 +2,17 @@
|
||||
# @author : Mahasri Kalavala
|
||||
# @date : 12/27/2017
|
||||
# @package : Pi Admin Package
|
||||
# @description : Got way too many Raspberry Pi's and this package is to
|
||||
# @description : Got way too many Raspberry Pi's and this package is to
|
||||
# help me with managing them via Home Assistant.
|
||||
#
|
||||
# How Does It Work?
|
||||
#
|
||||
# Each Raspberry Pi runs a service (a python program) locally that listens for
|
||||
# commands via MQTT on a pre-defined topic. This package publishes commands
|
||||
# Each Raspberry Pi runs a service (a python program) locally that listens for
|
||||
# commands via MQTT on a pre-defined topic. This package publishes commands
|
||||
# to MQTT requesting each Raspberry Pi to respond and or return data.
|
||||
# When the responses are received (on a differet topic), the sensors gets
|
||||
# When the responses are received (on a differet topic), the sensors gets
|
||||
# updated automatically and are displayed.
|
||||
#
|
||||
#
|
||||
################################################################################
|
||||
|
||||
homeassistant:
|
||||
@@ -32,32 +32,31 @@ input_select:
|
||||
raspberry_pis:
|
||||
name: All Raspberry Pis
|
||||
options:
|
||||
- Select One
|
||||
- pi_basement
|
||||
- pi_theater
|
||||
- pi_kitchen
|
||||
- pi_familyroom
|
||||
- pi_frontroom
|
||||
- pi_garage
|
||||
- pi_guest1
|
||||
- pi_guest2
|
||||
- pi_masterbedroom
|
||||
- Select One
|
||||
- pi_basement
|
||||
- pi_theater
|
||||
- pi_kitchen
|
||||
- pi_familyroom
|
||||
- pi_frontroom
|
||||
- pi_garage
|
||||
- pi_guest1
|
||||
- pi_guest2
|
||||
- pi_masterbedroom
|
||||
initial: Select One
|
||||
icon: mdi:pig
|
||||
|
||||
rpi_commands:
|
||||
name: RPi Commands
|
||||
options:
|
||||
- Select One
|
||||
- Restart Server
|
||||
- Shutdown
|
||||
- Restart Snapcast
|
||||
- Select One
|
||||
- Restart Server
|
||||
- Shutdown
|
||||
- Restart Snapcast
|
||||
initial: Select One
|
||||
icon: mdi:pig
|
||||
|
||||
sensor:
|
||||
|
||||
## WiFi Information related sensors
|
||||
## WiFi Information related sensors
|
||||
- platform: mqtt
|
||||
state_topic: "/wifi/pi_basement"
|
||||
name: Basement Pi Signal Level
|
||||
@@ -67,7 +66,7 @@ sensor:
|
||||
state_topic: "/wifi/pi_basement"
|
||||
name: Basement Pi Link Quality
|
||||
value_template: '{{ value_json["Link Quality"]}}'
|
||||
|
||||
|
||||
- platform: mqtt
|
||||
state_topic: "/wifi/pi_theater"
|
||||
name: Theater Pi Signal Level
|
||||
@@ -77,7 +76,7 @@ sensor:
|
||||
state_topic: "/wifi/pi_theater"
|
||||
name: Theater Pi Link Quality
|
||||
value_template: '{{ value_json["Link Quality"]}}'
|
||||
|
||||
|
||||
- platform: mqtt
|
||||
state_topic: "/wifi/pi_kitchen"
|
||||
name: Kitchen Pi Signal Level
|
||||
@@ -148,7 +147,7 @@ sensor:
|
||||
name: Master Bedroom Pi Link Quality
|
||||
value_template: '{{ value_json["Link Quality"]}}'
|
||||
|
||||
## Disk Information related Sensors
|
||||
## Disk Information related Sensors
|
||||
- platform: mqtt
|
||||
state_topic: "/disk/pi_basement"
|
||||
name: Basement Pi Available Disk
|
||||
@@ -157,7 +156,7 @@ sensor:
|
||||
state_topic: "/disk/pi_basement"
|
||||
name: Basement Pi Disk Used
|
||||
value_template: '{{ value_json["% Used"]}}'
|
||||
|
||||
|
||||
- platform: mqtt
|
||||
state_topic: "/disk/pi_theater"
|
||||
name: Theater Pi Available Disk
|
||||
@@ -166,7 +165,7 @@ sensor:
|
||||
state_topic: "/disk/pi_theater"
|
||||
name: Theater Pi Disk Used
|
||||
value_template: '{{ value_json["% Used"]}}'
|
||||
|
||||
|
||||
- platform: mqtt
|
||||
state_topic: "/disk/pi_kitchen"
|
||||
name: Kitchen Pi Available Disk
|
||||
@@ -235,47 +234,47 @@ script:
|
||||
sequence:
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_basement'
|
||||
topic: "/server/pi_basement"
|
||||
payload: CMD_REBOOT_PI
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_theater'
|
||||
topic: "/server/pi_theater"
|
||||
payload: CMD_REBOOT_PI
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_kitchen'
|
||||
topic: "/server/pi_kitchen"
|
||||
payload: CMD_REBOOT_PI
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_familyroom'
|
||||
topic: "/server/pi_familyroom"
|
||||
payload: CMD_REBOOT_PI
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_frontroom'
|
||||
topic: "/server/pi_frontroom"
|
||||
payload: CMD_REBOOT_PI
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_garage'
|
||||
topic: "/server/pi_garage"
|
||||
payload: CMD_REBOOT_PI
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_guest1'
|
||||
topic: "/server/pi_guest1"
|
||||
payload: CMD_REBOOT_PI
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_guest2'
|
||||
topic: "/server/pi_guest2"
|
||||
payload: CMD_REBOOT_PI
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_masterbedroom'
|
||||
topic: "/server/pi_masterbedroom"
|
||||
payload: CMD_REBOOT_PI
|
||||
retain: false
|
||||
|
||||
@@ -283,47 +282,47 @@ script:
|
||||
sequence:
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_basement'
|
||||
topic: "/server/pi_basement"
|
||||
payload: CMD_RESTART_SNAPCLIENT
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_theater'
|
||||
topic: "/server/pi_theater"
|
||||
payload: CMD_RESTART_SNAPCLIENT
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_kitchen'
|
||||
topic: "/server/pi_kitchen"
|
||||
payload: CMD_RESTART_SNAPCLIENT
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_familyroom'
|
||||
topic: "/server/pi_familyroom"
|
||||
payload: CMD_RESTART_SNAPCLIENT
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_frontroom'
|
||||
topic: "/server/pi_frontroom"
|
||||
payload: CMD_RESTART_SNAPCLIENT
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_garage'
|
||||
topic: "/server/pi_garage"
|
||||
payload: CMD_RESTART_SNAPCLIENT
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_guest1'
|
||||
topic: "/server/pi_guest1"
|
||||
payload: CMD_RESTART_SNAPCLIENT
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_guest2'
|
||||
topic: "/server/pi_guest2"
|
||||
payload: CMD_RESTART_SNAPCLIENT
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_masterbedroom'
|
||||
topic: "/server/pi_masterbedroom"
|
||||
payload: CMD_RESTART_SNAPCLIENT
|
||||
retain: false
|
||||
|
||||
@@ -331,204 +330,203 @@ script:
|
||||
sequence:
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_basement'
|
||||
topic: "/server/pi_basement"
|
||||
payload: CMD_SHUTDOWN_PI
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_theater'
|
||||
topic: "/server/pi_theater"
|
||||
payload: CMD_SHUTDOWN_PI
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_kitchen'
|
||||
topic: "/server/pi_kitchen"
|
||||
payload: CMD_SHUTDOWN_PI
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_familyroom'
|
||||
topic: "/server/pi_familyroom"
|
||||
payload: CMD_SHUTDOWN_PI
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_frontroom'
|
||||
topic: "/server/pi_frontroom"
|
||||
payload: CMD_SHUTDOWN_PI
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_garage'
|
||||
topic: "/server/pi_garage"
|
||||
payload: CMD_SHUTDOWN_PI
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_guest1'
|
||||
topic: "/server/pi_guest1"
|
||||
payload: CMD_SHUTDOWN_PI
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_guest2'
|
||||
topic: "/server/pi_guest2"
|
||||
payload: CMD_SHUTDOWN_PI
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data_template:
|
||||
topic: '/server/pi_masterbedroom'
|
||||
topic: "/server/pi_masterbedroom"
|
||||
payload: CMD_SHUTDOWN_PI
|
||||
retain: false
|
||||
|
||||
# Script to Query Disk Information - Publishes message 'CMD_REPORT_WIFI_DETAILS'
|
||||
# to MQTT, so that the message gets received by individual Raspberry Pi
|
||||
###############################################################################
|
||||
# Script to Query Disk Information - Publishes message 'CMD_REPORT_WIFI_DETAILS'
|
||||
# to MQTT, so that the message gets received by individual Raspberry Pi
|
||||
###############################################################################
|
||||
query_wifi_info:
|
||||
sequence:
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
topic: /server/pi_basement
|
||||
payload: 'CMD_REPORT_WIFI_DETAILS'
|
||||
payload: "CMD_REPORT_WIFI_DETAILS"
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
topic: /server/pi_theater
|
||||
payload: 'CMD_REPORT_WIFI_DETAILS'
|
||||
payload: "CMD_REPORT_WIFI_DETAILS"
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
topic: /server/pi_kitchen
|
||||
payload: 'CMD_REPORT_WIFI_DETAILS'
|
||||
payload: "CMD_REPORT_WIFI_DETAILS"
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
topic: /server/pi_familyroom
|
||||
payload: 'CMD_REPORT_WIFI_DETAILS'
|
||||
payload: "CMD_REPORT_WIFI_DETAILS"
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
topic: /server/pi_frontroom
|
||||
payload: 'CMD_REPORT_WIFI_DETAILS'
|
||||
payload: "CMD_REPORT_WIFI_DETAILS"
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
topic: /server/pi_garage
|
||||
payload: 'CMD_REPORT_WIFI_DETAILS'
|
||||
payload: "CMD_REPORT_WIFI_DETAILS"
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
topic: /server/pi_guest1
|
||||
payload: 'CMD_REPORT_WIFI_DETAILS'
|
||||
payload: "CMD_REPORT_WIFI_DETAILS"
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
topic: /server/pi_guest2
|
||||
payload: 'CMD_REPORT_WIFI_DETAILS'
|
||||
payload: "CMD_REPORT_WIFI_DETAILS"
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
topic: /server/pi_masterbedroom
|
||||
payload: 'CMD_REPORT_WIFI_DETAILS'
|
||||
payload: "CMD_REPORT_WIFI_DETAILS"
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
topic: /server/pizero_green
|
||||
payload: 'CMD_REPORT_WIFI_DETAILS'
|
||||
payload: "CMD_REPORT_WIFI_DETAILS"
|
||||
retain: false
|
||||
|
||||
# Script to Query Disk Information - Publishes message 'CMD_REPORT_DISK_DETAILS'
|
||||
# to MQTT, so that the message gets received by individual Raspberry Pi
|
||||
###############################################################################
|
||||
# Script to Query Disk Information - Publishes message 'CMD_REPORT_DISK_DETAILS'
|
||||
# to MQTT, so that the message gets received by individual Raspberry Pi
|
||||
###############################################################################
|
||||
query_disk_info:
|
||||
sequence:
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
topic: /server/pi_basement
|
||||
payload: 'CMD_REPORT_DISK_DETAILS'
|
||||
payload: "CMD_REPORT_DISK_DETAILS"
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
topic: /server/pi_theater
|
||||
payload: 'CMD_REPORT_DISK_DETAILS'
|
||||
payload: "CMD_REPORT_DISK_DETAILS"
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
topic: /server/pi_kitchen
|
||||
payload: 'CMD_REPORT_DISK_DETAILS'
|
||||
payload: "CMD_REPORT_DISK_DETAILS"
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
topic: /server/pi_familyroom
|
||||
payload: 'CMD_REPORT_DISK_DETAILS'
|
||||
payload: "CMD_REPORT_DISK_DETAILS"
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
topic: /server/pi_frontroom
|
||||
payload: 'CMD_REPORT_DISK_DETAILS'
|
||||
payload: "CMD_REPORT_DISK_DETAILS"
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
topic: /server/pi_garage
|
||||
payload: 'CMD_REPORT_DISK_DETAILS'
|
||||
payload: "CMD_REPORT_DISK_DETAILS"
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
topic: /server/pi_guest1
|
||||
payload: 'CMD_REPORT_DISK_DETAILS'
|
||||
payload: "CMD_REPORT_DISK_DETAILS"
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
topic: /server/pi_guest2
|
||||
payload: 'CMD_REPORT_DISK_DETAILS'
|
||||
payload: "CMD_REPORT_DISK_DETAILS"
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
topic: /server/pi_masterbedroom
|
||||
payload: 'CMD_REPORT_DISK_DETAILS'
|
||||
payload: "CMD_REPORT_DISK_DETAILS"
|
||||
retain: false
|
||||
- service: mqtt.publish
|
||||
data:
|
||||
topic: /server/pizero_green
|
||||
payload: 'CMD_REPORT_DISK_DETAILS'
|
||||
payload: "CMD_REPORT_DISK_DETAILS"
|
||||
retain: false
|
||||
|
||||
###############################################################################
|
||||
# _ _ _
|
||||
# /\ | | | | (_)
|
||||
# / \ _ _| |_ ___ _ __ ___ __ _| |_ _ ___ _ __ ___
|
||||
# _ _ _
|
||||
# /\ | | | | (_)
|
||||
# / \ _ _| |_ ___ _ __ ___ __ _| |_ _ ___ _ __ ___
|
||||
# / /\ \| | | | __/ _ \| '_ ` _ \ / _` | __| |/ _ \| '_ \/ __|
|
||||
# / ____ \ |_| | || (_) | | | | | | (_| | |_| | (_) | | | \__ \
|
||||
# /_/ \_\__,_|\__\___/|_| |_| |_|\__,_|\__|_|\___/|_| |_|___/
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
# Automations: Various automations to query and issue commands to Raspberry Pis
|
||||
###############################################################################
|
||||
automation:
|
||||
|
||||
# Queries WiFi Signal Level and Link Quality - it loads during startup, and
|
||||
# updates once every 30 minutes
|
||||
###############################################################################
|
||||
# Queries WiFi Signal Level and Link Quality - it loads during startup, and
|
||||
# updates once every 30 minutes
|
||||
###############################################################################
|
||||
- alias: Query RPi Wifi Data
|
||||
initial_state: true
|
||||
trigger:
|
||||
- platform: time_pattern
|
||||
minutes: '/30'
|
||||
minutes: "/30"
|
||||
- platform: homeassistant
|
||||
event: start
|
||||
action:
|
||||
- service: script.query_wifi_info
|
||||
|
||||
# Queries Disk Available and % Used - it loads during startup, and
|
||||
# updates once every 30 minutes
|
||||
###############################################################################
|
||||
# Queries Disk Available and % Used - it loads during startup, and
|
||||
# updates once every 30 minutes
|
||||
###############################################################################
|
||||
- alias: Query RPi Disk Data
|
||||
initial_state: true
|
||||
trigger:
|
||||
- platform: time_pattern
|
||||
minutes: '/30'
|
||||
minutes: "/30"
|
||||
- platform: homeassistant
|
||||
event: start
|
||||
event: start
|
||||
action:
|
||||
- service: script.query_disk_info
|
||||
|
||||
# Issues commands to Raspberry Pi via MQTT - On Demand
|
||||
###############################################################################
|
||||
# Issues commands to Raspberry Pi via MQTT - On Demand
|
||||
###############################################################################
|
||||
- alias: Raspberry Pi Command
|
||||
initial_state: true
|
||||
trigger:
|
||||
@@ -536,18 +534,18 @@ automation:
|
||||
entity_id: input_select.rpi_commands
|
||||
condition:
|
||||
- condition: template
|
||||
value_template: '{{ states.input_select.raspberry_pis.state | lower != "select one" }}'
|
||||
value_template: "{{ states('input_select.raspberry_pis') | lower != 'select one' }}"
|
||||
- condition: template
|
||||
value_template: '{{ states.input_select.rpi_commands.state | lower != "select one" }}'
|
||||
value_template: "{{ states('input_select.rpi_commands') | lower != 'select one' }}"
|
||||
action:
|
||||
service: mqtt.publish
|
||||
data_template:
|
||||
retain: false
|
||||
topic: "{{ '/server/' ~ states.input_select.raspberry_pis.state }}"
|
||||
topic: "{{ '/server/' ~ states('input_select.raspberry_pis') }}"
|
||||
payload: >-
|
||||
{% if states.input_select.rpi_commands.state | lower == "restart server" %}
|
||||
{% if states('input_select.rpi_commands') | lower == "restart server" %}
|
||||
CMD_REBOOT_PI
|
||||
{% elif states.input_select.rpi_commands.state | lower == "restart snapcast" %}
|
||||
{% elif states('input_select.rpi_commands') | lower == "restart snapcast" %}
|
||||
CMD_RESTART_SNAPCLIENT
|
||||
{% else %}
|
||||
CMD_SHUTDOWN_PI
|
||||
|
Reference in New Issue
Block a user