Add sensors-polling deployment.
This commit is contained in:
parent
7df0d95d95
commit
d579391c34
82
deploy.yml
82
deploy.yml
@ -37,80 +37,10 @@
|
|||||||
- /mnt/apps/volumes/homeassistant_conf:/config
|
- /mnt/apps/volumes/homeassistant_conf:/config
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: create docker-mounted-files directory
|
- name: Include deploy_thermostat tasks
|
||||||
ansible.builtin.file:
|
ansible.builtin.include_tasks: "tasks/deploy_thermostat.yml"
|
||||||
path: "/usr/local/docker-mounted-files/docker-thermostat"
|
tags: deploy_thermostat
|
||||||
state: directory
|
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: Template thermostat conf.yml
|
- name: Include deploy_sensors-polling tasks
|
||||||
ansible.builtin.template:
|
ansible.builtin.include_tasks: "tasks/deploy_sensors-polling.yml"
|
||||||
src: templates/conf.yml.j2
|
tags: deploy_sensors-polling
|
||||||
dest: /usr/local/docker-mounted-files/docker-thermostat/conf.yml
|
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: Build thermostat image
|
|
||||||
ansible.builtin.include_role:
|
|
||||||
name: role_build_container_image
|
|
||||||
vars:
|
|
||||||
image: "{{ item }}"
|
|
||||||
with_items:
|
|
||||||
- repo_url: https://git.scimetis.net/yohan/docker-thermostat.git
|
|
||||||
repo_name: docker-thermostat
|
|
||||||
name: thermostat
|
|
||||||
result_var: build_result
|
|
||||||
|
|
||||||
- debug: var=build_result
|
|
||||||
when: build_result.changed
|
|
||||||
|
|
||||||
- name: Gather facts on thermostat container
|
|
||||||
containers.podman.podman_container_info:
|
|
||||||
name: thermostat
|
|
||||||
register: container_info
|
|
||||||
become: true
|
|
||||||
|
|
||||||
- debug: var=container_info.containers[0].Config.Annotations.git_commit
|
|
||||||
when: container_info.containers | length == 1
|
|
||||||
|
|
||||||
- name: Set fact bool_recreate to true
|
|
||||||
set_fact:
|
|
||||||
bool_recreate: true
|
|
||||||
when:
|
|
||||||
- container_info.containers | length == 1
|
|
||||||
- container_info.containers[0].Config.Annotations.git_commit != commit
|
|
||||||
|
|
||||||
- name: create thermostat volume
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: "/mnt/apps/volumes/thermostat"
|
|
||||||
state: directory
|
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: Delete thermostat container
|
|
||||||
containers.podman.podman_container:
|
|
||||||
name: thermostat
|
|
||||||
state: absent
|
|
||||||
become: true
|
|
||||||
when: bool_recreate | default(false)
|
|
||||||
|
|
||||||
- name: Create thermostat container
|
|
||||||
containers.podman.podman_container:
|
|
||||||
name: thermostat
|
|
||||||
image: localhost/thermostat:latest
|
|
||||||
network:
|
|
||||||
- host
|
|
||||||
env:
|
|
||||||
TZ: "Europe/Paris"
|
|
||||||
GUNICORN_CMD_ARGS: "--bind=0.0.0.0:3002"
|
|
||||||
privileged: true
|
|
||||||
restart_policy: always
|
|
||||||
volume:
|
|
||||||
- /usr/local/docker-mounted-files/docker-thermostat/conf.yml:/root/conf.yml
|
|
||||||
- /mnt/apps/volumes/thermostat:/root/instance
|
|
||||||
- /run/udev:/run/udev
|
|
||||||
become: true
|
|
||||||
when: bool_recreate | default(false) or container_info.containers | length == 0
|
|
||||||
|
|
||||||
- name: Prune images
|
|
||||||
containers.podman.podman_prune:
|
|
||||||
image: true
|
|
||||||
become: true
|
|
||||||
|
70
tasks/deploy_sensors-polling.yml
Normal file
70
tasks/deploy_sensors-polling.yml
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
---
|
||||||
|
- name: create docker-mounted-files directory
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "/usr/local/docker-mounted-files/docker-sensors-polling"
|
||||||
|
state: directory
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Template sensors-polling conf.yml
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: templates/sensors-polling-conf.yml.j2
|
||||||
|
dest: /usr/local/docker-mounted-files/docker-sensors-polling/conf.yml
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Build sensors-polling image
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: role_build_container_image
|
||||||
|
vars:
|
||||||
|
image: "{{ item }}"
|
||||||
|
with_items:
|
||||||
|
- repo_url: https://git.scimetis.net/yohan/docker-sensors-polling.git
|
||||||
|
repo_name: docker-sensors-polling
|
||||||
|
name: sensors-polling
|
||||||
|
result_var: build_result
|
||||||
|
|
||||||
|
- debug: var=build_result
|
||||||
|
when: build_result.changed
|
||||||
|
|
||||||
|
- name: Gather facts on sensors-polling container
|
||||||
|
containers.podman.podman_container_info:
|
||||||
|
name: sensors-polling
|
||||||
|
register: container_info
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- debug: var=container_info.containers[0].Config.Annotations.git_commit
|
||||||
|
when: container_info.containers | length == 1
|
||||||
|
|
||||||
|
- name: Set fact bool_recreate to true
|
||||||
|
set_fact:
|
||||||
|
bool_recreate: true
|
||||||
|
when:
|
||||||
|
- container_info.containers | length == 1
|
||||||
|
- container_info.containers[0].Config.Annotations.git_commit != commit
|
||||||
|
|
||||||
|
- name: Delete sensors-polling container
|
||||||
|
containers.podman.podman_container:
|
||||||
|
name: sensors-polling
|
||||||
|
state: absent
|
||||||
|
become: true
|
||||||
|
when: bool_recreate | default(false)
|
||||||
|
|
||||||
|
- name: Create sensors-polling container
|
||||||
|
containers.podman.podman_container:
|
||||||
|
name: sensors-polling
|
||||||
|
image: localhost/sensors-polling:latest
|
||||||
|
network:
|
||||||
|
- host
|
||||||
|
env:
|
||||||
|
TZ: "Europe/Paris"
|
||||||
|
privileged: true
|
||||||
|
restart_policy: always
|
||||||
|
volume:
|
||||||
|
- /usr/local/docker-mounted-files/docker-sensors-polling/conf.yml:/root/conf.yml
|
||||||
|
- /run/udev:/run/udev
|
||||||
|
become: true
|
||||||
|
when: bool_recreate | default(false) or container_info.containers | length == 0
|
||||||
|
|
||||||
|
- name: Prune images
|
||||||
|
containers.podman.podman_prune:
|
||||||
|
image: true
|
||||||
|
become: true
|
78
tasks/deploy_thermostat.yml
Normal file
78
tasks/deploy_thermostat.yml
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
---
|
||||||
|
- name: create docker-mounted-files directory
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "/usr/local/docker-mounted-files/docker-thermostat"
|
||||||
|
state: directory
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Template thermostat conf.yml
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: templates/thermostat-conf.yml.j2
|
||||||
|
dest: /usr/local/docker-mounted-files/docker-thermostat/conf.yml
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Build thermostat image
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: role_build_container_image
|
||||||
|
vars:
|
||||||
|
image: "{{ item }}"
|
||||||
|
with_items:
|
||||||
|
- repo_url: https://git.scimetis.net/yohan/docker-thermostat.git
|
||||||
|
repo_name: docker-thermostat
|
||||||
|
name: thermostat
|
||||||
|
result_var: build_result
|
||||||
|
|
||||||
|
- debug: var=build_result
|
||||||
|
when: build_result.changed
|
||||||
|
|
||||||
|
- name: Gather facts on thermostat container
|
||||||
|
containers.podman.podman_container_info:
|
||||||
|
name: thermostat
|
||||||
|
register: container_info
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- debug: var=container_info.containers[0].Config.Annotations.git_commit
|
||||||
|
when: container_info.containers | length == 1
|
||||||
|
|
||||||
|
- name: Set fact bool_recreate to true
|
||||||
|
set_fact:
|
||||||
|
bool_recreate: true
|
||||||
|
when:
|
||||||
|
- container_info.containers | length == 1
|
||||||
|
- container_info.containers[0].Config.Annotations.git_commit != commit
|
||||||
|
|
||||||
|
- name: create thermostat volume
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "/mnt/apps/volumes/thermostat"
|
||||||
|
state: directory
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Delete thermostat container
|
||||||
|
containers.podman.podman_container:
|
||||||
|
name: thermostat
|
||||||
|
state: absent
|
||||||
|
become: true
|
||||||
|
when: bool_recreate | default(false)
|
||||||
|
|
||||||
|
- name: Create thermostat container
|
||||||
|
containers.podman.podman_container:
|
||||||
|
name: thermostat
|
||||||
|
image: localhost/thermostat:latest
|
||||||
|
network:
|
||||||
|
- host
|
||||||
|
env:
|
||||||
|
TZ: "Europe/Paris"
|
||||||
|
GUNICORN_CMD_ARGS: "--bind=0.0.0.0:3002"
|
||||||
|
privileged: true
|
||||||
|
restart_policy: always
|
||||||
|
volume:
|
||||||
|
- /usr/local/docker-mounted-files/docker-thermostat/conf.yml:/root/conf.yml
|
||||||
|
- /mnt/apps/volumes/thermostat:/root/instance
|
||||||
|
- /run/udev:/run/udev
|
||||||
|
become: true
|
||||||
|
when: bool_recreate | default(false) or container_info.containers | length == 0
|
||||||
|
|
||||||
|
- name: Prune images
|
||||||
|
containers.podman.podman_prune:
|
||||||
|
image: true
|
||||||
|
become: true
|
201
templates/sensors-polling-conf.j2
Normal file
201
templates/sensors-polling-conf.j2
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
http_port: 3000
|
||||||
|
|
||||||
|
# The output of the command must be a JSON dict with metrics name as keys and metrics value as value.
|
||||||
|
polling_conf:
|
||||||
|
- name: teleinfo
|
||||||
|
metrics:
|
||||||
|
- name: Modane_elec_main_power
|
||||||
|
type: int
|
||||||
|
- name: Modane_elec_energy_index
|
||||||
|
type: int
|
||||||
|
executable: ./read_teleinfo.py
|
||||||
|
arguments:
|
||||||
|
- "-f"
|
||||||
|
- "custom_json"
|
||||||
|
# interval between sensors polling in seconds
|
||||||
|
polling_interval: 10.0
|
||||||
|
|
||||||
|
- name: Modane_temperature_single_bedroom
|
||||||
|
metrics:
|
||||||
|
- name: Modane_temperature_single_bedroom
|
||||||
|
type: float
|
||||||
|
executable: ./read_one-wire_sensor.py
|
||||||
|
arguments:
|
||||||
|
- "Modane_temperature_single_bedroom"
|
||||||
|
- "/26.3FA954020000/temperature"
|
||||||
|
|
||||||
|
- name: Modane_temperature_double_bedroom
|
||||||
|
metrics:
|
||||||
|
- name: Modane_temperature_double_bedroom
|
||||||
|
type: float
|
||||||
|
executable: ./read_one-wire_sensor.py
|
||||||
|
arguments:
|
||||||
|
- "Modane_temperature_double_bedroom"
|
||||||
|
- "/26.A6E96B020000/temperature"
|
||||||
|
|
||||||
|
- name: Modane_temperature_living_room
|
||||||
|
metrics:
|
||||||
|
- name: Modane_temperature_living_room
|
||||||
|
type: float
|
||||||
|
executable: ./read_one-wire_sensor.py
|
||||||
|
arguments:
|
||||||
|
- "Modane_temperature_living_room"
|
||||||
|
- "/26.23D26B020000/temperature"
|
||||||
|
|
||||||
|
- name: Modane_temperature_bathroom
|
||||||
|
metrics:
|
||||||
|
- name: Modane_temperature_bathroom
|
||||||
|
type: float
|
||||||
|
executable: ./read_one-wire_sensor.py
|
||||||
|
arguments:
|
||||||
|
- "Modane_temperature_bathroom"
|
||||||
|
- "/26.A4C354020000/temperature"
|
||||||
|
|
||||||
|
- name: Modane_temperature_cellar
|
||||||
|
metrics:
|
||||||
|
- name: Modane_temperature_cellar
|
||||||
|
type: float
|
||||||
|
executable: ./read_yocto_sensor.py
|
||||||
|
arguments:
|
||||||
|
- "Modane_temperature_cellar"
|
||||||
|
- "YTemperature"
|
||||||
|
- "METEOMK1-65C96"
|
||||||
|
|
||||||
|
#- name: Modane_temperature_outside
|
||||||
|
# metrics:
|
||||||
|
# - name: Modane_temperature_outside
|
||||||
|
# type: float
|
||||||
|
|
||||||
|
- name: Modane_temperature_closet
|
||||||
|
metrics:
|
||||||
|
- name: Modane_temperature_closet
|
||||||
|
type: float
|
||||||
|
executable: ./read_yocto_sensor.py
|
||||||
|
arguments:
|
||||||
|
- "Modane_temperature_closet"
|
||||||
|
- "YTemperature"
|
||||||
|
- "TMPSENS1-EDF2D"
|
||||||
|
|
||||||
|
- name: Modane_humidity_single_bedroom
|
||||||
|
metrics:
|
||||||
|
- name: Modane_humidity_single_bedroom
|
||||||
|
type: float
|
||||||
|
executable: ./read_one-wire_sensor.py
|
||||||
|
arguments:
|
||||||
|
- "Modane_humidity_single_bedroom"
|
||||||
|
- "/26.3FA954020000/humidity"
|
||||||
|
|
||||||
|
- name: Modane_humidity_double_bedroom
|
||||||
|
metrics:
|
||||||
|
- name: Modane_humidity_double_bedroom
|
||||||
|
type: float
|
||||||
|
executable: ./read_one-wire_sensor.py
|
||||||
|
arguments:
|
||||||
|
- "Modane_humidity_double_bedroom"
|
||||||
|
- "/26.A6E96B020000/humidity"
|
||||||
|
|
||||||
|
- name: Modane_humidity_bathroom
|
||||||
|
metrics:
|
||||||
|
- name: Modane_humidity_bathroom
|
||||||
|
type: float
|
||||||
|
executable: ./read_one-wire_sensor.py
|
||||||
|
arguments:
|
||||||
|
- "Modane_humidity_bathroom"
|
||||||
|
- "/26.A4C354020000/humidity"
|
||||||
|
|
||||||
|
- name: Modane_humidity_living_room
|
||||||
|
metrics:
|
||||||
|
- name: Modane_humidity_living_room
|
||||||
|
type: float
|
||||||
|
executable: ./read_one-wire_sensor.py
|
||||||
|
arguments:
|
||||||
|
- "Modane_humidity_living_room"
|
||||||
|
- "/26.23D26B020000/humidity"
|
||||||
|
|
||||||
|
- name: Modane_humidity_cellar
|
||||||
|
metrics:
|
||||||
|
- name: Modane_humidity_cellar
|
||||||
|
type: float
|
||||||
|
executable: ./read_yocto_sensor.py
|
||||||
|
arguments:
|
||||||
|
- "Modane_humidity_cellar"
|
||||||
|
- "YHumidity"
|
||||||
|
- "METEOMK1-65C96"
|
||||||
|
|
||||||
|
#- name: Modane_humidity_outside
|
||||||
|
# metrics:
|
||||||
|
# - name: Modane_humidity_outside
|
||||||
|
# type: float
|
||||||
|
# executable: ./read_yocto_sensor.py
|
||||||
|
# arguments:
|
||||||
|
# - "Modane_humidity_outside"
|
||||||
|
# - "YHumidity"
|
||||||
|
# - ""
|
||||||
|
|
||||||
|
- name: Modane_luminosity_single_bedroom
|
||||||
|
metrics:
|
||||||
|
- name: Modane_luminosity_single_bedroom
|
||||||
|
type: int
|
||||||
|
executable: ./read_one-wire_sensor.py
|
||||||
|
arguments:
|
||||||
|
- "Modane_luminosity_single_bedroom"
|
||||||
|
- "/26.3FA954020000/vis"
|
||||||
|
|
||||||
|
- name: Modane_luminosity_double_bedroom
|
||||||
|
metrics:
|
||||||
|
- name: Modane_luminosity_double_bedroom
|
||||||
|
type: int
|
||||||
|
executable: ./read_one-wire_sensor.py
|
||||||
|
arguments:
|
||||||
|
- "Modane_luminosity_double_bedroom"
|
||||||
|
- "/26.A6E96B020000/vis"
|
||||||
|
|
||||||
|
- name: Modane_luminosity_bathroom
|
||||||
|
metrics:
|
||||||
|
- name: Modane_luminosity_bathroom
|
||||||
|
type: int
|
||||||
|
executable: ./read_one-wire_sensor.py
|
||||||
|
arguments:
|
||||||
|
- "Modane_luminosity_bathroom"
|
||||||
|
- "/26.A4C354020000/vis"
|
||||||
|
|
||||||
|
- name: Modane_luminosity_living_room
|
||||||
|
metrics:
|
||||||
|
- name: Modane_luminosity_living_room
|
||||||
|
type: int
|
||||||
|
executable: ./read_one-wire_sensor.py
|
||||||
|
arguments:
|
||||||
|
- "Modane_luminosity_living_room"
|
||||||
|
- "/26.23D26B020000/vis"
|
||||||
|
|
||||||
|
- name: Modane_pressure_cellar
|
||||||
|
metrics:
|
||||||
|
- name: Modane_pressure_cellar
|
||||||
|
type: float
|
||||||
|
executable: ./read_yocto_sensor.py
|
||||||
|
arguments:
|
||||||
|
- "Modane_pressure_cellar"
|
||||||
|
- "YPressure"
|
||||||
|
- "METEOMK1-65C96"
|
||||||
|
|
||||||
|
- name: Modane_CO2_single_bedroom
|
||||||
|
metrics:
|
||||||
|
- name: Modane_CO2_single_bedroom
|
||||||
|
type: float
|
||||||
|
executable: ./read_yocto_sensor.py
|
||||||
|
arguments:
|
||||||
|
- "Modane_CO2_single_bedroom"
|
||||||
|
- "YCarbonDioxide"
|
||||||
|
- "any"
|
||||||
|
|
||||||
|
# Default interval between sending to record API in seconds
|
||||||
|
default_recording_interval: 600.0
|
||||||
|
|
||||||
|
# Default interval between sensors polling in seconds
|
||||||
|
default_polling_interval: 600.0
|
||||||
|
|
||||||
|
recording_api_key: "{{ modane_server_thermostat_api_key }}"
|
||||||
|
|
||||||
|
post_url:
|
||||||
|
int: "http://ovh1.scimetis.net:3001/integer_metric/add"
|
||||||
|
float: "http://ovh1.scimetis.net:3001/float_metric/add"
|
Loading…
Reference in New Issue
Block a user