From c98436bd08e5e8a71f6e607d0c8325276dc4724b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Grondek?= Date: Sun, 2 Jun 2024 02:17:49 +0200 Subject: [PATCH] Add script to check unavailable devices --- availability.yml | 104 ++++++++++++++++++++++++++++ home-assistant.yml | 10 +++ templates/check-unavailable.yaml.j2 | 17 +++++ 3 files changed, 131 insertions(+) create mode 100644 availability.yml create mode 100644 templates/check-unavailable.yaml.j2 diff --git a/availability.yml b/availability.yml new file mode 100644 index 0000000..d796059 --- /dev/null +++ b/availability.yml @@ -0,0 +1,104 @@ +availability: + - update.3d_printer_button_firmware + - update.3d_printer_enclosure_fan_firmware + - update.3d_printer_smoke_sensor_firmware + - update.ac_power_firmware + - update.access_point + - update.bathroom_1_firmware + - update.bathroom_2_firmware + - update.bathroom_3_firmware + - update.bathroom_4_firmware + - update.bathroom_color_left_firmware + - update.bathroom_color_middle_firmware + - update.bathroom_color_right_firmware + - update.bathroom_mirror_1_firmware + - update.bathroom_mirror_2_firmware + - update.bathroom_mirror_3_firmware + - update.bathroom_motion_firmware + - update.bathroom_music_button_firmware + - update.bathroom_thermostat_firmware + - update.bedroom_bed_button_firmware + - update.bedroom_blind_left_firmware + - update.bedroom_blind_right_firmware + - update.bedroom_blinds_button_firmware + - update.bedroom_button_firmware + - update.bedroom_mitv_firmware + - update.bedroom_motion_firmware + - update.bedroom_tv_button_firmware + - update.bt_proxy_1_firmware + - update.bt_proxy_bathroom_firmware + - update.computer_button_firmware + - update.computer_outlet_firmware + - update.custom_deps_deployment_update + - update.dining_blind_back_firmware + - update.dining_blind_left_firmware + - update.dining_blind_middle_firmware + - update.dining_blind_right_firmware + - update.dining_blinds_controller_button_firmware + - update.dining_plants_leak_sensor_firmware + - update.eps32_rack_control_firmware + - update.esp_rack_fans_firmware + - update.esphome_update + - update.file_editor_update + - update.fridge_leak_sensor_firmware + - update.frigate_server + - update.front_door_lock_button_firmware + - update.front_door_lock_firmware + - update.hallway_button_firmware + - update.hallway_light_firmware + - update.home_assistant_core_update + - update.home_assistant_operating_system_update + - update.home_assistant_supervisor_update + - update.humidifier_firmware + - update.humidifier_leak_firmware + - update.ikea_of_sweden_tradfri_driver_10w_firmware + - update.kitchen_big_light_firmware + - update.kitchen_button_firmware + - update.kitchen_dishwasher_firmware + - update.kitchen_sink_button_firmware + - update.kitchen_sink_leak_sensor_firmware + - update.kvm_firmware + - update.lego_bookcase_firmware + - update.mac_mini_firmware + - update.mosquitto_broker_update + - update.nas_firmware + - update.network_ups_tools_update + - update.node_26_firmware + - update.node_27_firmware + - update.node_29_firmware + - update.office_air_quality_firmware + - update.office_blind_button_firmware + - update.office_blind_left_firmware + - update.office_blind_right_firmware + - update.office_keylight_button_firmware + - update.office_window_sensor_firmware + - update.office_window_vibration_sensor_firmware + - update.osram_plug_01_firmware + - update.outside_sensor_firmware + - update.ozempic_sensor_firmware + - update.printer_button_firmware + - update.prusa_mini_button_firmware + - update.prusa_mini_outlet_firmware + - update.rack_laptop_outlet_firmware + - update.rack_outlet_firmware + - update.rack_smoke_sensor_firmware + - update.relay_switch_1x2_5kw_firmware + - update.samba_backup_update + - update.samba_share_update + - update.shower_1_firmware + - update.shower_2_firmware + - update.shower_3_firmware + - update.shower_4_firmware + - update.switch_poe_firmware + - update.table_lamp_1_firmware + - update.table_lamp_2_firmware + - update.table_lamp_3_firmware + - update.usb_rack_pwr_firmware + - update.usb_switch_1_firmware + - update.usb_switch_2_firmware + - update.usb_switch_3_firmware + - update.washing_machine_firmware + - update.washing_machine_leak_firmware + - update.wled_firmware + - update.wled_office_monitor_firmware + - update.z_wave_js_update diff --git a/home-assistant.yml b/home-assistant.yml index 201aa51..15ea0bf 100644 --- a/home-assistant.yml +++ b/home-assistant.yml @@ -115,6 +115,16 @@ remote_src: no src: './build/automations/' dest: '{{ pwd_config }}/automations.yaml' + - name: Include availability vars + include_vars: + file: availability.yml + - name: Build unavailable script + delegate_to: localhost + template: + src: check-unavailable.yaml.j2 + dest: './scripts/check-unavailable.yaml' + vars: + entities: "{{ availability }}" - name: Concat scripts ansible.builtin.assemble: remote_src: no diff --git a/templates/check-unavailable.yaml.j2 b/templates/check-unavailable.yaml.j2 new file mode 100644 index 0000000..1b0aac5 --- /dev/null +++ b/templates/check-unavailable.yaml.j2 @@ -0,0 +1,17 @@ +check_unavailable: + alias: '[INFO] Check unavailable devices' + sequence: +{% for entity in entities %} + - choose: + - conditions: + - condition: state + entity_id: {{ entity }} + state: unavailable + sequence: + - service: notify.home_assistant + data: + message: > + Device unavailable + {% raw %}{{ {% endraw %} device_attr('{{entity}}', 'name_by_user'){% raw %} }} {% endraw %}is unavailable + target: [ "1109936159951441960" ] +{% endfor %}