From adbbdf0b95e280db35f94b4dab36ad38d7fcb860 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Dec 2022 15:04:07 +1300 Subject: [PATCH] Sony TV replaces Viera, Veon Media Button Updates --- automations.yaml | 14 ++ esphome/esp-leafbat2.yaml | 4 +- packages/energy_readings.yaml | 8 + packages/office_media_buttons.yaml | 76 +++++----- packages/raspberry_pi_monitor.yaml | 193 +++++++++++++++++++++++++ packages/total_power_sum_template.yaml | 8 +- 6 files changed, 256 insertions(+), 47 deletions(-) create mode 100644 packages/raspberry_pi_monitor.yaml diff --git a/automations.yaml b/automations.yaml index e69de29..c63b3be 100644 --- a/automations.yaml +++ b/automations.yaml @@ -0,0 +1,14 @@ +- id: '1669966515993' + alias: Turn off Lounge TV + description: '' + trigger: + - platform: mqtt + topic: viewroad-commands/maintv/action + payload: 'OFF' + condition: [] + action: + - type: turn_off + device_id: 4a9f71fc64e158f1c9286d6e43ce782e + entity_id: remote.sony_kd_55x85k + domain: remote + mode: single diff --git a/esphome/esp-leafbat2.yaml b/esphome/esp-leafbat2.yaml index 1aed838..74e7f86 100644 --- a/esphome/esp-leafbat2.yaml +++ b/esphome/esp-leafbat2.yaml @@ -113,13 +113,13 @@ sensor: # Quality of Wifi in dBm - platform: wifi_signal name: "WiFi Signal" - update_interval: 20s + update_interval: 10s retain: true # Analog sensor for voltage reading (A0) - platform: adc pin: A0 name: "Battery Voltage" - update_interval: 20s + update_interval: 10s retain: true filters: - multiply: 18.52 # trial and error calc/measure diff --git a/packages/energy_readings.yaml b/packages/energy_readings.yaml index d25e390..b291716 100644 --- a/packages/energy_readings.yaml +++ b/packages/energy_readings.yaml @@ -19,3 +19,11 @@ mqtt: state_topic: "tele/tasmo-wemosd1-7280-powermon-1/SENSOR" unit_of_measurement: "kW" value_template: "{{ value_json.ENERGY.Power[2] }}" + +sensor: + - platform: template + sensors: + electricity_power_total: + friendly_name: "Electricity Power Total" + unit_of_measurement: "W" + value_template: "{{ states('sensor.tasmo_wemosd1_7280_powermon_1_energy_power_0') |float + states('sensor.tasmo_wemosd1_7280_powermon_1_energy_power_1') | float + states('sensor.tasmo_wemosd1_7280_powermon_1_energy_power_2') | float }}" diff --git a/packages/office_media_buttons.yaml b/packages/office_media_buttons.yaml index 51a7c34..90fc3d9 100644 --- a/packages/office_media_buttons.yaml +++ b/packages/office_media_buttons.yaml @@ -1,10 +1,10 @@ -mqtt: - sensor: - - unique_id: office_media_button_1 - name: "Office Media Button" - state_topic: "tele/tasmo-zigb-6440-1/9CB5/SENSOR" - unit_of_measurement: "Press" - value_template: "{{ value_json.ZbReceived.Office_Media_Button.Power }}" +#mqtt: +# sensor: +# - unique_id: office_media_button_1 +# name: "Office Media Button" +# state_topic: "tele/tasmo-zigb-6440-1/9CB5/SENSOR" +# unit_of_measurement: "Press" +# value_template: "{{ value_json.ZbReceived.Office_Media_Button.Power }}" automation: - id: "1629271273952" @@ -12,8 +12,8 @@ automation: description: "" trigger: - platform: state - entity_id: sensor.office_media_button - to: "1" + entity_id: sensor.media_button_office_zbt04_action + to: "single" condition: [] action: - service: media_player.media_pause @@ -25,38 +25,38 @@ automation: description: "" trigger: - platform: state - entity_id: sensor.office_media_button - to: "2" + entity_id: sensor.media_button_office_zbt04_action + to: "double" condition: [] action: - service: media_player.media_play target: device_id: abb6b5a6b4e4925dcb3a77ea2c293eaa mode: single - - id: "1629271273958" - alias: Pause office TV on MQTT - description: "" - trigger: - - platform: mqtt - topic: viewroad-commands/officetv/action - payload: pause - encoding: utf-8 - condition: [] - action: - - service: media_player.media_pause - target: - device_id: abb6b5a6b4e4925dcb3a77ea2c293eaa - mode: single - - id: "1630969028384" - alias: Skip Forward 30 Seconds on Media Button - description: "" - trigger: - - platform: state - entity_id: sensor.office_media_button - to: "3" - condition: [] - action: - - service: media_player.media_seek - data: - seek_position: 30 - mode: single +# - id: "1629271273958" +# alias: Pause office TV on MQTT +# description: "" +# trigger: +# - platform: mqtt +# topic: viewroad-commands/officetv/action +# payload: pause +# encoding: utf-8 +# condition: [] +# action: +# - service: media_player.media_pause +# target: +# device_id: abb6b5a6b4e4925dcb3a77ea2c293eaa +# mode: single +# - id: "1630969028384" +# alias: Skip Forward 30 Seconds on Media Button +# description: "" +# trigger: +# - platform: state +# entity_id: sensor.media_button_office_zbt04_action +# to: "triple" +# condition: [] +# action: +# - service: media_player.media_seek +# data: +# seek_position: 30 +# mode: single diff --git a/packages/raspberry_pi_monitor.yaml b/packages/raspberry_pi_monitor.yaml new file mode 100644 index 0000000..1fdd51f --- /dev/null +++ b/packages/raspberry_pi_monitor.yaml @@ -0,0 +1,193 @@ +mqtt: + sensor: + - state_topic: "viewroad-status/rpis/cctvquad1/cpu-temp" + name: "CCTVQuad1 CPU Temperature" + unit_of_measurement: "°C" + icon: mdi:thermometer + - state_topic: "viewroad-status/rpis/cctvquad1/cpu-use" + name: "CCTVQuad1 CPU Use" + unit_of_measurement: "%" + icon: mdi:cpu-32-bit + - state_topic: "viewroad-status/rpis/cctvquad1/ram-use" + name: "CCTVQuad1 RAM Use" + unit_of_measurement: "%" + icon: mdi:raspberry-pi + - state_topic: "viewroad-status/rpis/cctvquad1/disk-use" + name: "CCTVQuad1 Disk Use" + unit_of_measurement: "%" + icon: mdi:harddisk + - state_topic: "viewroad-status/rpis/cctvquad1/uptime" + name: "CCTVQuad1 Uptime" + icon: mdi:timer + - state_topic: "viewroad-status/rpis/cctvquad1/last-seen" + name: "CCTVQuad1 Last Seen" + icon: mdi:calendar-clock + - state_topic: "viewroad-status/rpis/cctvquad1/ipv4-address" + name: "CCTVQuad1 IPv4 Address" + icon: mdi:server-network + - state_topic: "viewroad-status/rpis/cctvquad2/cpu-temp" + name: "CCTVQuad2 CPU Temperature" + unit_of_measurement: "°C" + icon: mdi:thermometer + - state_topic: "viewroad-status/rpis/cctvquad2/cpu-use" + name: "CCTVQuad2 CPU Use" + unit_of_measurement: "%" + icon: mdi:cpu-32-bit + - state_topic: "viewroad-status/rpis/cctvquad2/ram-use" + name: "CCTVQuad2 RAM Use" + unit_of_measurement: "%" + icon: mdi:raspberry-pi + - state_topic: "viewroad-status/rpis/cctvquad2/disk-use" + name: "CCTVQuad2 Disk Use" + unit_of_measurement: "%" + icon: mdi:harddisk + - state_topic: "viewroad-status/rpis/cctvquad2/uptime" + name: "CCTVQuad2 Uptime" + icon: mdi:timer + - state_topic: "viewroad-status/rpis/cctvquad2/last-seen" + name: "CCTVQuad2 Last Seen" + icon: mdi:calendar-clock + - state_topic: "viewroad-status/rpis/cctvquad2/ipv4-address" + name: "CCTVQuad2 IPv4 Address" + icon: mdi:server-network + + switch: + - name: "CCTVQuad1 Reboot" + state_topic: "viewroad-status/rpis/cctvquad1/reboot" + command_topic: "viewroad-commands/rpis/cctvquad1/reboot/set" + qos: 1 + optimistic: false + retain: false + icon: mdi:refresh + - name: "CCTVQuad1 Shutdown" + state_topic: "viewroad-status/rpis/cctvquad1/shutdown" + command_topic: "viewroad-commands/rpis/cctvquad1/shutdown/set" + qos: 1 + optimistic: false + retain: false + icon: mdi:close-network + - name: "CCTVQuad2 Reboot" + state_topic: "viewroad-status/rpis/cctvquad2/reboot" + command_topic: "viewroad-commands/rpis/cctvquad2/reboot/set" + qos: 1 + optimistic: false + retain: false + icon: mdi:refresh + - name: "CCTVQuad2 Shutdown" + state_topic: "viewroad-status/rpis/cctvquad2/shutdown" + command_topic: "viewroad-commands/rpis/cctvquad2/shutdown/set" + qos: 1 + optimistic: false + retain: false + icon: mdi:close-network + +binary_sensor: + - platform: template + sensors: + pi_cctvquad1_on: + friendly_name: "CCTV Quad1 Available" + value_template: >- + {%- if states( 'sensor.cctvquad1_last_seen' ) != 'unknown' + and ( as_timestamp( now() ) - as_timestamp( states( 'sensor.cctvquad1_last_seen' ) ) ) <= 180 -%} + True + {%- else -%} + False + {%- endif %} + - platform: template + sensors: + pi_cctvquad2_on: + friendly_name: "CCTV Quad2 Available" + value_template: >- + {%- if states( 'sensor.cctvquad2_last_seen' ) != 'unknown' + and ( as_timestamp( now() ) - as_timestamp( states( 'sensor.cctvquad2_last_seen' ) ) ) <= 180 -%} + True + {%- else -%} + False + {%- endif %} + +group: + pi_cctvquad1_on: + name: "RPi CCTV Quad1" + #control: hidden + entities: + - sensor.cctvquad1_ipv4_address + - sensor.cctvquad1_uptime + - switch.cctvquad1_reboot + - switch.cctvquad1_shutdown + - sensor.cctvquad1_cpu_temperature + - sensor.cctvquad1_cpu_use + - sensor.cctvquad1_ram_use + - sensor.cctvquad1_disk_use + - sensor.cctvquad1_last_seen + + pi_cctvquad2_on: + name: "RPi CCTV Quad2" + #control: hidden + entities: + - sensor.cctvquad2_ipv4_address + - sensor.cctvquad2_uptime + - switch.cctvquad2_reboot + - switch.cctvquad2_shutdown + - sensor.cctvquad2_cpu_temperature + - sensor.cctvquad2_cpu_use + - sensor.cctvquad2_ram_use + - sensor.cctvquad2_disk_use + - sensor.cctvquad2_last_seen +#automation: +# - alias: "Home Assistant Start" +# trigger: +# platform: homeassistant +# event: start +# action: +# - service: group.set_visibility +# entity_id: +# - group.pi_cctvquad1_on +# data: +# visible: False +# - alias: "pi is on" +# trigger: +# platform: state +# entity_id: +# - binary_sensor.pi_cctvquad1_on +# from: "off" +# to: "on" +# action: +# - service: group.set_visibility +# data_template: +# entity_id: "group.pi_{{ trigger.entity_id | replace( 'binary_sensor.pi_', '' ) }}" +# visible: True +# - service: group.set_visibility +# data_template: +# entity_id: "group.pi_{{ trigger.entity_id | replace( 'binary_sensor.pi_', '' ) | replace( '_on', '' ) }}_off" +# visible: False +# - alias: "pi not seen" +# trigger: +# platform: state +# entity_id: +# - binary_sensor.pi_cctvquad1_on +# from: "on" +# to: "off" +# action: +# - service: group.set_visibility +# data_template: +# entity_id: "group.pi_{{ trigger.entity_id | replace( 'binary_sensor.pi_', '' ) | replace( '_on', '' ) }}_on" +# visible: False +# - service: group.set_visibility +# data_template: +# entity_id: "group.pi_{{ trigger.entity_id | replace( 'binary_sensor.pi_', '' ) | replace( '_on', '' ) }}_off" +# visible: True +#- service: notify.ios_PHONENAME +#data_template: +#title: "Pi Offline" +#message: "{{ trigger.entity_id | replace( 'binary_sensor.pi_', '' ) | replace( '_on', '' ) }}" +#- alias: 'pi disk use' +#trigger: +#platform: numeric_state +#entity_id: +#- sensor.cctvquad1_disk_use +#above: 90 +#action: +#- service: notify.ios_PHONENAME +#data_template: +#title: "Pi Disk Use > 90%" +#message: "{{ trigger.entity_id | replace( 'sensor.', '' ) | replace( '_disk_use', '' ) }}" diff --git a/packages/total_power_sum_template.yaml b/packages/total_power_sum_template.yaml index 48b61a2..8b13789 100644 --- a/packages/total_power_sum_template.yaml +++ b/packages/total_power_sum_template.yaml @@ -1,7 +1 @@ -sensor: - - platform: template - sensors: - electricity_power_total: - friendly_name: "Electricity Power Total" - unit_of_measurement: "W" - value_template: "{{ states('sensor.tasmo_wemosd1_7280_powermon_1_energy_power_0') |float + states('sensor.tasmo_wemosd1_7280_powermon_1_energy_power_1') | float + states('sensor.tasmo_wemosd1_7280_powermon_1_energy_power_2') | float }}" +