From e0a7e6d9c82b426efb44a7e0673d443220d24890 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sun, 8 Dec 2024 18:40:36 +0100 Subject: [PATCH] add home assistant notif to downloads --- playbooks/apps/bin.yaml | 7 +++++++ .../apps/templates/bin/download-eau-du-grand-lyon.j2 | 8 ++++++-- playbooks/apps/templates/bin/download-free-mobile.j2 | 8 ++++++-- playbooks/apps/templates/bin/download-freebox.j2 | 8 ++++++-- playbooks/apps/templates/bin/download-lcl-checking.j2 | 6 +++++- playbooks/apps/templates/bin/download-octopus.j2 | 8 ++++++-- playbooks/apps/templates/bin/download-shiva.j2 | 8 ++++++-- 7 files changed, 42 insertions(+), 11 deletions(-) diff --git a/playbooks/apps/bin.yaml b/playbooks/apps/bin.yaml index acd6043..96f281b 100644 --- a/playbooks/apps/bin.yaml +++ b/playbooks/apps/bin.yaml @@ -67,6 +67,13 @@ 3466633264626636620a613634653933333332386365393639343030616234376537373635343237 37373364303732343264623239353837613435363363393862383765376435376166343237333664 3330623266383462666564376166373032393361653234633863 + downloader_home_assistant_hook_id: !vault | + $ANSIBLE_VAULT;1.1;AES256 + 38376539353731316230663461653764633138313465353132386230623864356637356465366434 + 6466376364643632636538356466353261396235386564300a653831326230623761663433303632 + 64633537343931623430616132656234613661366166366265396566333435643338303731303463 + 3662343165343261640a336564313161326364396435366666653838383766383961366463346137 + 64383235343132393566356266643936386235326337393236623635313537616539 downloader_freebox_username: !vault | $ANSIBLE_VAULT;1.1;AES256 33636161363132333137313536613165393466303436306130376264383834663439346366383765 diff --git a/playbooks/apps/templates/bin/download-eau-du-grand-lyon.j2 b/playbooks/apps/templates/bin/download-eau-du-grand-lyon.j2 index 919a7aa..1bb7d77 100755 --- a/playbooks/apps/templates/bin/download-eau-du-grand-lyon.j2 +++ b/playbooks/apps/templates/bin/download-eau-du-grand-lyon.j2 @@ -1,5 +1,9 @@ #!/bin/bash -set -euo pipefail +set -uo pipefail -pushd /mnt/data/paperless-ngx +pushd /mnt/data/paperless-ngx || exit 1 ./downloader eau-du-grand-lyon -o consume -u '{{downloader_eau_lyon_username}}' -p '{{downloader_eau_lyon_password}}' --headless + +status=$? +curl -X PUT -d 'source=eau-du-grand-lyon' "https://hass.augendre.info/api/webhook/{{ downloader_home_assistant_hook_id }}" +exit $status diff --git a/playbooks/apps/templates/bin/download-free-mobile.j2 b/playbooks/apps/templates/bin/download-free-mobile.j2 index 139e723..45b8cc0 100755 --- a/playbooks/apps/templates/bin/download-free-mobile.j2 +++ b/playbooks/apps/templates/bin/download-free-mobile.j2 @@ -1,5 +1,9 @@ #!/bin/bash -set -euo pipefail +set -uo pipefail -pushd /mnt/data/paperless-ngx +pushd /mnt/data/paperless-ngx || exit 1 ./downloader free-mobile -o consume -u '{{downloader_free_mobile_username}}' -p '{{downloader_free_mobile_password}}' --headless --no-interaction + +status=$? +curl -X PUT -d 'source=free-mobile' "https://hass.augendre.info/api/webhook/{{ downloader_home_assistant_hook_id }}" +exit $status diff --git a/playbooks/apps/templates/bin/download-freebox.j2 b/playbooks/apps/templates/bin/download-freebox.j2 index 4568916..c91d001 100755 --- a/playbooks/apps/templates/bin/download-freebox.j2 +++ b/playbooks/apps/templates/bin/download-freebox.j2 @@ -1,5 +1,9 @@ #!/bin/bash -set -euo pipefail +set -uo pipefail -pushd /mnt/data/paperless-ngx +pushd /mnt/data/paperless-ngx || exit 1 ./downloader freebox -o consume -u '{{downloader_freebox_username}}' -p '{{downloader_freebox_password}}' --headless + +status=$? +curl -X PUT -d 'source=freebox' "https://hass.augendre.info/api/webhook/{{ downloader_home_assistant_hook_id }}" +exit $status diff --git a/playbooks/apps/templates/bin/download-lcl-checking.j2 b/playbooks/apps/templates/bin/download-lcl-checking.j2 index 5301129..ddb2c21 100755 --- a/playbooks/apps/templates/bin/download-lcl-checking.j2 +++ b/playbooks/apps/templates/bin/download-lcl-checking.j2 @@ -1,5 +1,9 @@ #!/bin/bash set -euo pipefail -pushd /mnt/data/paperless-ngx +pushd /mnt/data/paperless-ngx || exit 1 ./downloader lcl-checking -o consume -u '{{downloader_lcl_username}}' -p '{{downloader_lcl_password}}' --headless + +status=$? +curl -X PUT -d 'source=lcl-checking' "https://hass.augendre.info/api/webhook/{{ downloader_home_assistant_hook_id }}" +exit $status diff --git a/playbooks/apps/templates/bin/download-octopus.j2 b/playbooks/apps/templates/bin/download-octopus.j2 index 9e5f8bc..359eb06 100755 --- a/playbooks/apps/templates/bin/download-octopus.j2 +++ b/playbooks/apps/templates/bin/download-octopus.j2 @@ -1,5 +1,9 @@ #!/bin/bash -set -euo pipefail +set -uo pipefail -pushd /mnt/data/paperless-ngx +pushd /mnt/data/paperless-ngx || exit 1 ./downloader octopus-energy-address -o consume -u '{{downloader_octopus_username}}' -p '{{downloader_octopus_password}}' --headless + +status=$? +curl -X PUT -d 'source=octopus-energy-address' "https://hass.augendre.info/api/webhook/{{ downloader_home_assistant_hook_id }}" +exit $status diff --git a/playbooks/apps/templates/bin/download-shiva.j2 b/playbooks/apps/templates/bin/download-shiva.j2 index 5a7013c..19d8966 100755 --- a/playbooks/apps/templates/bin/download-shiva.j2 +++ b/playbooks/apps/templates/bin/download-shiva.j2 @@ -1,5 +1,9 @@ #!/bin/bash -set -euo pipefail +set -uo pipefail -pushd /mnt/data/paperless-ngx +pushd /mnt/data/paperless-ngx || exit 1 ./downloader shiva -o consume -u '{{downloader_shiva_username}}' -p '{{downloader_shiva_password}}' --headless + +status=$? +curl -X PUT -d 'source=shiva' "https://hass.augendre.info/api/webhook/{{ downloader_home_assistant_hook_id }}" +exit $status