From dced66e62653382ab3fb618548ef1b0916b856bd Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Fri, 17 Mar 2023 15:46:02 +0200 Subject: [PATCH] Add motion_hass --- files/motion_hass.service | 8 ++++++++ files/motion_hass.timer | 7 +++++++ tasks/configure.yml | 6 ++++++ tasks/install.yml | 4 ++++ templates/motion_hass.conf.j2 | 5 +++++ 5 files changed, 30 insertions(+) create mode 100644 files/motion_hass.service create mode 100644 files/motion_hass.timer create mode 100644 templates/motion_hass.conf.j2 diff --git a/files/motion_hass.service b/files/motion_hass.service new file mode 100644 index 0000000..162e581 --- /dev/null +++ b/files/motion_hass.service @@ -0,0 +1,8 @@ +[Service] +Type=simple +#RemainAfterExit=yes +User=motion +ExecStart=/usr/local/bin/motion_hass.py --config /etc/motion_hass.conf + +[Unit] +OnFailure=status_email_antoniodelgado@%n.service diff --git a/files/motion_hass.timer b/files/motion_hass.timer new file mode 100644 index 0000000..5d6c7a4 --- /dev/null +++ b/files/motion_hass.timer @@ -0,0 +1,7 @@ +[Timer] +OnBootSec=10sec +OnUnitActiveSec=10sec +Unit=motion_hass.service + +[Install] +WantedBy=timers.target diff --git a/tasks/configure.yml b/tasks/configure.yml index ffa2438..2914082 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -137,3 +137,9 @@ daemon_reload: true name: transfer_recordings.timer enabled: true + + - name: Ensure motion_hass is configured + template: + src: templates/motion_hass.conf.j2 + dest: /etc/motion_hass.conf + backup: yes diff --git a/tasks/install.yml b/tasks/install.yml index d95cc40..7dd3929 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -20,3 +20,7 @@ owner: motion group: motion mode: 0750 + + - name: Ensure motion_hass is installed + ansible.builtin.pip: + name: git+ssh://git@repos.susurrando.com:1122/srv/git.repos/motion_hass.git diff --git a/templates/motion_hass.conf.j2 b/templates/motion_hass.conf.j2 new file mode 100644 index 0000000..f3900b7 --- /dev/null +++ b/templates/motion_hass.conf.j2 @@ -0,0 +1,5 @@ +hass_token='{{ vault_haos_api_calls_token }}' +hass_uri='http://192.168.1.248:8123' +motion_config='/etc/motion/motion.conf' +# debug_level='DEBUG' +on_movie_end="/usr/local/bin/process_motion_event.sh --move-to /srv/expendable_data/motion 192.168.1.251:/srv/expendable_data/ --move-to-port 1122 --remove-picture --email-destination '{{ recipient }}' --home-assistant-url http://192.168.1.248:8123 --home-assistant-token '{{ vault_haos_api_calls_token }}' --signal-destination '+358401871182' -e 'on_movie_end' -t '%t' -w '%w' -J '%J' -i '%i' -C '%C' -o '%o' -c '%$' -v '%v' -D '%D' -h '%h' -K '%K' -L '%L' -f '%f' -Q '%Q' -F '%fps' -q '%q' -N '%N' -n '%n' -h '%host'"