diff --git a/.gitignore b/.gitignore index a8e4096..ba3f5ad 100644 --- a/.gitignore +++ b/.gitignore @@ -20,9 +20,11 @@ __pycache__/ deps/ ip_bans.yaml known_devices.yaml +tracked_devices.yaml secrets.yaml ToDo.md OZW_Log.txt +host-id-rsa !.github !.gitignore diff --git a/appdaemon/.gitignore b/appdaemon/.gitignore index fcc4735..73f18a4 100644 --- a/appdaemon/.gitignore +++ b/appdaemon/.gitignore @@ -1,2 +1,3 @@ compiled -cameras.yaml \ No newline at end of file +cameras.yaml +tracked_Devices.yaml \ No newline at end of file diff --git a/appdaemon/dashboards/Desk.dash b/appdaemon/dashboards/Desk.dash index 875e9a0..70f7a05 100644 --- a/appdaemon/dashboards/Desk.dash +++ b/appdaemon/dashboards/Desk.dash @@ -4,7 +4,7 @@ widget_dimensions: [120, 120] widget_size: [1, 1] widget_margins: [5, 5] columns: 6 -rows: 4 +rows: 6 global_parameters: use_comma: 0 precision: 2 @@ -32,4 +32,5 @@ layout: - nav_main, clock(2x1), nav_mobile, nav_back, reload - temp, heat_index, humidity, light, light_value, pressure - ac_status, ac_current, battery_status, battery_capacity, battery_voltage, battery_current + - cpu_temperature, load_5m, memory_use_percent, swap_use_percent, disk_use_root, disk_use_tank - zwave_gateway_status, zwave_multi_sensor_attic_status, multi_sensor_attic, multi_sensor_attic_battery_level, multi_sensor_attic_temperature, multi_sensor_attic_humidity, spacer diff --git a/appdaemon/dashboards/Desk_Mobile.dash b/appdaemon/dashboards/Desk_Mobile.dash index 8d9637f..ab956e6 100644 --- a/appdaemon/dashboards/Desk_Mobile.dash +++ b/appdaemon/dashboards/Desk_Mobile.dash @@ -4,7 +4,7 @@ widget_dimensions: [120, 120] widget_size: [1, 1] widget_margins: [5, 5] columns: 3 -rows: 8 +rows: 11 global_parameters: use_comma: 0 precision: 2 @@ -37,3 +37,6 @@ layout: - battery_capacity, battery_voltage, battery_current - zwave_gateway_status, zwave_multi_sensor_attic_status, multi_sensor_attic - multi_sensor_attic_battery_level, multi_sensor_attic_temperature, multi_sensor_attic_humidity + - load_5m, cpu_temperature, cpu_speed + - memory_use_percent, swap_use_percent, spacer + - disk_use_root, disk_use_tank, spacer \ No newline at end of file diff --git a/appdaemon/dashboards/Main.dash b/appdaemon/dashboards/Main.dash index 1af2852..505e8fa 100644 --- a/appdaemon/dashboards/Main.dash +++ b/appdaemon/dashboards/Main.dash @@ -79,10 +79,11 @@ layout: - include: header - include: cameras - include: entertainment + - include: tracked_devices - nav_main, clock(3x1), nav_mobile, reload - - nav_weather, current_weather(2x1), nav_sensors, nav_desk, nav_status + - nav_weather, current_weather(2x1), tracked_device_1, tracked_device_2, nav_desk - bedroom_tv(3x2), living_room_tv(3x2) - - - nav_cameras, nav_entertainment, spacer(4x1) + - nav_sensors, nav_entertainment, nav_cameras, nav_status, spacer(3x1) - camera_stairs(3x2), camera_living_room(3x2) - diff --git a/appdaemon/dashboards/Main_Mobile.dash b/appdaemon/dashboards/Main_Mobile.dash index 7d63b44..c2970b8 100644 --- a/appdaemon/dashboards/Main_Mobile.dash +++ b/appdaemon/dashboards/Main_Mobile.dash @@ -79,15 +79,16 @@ layout: - include: header - include: cameras - include: entertainment + - include: tracked_devices - nav_main_mobile, spacer, reload - nav_desktop, clock(2x1) - nav_weather, current_weather(2x1) - - nav_sensors, nav_desk, nav_status + - nav_desk, tracked_device_1, tracked_device_2 + - nav_sensors, nav_cameras, nav_status - bedroom_tv(3x2) - - living_room_tv(3x2) - - - nav_cameras, nav_entertainment, spacer - camera_stairs(3x2) - - camera_living_room(3x2) diff --git a/appdaemon/dashboards/Status.dash b/appdaemon/dashboards/Status.dash index a0550db..b91f054 100644 --- a/appdaemon/dashboards/Status.dash +++ b/appdaemon/dashboards/Status.dash @@ -4,7 +4,7 @@ widget_dimensions: [120, 120] widget_size: [1, 1] widget_margins: [5, 5] columns: 5 -rows: 3 +rows: 5 global_parameters: use_comma: 0 precision: 2 @@ -30,3 +30,5 @@ layout: - include: status - ac_status, ac_current, ac_voltage, spacer(2x1) - battery_status, battery_capacity, battery_voltage, battery_current, battery_health + - load_5m, cpu_temperature, spacer(3x1) + - memory_use_percent, swap_use_percent, disk_use_root, disk_use_tank, cpu_speed diff --git a/appdaemon/dashboards/Status_Mobile.dash b/appdaemon/dashboards/Status_Mobile.dash index 6d16da9..8de030b 100644 --- a/appdaemon/dashboards/Status_Mobile.dash +++ b/appdaemon/dashboards/Status_Mobile.dash @@ -4,7 +4,7 @@ widget_dimensions: [120, 120] widget_size: [1, 1] widget_margins: [5, 5] columns: 3 -rows: 5 +rows: 7 global_parameters: use_comma: 0 precision: 2 @@ -31,4 +31,6 @@ layout: - include: status - ac_status, ac_current, ac_voltage - battery_status, battery_capacity, battery_voltage - - spacer, battery_current, battery_health + - battery_current, battery_health + - cpu_temperature, memory_use_percent, swap_use_percent + - load_5m, disk_use_root, disk_use_tank, spacer diff --git a/appdaemon/dashboards/status.yaml b/appdaemon/dashboards/status.yaml index 0b8e914..f4ac34b 100644 --- a/appdaemon/dashboards/status.yaml +++ b/appdaemon/dashboards/status.yaml @@ -53,3 +53,53 @@ battery_health: widget_type: sensor entity: sensor.sopine_battery_health units: "" + +memory_use_percent: + widget_type: gauge + entity: sensor.memory_use_percent + title: "Memory" + units: "%" + min: 0 + max: 100 + +swap_use_percent: + widget_type: gauge + entity: sensor.swap_use_percent + title: "Swap" + units: "%" + min: 0 + max: 100 + +load_5m: + widget_type: sensor + entity: sensor.load_5m + title: "5 Minute Load" + units: "" + +disk_use_root: + widget_type: gauge + entity: sensor.disk_use_root + title: "/" + units: "%" + min: 0 + max: 100 + +disk_use_tank: + widget_type: gauge + entity: sensor.disk_use_tank + title: "/tank" + units: "%" + min: 0 + max: 100 + +cpu_speed: + widget_type: sensor + entity: sensor.cpu_speed + title: "CPU Frequency" + units: "Hz" + +cpu_temperature: + widget_type: sensor + title: CPU + entity: sensor.cpu_temperature + units: "°F" diff --git a/appdaemon/secrets-example.yaml b/appdaemon/secrets-example.yaml index e4664af..4d529b9 100644 --- a/appdaemon/secrets-example.yaml +++ b/appdaemon/secrets-example.yaml @@ -5,3 +5,7 @@ appdaemon_elevation: 0 appdaemon_latitude: 0 appdaemon_longitude: 0 appdaemon_time_zone: UTC +tracked_device_1: android_phone_1 +tracked_device_1_title: Android Phone (1) +tracked_device_2: android_phone_2 +tracked_device_2: Android Phone (2) diff --git a/automations/desk_human_kiosk.yaml b/automations/desk_human_kiosk.yaml new file mode 100644 index 0000000..eb71e2c --- /dev/null +++ b/automations/desk_human_kiosk.yaml @@ -0,0 +1,15 @@ +# Desk kiosk on/off +- id: desk_kiosk + alias: Desk Kiosk + trigger: + - platform: state + entity_id: !secret tracked_device_1 + action: + - service: shell_command.lightdm + data_template: + action: >- + {% if trigger.to_state.state == 'home' %} + start + {% else %} + stop + {% endif %} diff --git a/configuration.yaml b/configuration.yaml index 8d80495..3f740f9 100644 --- a/configuration.yaml +++ b/configuration.yaml @@ -159,11 +159,19 @@ logbook: - sensor.pcf8523 +# Shell Commands +shell_command: !include shell_commands.yaml + + # Scenes # https://home-assistant.io/components/scene/ #scene: !include misc/scenes.yaml +# Automations +automation: !include_dir_merge_list automations/ + + # Discover some devices automatically discovery: ignore: diff --git a/secrets-example.yaml b/secrets-example.yaml index 80d3361..530d6ca 100644 --- a/secrets-example.yaml +++ b/secrets-example.yaml @@ -9,6 +9,10 @@ homeassistant_whitelist_config: ./ http_base_url: "" http_password: "" +# Devices +tracked_device_1: android_phone_1 +tracked_device_2: android_phone_2 + # Database Setup recorder_db_url: "postgresql://user:password@SERVER_IP/DB_NAME" diff --git a/sensors/README.md b/sensors/README.md index 7a5030c..4e299fa 100644 --- a/sensors/README.md +++ b/sensors/README.md @@ -1,3 +1,17 @@ # Sensors Various sensor configurations. Each of the ```yaml``` files is a *different* sensor. + +## SSH Voodoo + +Some sensors are setup to use ssh -> host to bail out of the docker container for monitoring. You'll need to run the below setup on the Docker host to get these sensors working. + +``` bash + +useradd -m -s /bin/bash home-assistant +sudo -sHu home-assistant +ssh-keygen -t rsa -b 4096 +cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys +cat ~/.ssh/id_rsa > /path/to/config/host-id-rsa + +``` \ No newline at end of file diff --git a/sensors/server.yaml b/sensors/server.yaml new file mode 100644 index 0000000..6e45a35 --- /dev/null +++ b/sensors/server.yaml @@ -0,0 +1,31 @@ +# These are respresentative of the host system too despite containerization +- platform: systemmonitor + resources: + - type: memory_use_percent + - type: swap_use_percent + - type: load_5m + +# SSH voodoo to work around containerization +- platform: command_line + name: disk_use_root + command: "ssh -i /config/host-id-rsa -o StrictHostKeyChecking=no home-assistant@172.30.0.1 df --output=pcent / | sed 1d | sed 's/ //g' | sed 's/%//g'" + unit_of_measurement: "%" + +# SSH voodoo to work around containerization +- platform: command_line + name: disk_use_tank + command: "ssh -i /config/host-id-rsa -o StrictHostKeyChecking=no home-assistant@172.30.0.1 df --output=pcent /tank | sed 1d | sed 's/ //g' | sed 's/%//g'" + unit_of_measurement: "%" + +# Works on SOPine ; standard cpuspeed patform doesn't support SOPine +- platform: command_line + name: cpu_speed + command: "ssh -i /config/host-id-rsa -o StrictHostKeyChecking=no home-assistant@172.30.0.1 cpufreq-info -f" + unit_of_measurement: "Hz" + +# Thermal zone for CPU on SOPine and other arm boards +- platform: command_line + name: cpu_temperature + command: "cat /sys/class/thermal/thermal_zone0/temp" + unit_of_measurement: "°C" + value_template: '{{ value | multiply(0.001) | round(2) }}' diff --git a/shell_commands.yaml b/shell_commands.yaml new file mode 100644 index 0000000..4c455d9 --- /dev/null +++ b/shell_commands.yaml @@ -0,0 +1 @@ +lightdm: "ssh -i /config/host-id-rsa -o StrictHostKeyChecking=no home-assistant@172.30.0.1 sudo systemctl {{ action }} lightdm"