From b9f133794dba64e0e143f913357be4a1716d2596 Mon Sep 17 00:00:00 2001 From: Georgi Gardev Date: Fri, 24 Apr 2020 00:04:19 +0300 Subject: [PATCH] Add titanium via IOTLink --- config/floorplan-lovelace.yaml | 2 +- config/home-lovelace.yaml | 18 +- .../picture_elements/sensors.yaml | 5 +- config/lovelace/home_dashboard/00_home.yaml | 6 +- .../home_dashboard/01_living_room.yaml | 4 +- .../lovelace/home_dashboard/08_network.yaml | 105 ++++++++-- config/lovelace/popup_cards.yaml | 97 +++++++++ config/packages/devices/titanium.yaml | 188 ++++++++++++++++++ config/packages/routines/bedtime.yaml | 2 + config/packages/routines/good_night.yaml | 2 + 10 files changed, 395 insertions(+), 34 deletions(-) diff --git a/config/floorplan-lovelace.yaml b/config/floorplan-lovelace.yaml index 654ba56..7f5348c 100644 --- a/config/floorplan-lovelace.yaml +++ b/config/floorplan-lovelace.yaml @@ -30,7 +30,7 @@ views: - media_player.nvidia_shield - switch.camera - - binary_sensor.titanium + - switch.titanium_power - sensor.synology_dsm_type_volume_1 - binary_sensor.living_room_right_window_on_off_wrapper diff --git a/config/home-lovelace.yaml b/config/home-lovelace.yaml index 06d03c6..fcd8a84 100644 --- a/config/home-lovelace.yaml +++ b/config/home-lovelace.yaml @@ -46,8 +46,7 @@ views: name: Living room - type: custom:button-card template: small - entity: light.tuya_hallway_main_lights - name: Hallway + entity: light.pc - type: horizontal-stack cards: - type: custom:button-card @@ -70,7 +69,8 @@ views: name: Kitchen - type: custom:button-card template: small - entity: light.pc + entity: light.tuya_hallway_main_lights + name: Hallway - type: custom:button-card template: small entity: light.tuya_hallway_entrance_lights @@ -111,11 +111,7 @@ views: entity: media_player.living_room_tv - type: custom:button-card template: small - entity: binary_sensor.titanium - name: Titanium - tap_action: - action: call-service - service: script.titanium_start + entity: switch.titanium_power - type: horizontal-stack cards: @@ -123,6 +119,9 @@ views: template: small entity: switch.camera name: Camera + - type: custom:button-card + template: small + entity: fan.philips_airpurifier - type: custom:button-card template: small entity: sensor.synology_dsm_type_volume_1 @@ -130,9 +129,6 @@ views: icon: mdi:nas tap_action: action: more-info - - type: custom:button-card - template: small - entity: fan.philips_airpurifier - type: vertical-stack title: Presence diff --git a/config/lovelace/floorplan-dashboard/picture_elements/sensors.yaml b/config/lovelace/floorplan-dashboard/picture_elements/sensors.yaml index 7fae522..73c8e5c 100644 --- a/config/lovelace/floorplan-dashboard/picture_elements/sensors.yaml +++ b/config/lovelace/floorplan-dashboard/picture_elements/sensors.yaml @@ -9,12 +9,9 @@ - type: custom:decluttering-card template: floorplan_state_icon variables: - - entity: binary_sensor.titanium + - entity: switch.titanium_power - top: 62% - left: 81% - - tap_action: - action: call-service - service: script.titanium_start # Platinum - type: custom:decluttering-card diff --git a/config/lovelace/home_dashboard/00_home.yaml b/config/lovelace/home_dashboard/00_home.yaml index 04329a6..7805468 100644 --- a/config/lovelace/home_dashboard/00_home.yaml +++ b/config/lovelace/home_dashboard/00_home.yaml @@ -37,8 +37,7 @@ cards: name: Living room - type: custom:button-card template: small - entity: light.tuya_hallway_main_lights - name: Hallway + entity: light.pc - type: horizontal-stack cards: - type: custom:button-card @@ -61,7 +60,8 @@ cards: name: Kitchen - type: custom:button-card template: small - entity: light.pc + entity: light.tuya_hallway_main_lights + name: Hallway - type: custom:button-card template: small entity: light.tuya_hallway_entrance_lights diff --git a/config/lovelace/home_dashboard/01_living_room.yaml b/config/lovelace/home_dashboard/01_living_room.yaml index 9d3643d..cdc4e42 100644 --- a/config/lovelace/home_dashboard/01_living_room.yaml +++ b/config/lovelace/home_dashboard/01_living_room.yaml @@ -100,9 +100,7 @@ cards: - type: glance show_state: false entities: - - binary_sensor.titanium - - entity: script.titanium_start - name: Start + - switch.titanium_power - type: vertical-stack cards: diff --git a/config/lovelace/home_dashboard/08_network.yaml b/config/lovelace/home_dashboard/08_network.yaml index aad6d11..ef797ae 100644 --- a/config/lovelace/home_dashboard/08_network.yaml +++ b/config/lovelace/home_dashboard/08_network.yaml @@ -20,18 +20,99 @@ cards: cards: - type: vertical-stack cards: - - type: entities - title: Titanium - icon: mdi:desktop-tower - entities: - - binary_sensor.titanium - - type: custom:dummy-entity-row - entity: binary_sensor.titanium - tap_action: - action: call-service - service: script.titanium_start - name: Start - icon: mdi:power + - type: vertical-stack + cards: + - type: entities + title: Titanium + icon: mdi:desktop-tower + entities: + - switch.titanium_power + - sensor.titanium_uptime + - binary_sensor.titanium_playing + - sensor.titanium_volume + - type: custom:fold-entity-row + head: + type: custom:decluttering-card + template: percentage_card + variables: + - name: Memory + - entity: sensor.titanium_memory_used_percent + - icon: mdi:memory + - orange: 70 + - red: 85 + entities: + - entity: sensor.titanium_memory_used + name: Memory used + - entity: sensor.titanium_memory_available + name: Memory available + - entity: sensor.titanium_memory_total + name: Memory total + + - type: custom:fold-entity-row + head: + type: custom:decluttering-card + template: percentage_card + variables: + - name: "C: Drive" + - entity: sensor.titanium_c_usage + - icon: mdi:harddisk + - orange: 70 + - red: 85 + entities: + - entity: sensor.titanium_c_used_space + name: "C: Drive used" + - entity: sensor.titanium_c_free_space + name: "C: Drive available" + - entity: sensor.titanium_c_total_space + name: "C: Drive total" + + - type: horizontal-stack + cards: + - type: custom:button-card + template: small + entity: script.titanium_lock + name: Lock + icon: mdi:lock + tap_action: + action: toggle + - type: custom:button-card + template: small + entity: script.titanium_vol_mute + name: Mute + icon: mdi:volume-mute + tap_action: + action: toggle + - type: custom:button-card + template: small + entity: script.titanium_set_volume + name: Set volume + icon: mdi:volume-medium + tap_action: + action: toggle + + - type: horizontal-stack + cards: + - type: custom:button-card + template: small + entity: script.titanium_displays_on + name: Displays on + icon: mdi:monitor-dashboard + tap_action: + action: toggle + - type: custom:button-card + template: small + entity: script.titanium_displays_off + name: Displays off + icon: mdi:monitor-off + tap_action: + action: toggle + - type: custom:button-card + template: small + entity: script.titanium_refresh + name: Refresh + icon: mdi:refresh + tap_action: + action: toggle - type: entities style: | diff --git a/config/lovelace/popup_cards.yaml b/config/lovelace/popup_cards.yaml index 6dc4aa3..37b6995 100644 --- a/config/lovelace/popup_cards.yaml +++ b/config/lovelace/popup_cards.yaml @@ -458,3 +458,100 @@ sensor.synology_dsm_type_volume_1: legend: false tap_action: action: none + +switch.titanium_power: + title: Titanium + style: + <<: *popup_style + card: + type: vertical-stack + cards: + - type: entities + entities: + - switch.titanium_power + - sensor.titanium_uptime + - binary_sensor.titanium_playing + - sensor.titanium_volume + - type: custom:fold-entity-row + head: + type: custom:decluttering-card + template: percentage_card + variables: + - name: Memory + - entity: sensor.titanium_memory_used_percent + - icon: mdi:memory + - orange: 70 + - red: 85 + entities: + - entity: sensor.titanium_memory_used + name: Memory used + - entity: sensor.titanium_memory_available + name: Memory available + - entity: sensor.titanium_memory_total + name: Memory total + + - type: custom:fold-entity-row + head: + type: custom:decluttering-card + template: percentage_card + variables: + - name: "C: Drive" + - entity: sensor.titanium_c_usage + - icon: mdi:harddisk + - orange: 70 + - red: 85 + entities: + - entity: sensor.titanium_c_used_space + name: "C: Drive used" + - entity: sensor.titanium_c_free_space + name: "C: Drive available" + - entity: sensor.titanium_c_total_space + name: "C: Drive total" + + - type: horizontal-stack + cards: + - type: custom:button-card + template: small + entity: script.titanium_lock + name: Lock + icon: mdi:lock + tap_action: + action: toggle + - type: custom:button-card + template: small + entity: script.titanium_vol_mute + name: Mute + icon: mdi:volume-mute + tap_action: + action: toggle + - type: custom:button-card + template: small + entity: script.titanium_set_volume + name: Set volume + icon: mdi:volume-medium + tap_action: + action: toggle + + - type: horizontal-stack + cards: + - type: custom:button-card + template: small + entity: script.titanium_displays_on + name: Displays on + icon: mdi:monitor-dashboard + tap_action: + action: toggle + - type: custom:button-card + template: small + entity: script.titanium_displays_off + name: Displays off + icon: mdi:monitor-off + tap_action: + action: toggle + - type: custom:button-card + template: small + entity: script.titanium_refresh + name: Refresh + icon: mdi:refresh + tap_action: + action: toggle diff --git a/config/packages/devices/titanium.yaml b/config/packages/devices/titanium.yaml index 3ac88d6..b3543f9 100644 --- a/config/packages/devices/titanium.yaml +++ b/config/packages/devices/titanium.yaml @@ -18,6 +18,138 @@ binary_sensor: mdi:desktop-mac {% endif %} + - platform: mqtt + name: "Titanium playing" + availability_topic: "iotlink/workgroup/titanium/lwt" + payload_available: "ON" + payload_not_available: "OFF" + payload_on: "True" + payload_off: "False" + state_topic: "iotlink/workgroup/titanium/windows-monitor/stats/media/playing" + +# +# ─── IOTLink ────────────────────────────────────────────────────────────── +# +sensor: + - platform: mqtt + name: "Titanium uptime" + icon: mdi:clock-check-outline + availability_topic: "iotlink/workgroup/titanium/lwt" + payload_available: "ON" + payload_not_available: "OFF" + state_topic: "iotlink/workgroup/titanium/windows-monitor/stats/system/uptime" + + # Memory + - platform: mqtt + name: "Titanium memory used" + icon: mdi:memory + availability_topic: "iotlink/workgroup/titanium/lwt" + payload_available: "ON" + payload_not_available: "OFF" + state_topic: "iotlink/workgroup/titanium/windows-monitor/stats/memory/used" + unit_of_measurement: "MB" + + - platform: mqtt + name: "Titanium memory used percent" + icon: mdi:memory + availability_topic: "iotlink/workgroup/titanium/lwt" + payload_available: "ON" + payload_not_available: "OFF" + state_topic: "iotlink/workgroup/titanium/windows-monitor/stats/memory/usage" + unit_of_measurement: "%" + + - platform: mqtt + name: "Titanium memory available" + icon: mdi:memory + availability_topic: "iotlink/workgroup/titanium/lwt" + payload_available: "ON" + payload_not_available: "OFF" + state_topic: "iotlink/workgroup/titanium/windows-monitor/stats/memory/available" + unit_of_measurement: "MB" + + - platform: mqtt + name: "Titanium memory total" + icon: mdi:memory + availability_topic: "iotlink/workgroup/titanium/lwt" + payload_available: "ON" + payload_not_available: "OFF" + state_topic: "iotlink/workgroup/titanium/windows-monitor/stats/memory/total" + unit_of_measurement: "MB" + + # C Drive + - platform: mqtt + name: "Titanium C usage" + icon: mdi:harddisk + availability_topic: "iotlink/workgroup/titanium/lwt" + payload_available: "ON" + payload_not_available: "OFF" + state_topic: "iotlink/workgroup/titanium/windows-monitor/stats/hard-drive/c/drive-usage" + unit_of_measurement: "%" + + - platform: mqtt + name: "Titanium C free space" + icon: mdi:harddisk + availability_topic: "iotlink/workgroup/titanium/lwt" + payload_available: "ON" + payload_not_available: "OFF" + state_topic: "iotlink/workgroup/titanium/windows-monitor/stats/hard-drive/c/total-free-space" + unit_of_measurement: "GB" + + - platform: mqtt + name: "Titanium C used space" + icon: mdi:harddisk + availability_topic: "iotlink/workgroup/titanium/lwt" + payload_available: "ON" + payload_not_available: "OFF" + state_topic: "iotlink/workgroup/titanium/windows-monitor/stats/hard-drive/c/used-space" + unit_of_measurement: "GB" + + - platform: mqtt + name: "Titanium C total space" + icon: mdi:harddisk + availability_topic: "iotlink/workgroup/titanium/lwt" + payload_available: "ON" + payload_not_available: "OFF" + state_topic: "iotlink/workgroup/titanium/windows-monitor/stats/hard-drive/c/total-size" + unit_of_measurement: "GB" + + + # Media + - platform: mqtt + name: "Titanium volume" + icon: mdi:volume-medium + availability_topic: "iotlink/workgroup/titanium/lwt" + payload_available: "ON" + payload_not_available: "OFF" + state_topic: "iotlink/workgroup/titanium/windows-monitor/stats/media/volume" + unit_of_measurement: "GB" + +camera: + - platform: mqtt + name: "Titanium Screen 0" + topic: "iotlink/workgroup/titanium/windows-monitor/stats/display/0/screen" + - platform: mqtt + name: "Titanium Screen 1" + topic: "iotlink/workgroup/titanium/windows-monitor/stats/display/1/screen" + +switch: + - platform: template + switches: + titanium_power: + friendly_name: Titanium + value_template: "{{ is_state('binary_sensor.titanium', 'on') }}" + turn_on: + service: script.titanium_start + turn_off: + service: script.titanium_shutdown + icon_template: >- + + {% if is_state('binary_sensor.titanium', 'on') %} + mdi:monitor-dashboard + {% else %} + mdi:monitor-off + {% endif %} + script: titanium_start: alias: Titanium · Start @@ -26,3 +158,59 @@ script: - service: wake_on_lan.send_magic_packet data: mac: !secret titanium_mac + + titanium_shutdown: + alias: Titanium · Shutdown + sequence: + - service: mqtt.publish + data: + topic: "iotlink/workgroup/titanium/commands/shutdown" + payload: "" + + titanium_lock: + alias: Titanium · Lock + sequence: + - service: mqtt.publish + data: + topic: "iotlink/workgroup/titanium/commands/lock" + payload: "" + + titanium_vol_mute: + alias: Titanium · Toggle Mute + sequence: + - service: mqtt.publish + data: + topic: "iotlink/workgroup/titanium/commands/volume/mute" + payload: "" + + titanium_set_volume: + alias: Titanium · Set volume + sequence: + - service: mqtt.publish + data_template: + topic: "iotlink/workgroup/titanium/commands/volume/set" + payload: "{{ volume | default(30) }}" + + titanium_displays_on: + alias: Titanium · Displays ON + sequence: + - service: mqtt.publish + data: + topic: "iotlink/workgroup/titanium/commands/displays/on" + payload: "" + + titanium_displays_off: + alias: Titanium · Displays OFF + sequence: + - service: mqtt.publish + data: + topic: "iotlink/workgroup/titanium/commands/displays/off" + payload: "" + + titanium_refresh: + alias: Titanium · Refresh + sequence: + - service: mqtt.publish + data: + topic: "iotlink/workgroup/titanium/refresh" + payload: "" diff --git a/config/packages/routines/bedtime.yaml b/config/packages/routines/bedtime.yaml index 86c4cc9..f51523b 100644 --- a/config/packages/routines/bedtime.yaml +++ b/config/packages/routines/bedtime.yaml @@ -35,3 +35,5 @@ script: - media_player.living_room_tv - service: light.turn_off entity_id: light.ceiling_lights + - service: switch.turn_off + entity_id: switch.titanium_power diff --git a/config/packages/routines/good_night.yaml b/config/packages/routines/good_night.yaml index 00b1db1..93937bb 100644 --- a/config/packages/routines/good_night.yaml +++ b/config/packages/routines/good_night.yaml @@ -17,6 +17,8 @@ script: entity_id: - media_player.nvidia_shield - media_player.living_room_tv + - service: switch.turn_off + entity_id: switch.titanium_power # Use say_discretely instead of talk, because night mode is already on. - service: script.say_discretely data: