From ee242e5811b7b99d08c74d299c0de8739f9f9810 Mon Sep 17 00:00:00 2001 From: Przemek Grondek Date: Thu, 22 Aug 2024 22:23:02 +0200 Subject: [PATCH] Moisture warning for plants --- home-assistant.yml | 1 + roles/config/files/configuration.yaml | 9 +++++++++ roles/scripts/files/10.modes.yaml | 2 ++ roles/scripts/tasks/templates.yml | 6 ++++++ .../scripts/templates/water-plants-check.yaml.j2 | 15 +++++++++++++++ vars/plants.yml | 10 ++++++++++ 6 files changed, 43 insertions(+) create mode 100644 roles/scripts/templates/water-plants-check.yaml.j2 create mode 100644 vars/plants.yml diff --git a/home-assistant.yml b/home-assistant.yml index c7b398d..74c59c5 100644 --- a/home-assistant.yml +++ b/home-assistant.yml @@ -10,6 +10,7 @@ - vars/availability.yml - vars/shopping-list.yml - vars/lights-automations.yml + - vars/plants.yml pre_tasks: - import_tasks: tasks/clean.yml diff --git a/roles/config/files/configuration.yaml b/roles/config/files/configuration.yaml index 698983a..c4d13ed 100644 --- a/roles/config/files/configuration.yaml +++ b/roles/config/files/configuration.yaml @@ -412,6 +412,15 @@ plant: battery: sensor.citrus_sensor_battery min_moisture: 30 max_moisture: 50 + calamondin: + sensors: + temperature: sensor.calamondin_temperature + moisture: sensor.calamondin_moisture + brightness: sensor.calamondin_illuminance + conductivity: sensor.calamondin_conductivity + battery: sensor.calamondin_battery + min_moisture: 30 + max_moisture: 50 coffee: sensors: temperature: sensor.coffee_plant_sensor_temperature diff --git a/roles/scripts/files/10.modes.yaml b/roles/scripts/files/10.modes.yaml index 045441b..832e4b7 100644 --- a/roles/scripts/files/10.modes.yaml +++ b/roles/scripts/files/10.modes.yaml @@ -104,6 +104,7 @@ good_morning: icon: mdi:weather-sunny sequence: - service: script.check_unavailable + - service: script.water_plants_check - service: script.alarm_disarm - service: input_select.select_option data: @@ -241,6 +242,7 @@ arrive_home: icon: mdi:home-import-outline sequence: - service: script.alarm_disarm + - service: script.water_plants_check - service: input_select.select_option data: option: Day diff --git a/roles/scripts/tasks/templates.yml b/roles/scripts/tasks/templates.yml index 6f27f4a..2a27e5f 100644 --- a/roles/scripts/tasks/templates.yml +++ b/roles/scripts/tasks/templates.yml @@ -11,3 +11,9 @@ template: src: 'alarm.yaml.j2' dest: './build/scripts/alarm.yaml' + +- name: Build plants script + delegate_to: localhost + template: + src: 'water-plants-check.yaml.j2' + dest: './build/scripts/water-plants-check.yaml' diff --git a/roles/scripts/templates/water-plants-check.yaml.j2 b/roles/scripts/templates/water-plants-check.yaml.j2 new file mode 100644 index 0000000..23940e1 --- /dev/null +++ b/roles/scripts/templates/water-plants-check.yaml.j2 @@ -0,0 +1,15 @@ +water_plants_check: + alias: '[Info] check water plants' + sequence: +{% for plant in plants %} + - choose: + - conditions: + - condition: numeric_state + entity_id: {{ plant.entity_id }} + attribute: moisture + below: {{ plant.min_humidity }} + sequence: + - action: notify.mobile_app_iphone + data: + message: {{ plant.name }} moisture below {{ plant.min_humidity }}%, water plant +{% endfor %} diff --git a/vars/plants.yml b/vars/plants.yml new file mode 100644 index 0000000..9a86915 --- /dev/null +++ b/vars/plants.yml @@ -0,0 +1,10 @@ +plants: + - name: Citrus + entity_id: plant.citrus + min_humidity: 30 + - name: Calamondin + entity_id: plant.calamondin + min_humidity: 30 + - name: Coffee + entity_id: plant.coffee + min_humidity: 30