Skip to content

Commit

Permalink
add documentation, improve the readme, change the default timer for s…
Browse files Browse the repository at this point in the history
…cheduling, add custom card for homeassistant instructions
  • Loading branch information
jpizquierdo committed Aug 3, 2023
1 parent b87d1cf commit 11e22ed
Show file tree
Hide file tree
Showing 12 changed files with 198 additions and 5 deletions.
23 changes: 21 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,19 @@ Core functionality
============
- Telegram interface: Logging and commands
- Scheduler interface: Task scheduling
- GPIO interrace: Control the relay shield interface
- MQTT interface: to be able to control it from homeassistant or any other MQTT device/service.
- GPIO interface: Control the relay shield interface

Only GPIO interface is mandatory.
MQTT and telegram interfaces are optional to be able to control and monitor the system, but not mandatory.
Scheduler interface is not mandatory if MQTT or telegram interface is selected. If not, the scheduler will be activated by default and no need to activate the holidays option. It will be working at the interval of ``config.json``. It means that when draco app starts, it will activate water_pump and valve1 at ``water_start_time_HH:water_start_time_MM`` till ``water_stop_time_HH:water_stop_time_MM with an interval`` of ``holidays_frequency_days`` (first execution in ``holidays_frequency_days`` days)

Combinations:
GPIO + scheduler
GPIO + Telegram
GPIO + MQTT
GPIO + Telegram + MQTT
GPIO + scheduler + Telegram + MQTT

Future functionality
============
Expand All @@ -26,7 +38,14 @@ Installing
$ git clone https://github.com/jpizquierdo/Draco.git
$ cd Draco
$ pip install -r requirements.txt
$ python -m venv .venv
$ .venv/bin/pip install -r requirements.txt
Usage
============
.. code:: shell
$ ~/Draco/.venv/bin/python ~/Draco/draco.py -c ~/Draco/config/config.json
Getting help or sharing your idea
============
Expand Down
2 changes: 1 addition & 1 deletion config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"water_start_time_HH": "10",
"water_start_time_MM": "00",
"water_stop_time_HH": "10",
"water_stop_time_MM": "15",
"water_stop_time_MM": "02",
"enable_alive_logging": false
},
"mqtt": {
Expand Down
18 changes: 18 additions & 0 deletions docs/homeassistant/automation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#automation for watering system:
#automation:
- id: 'automated_watering'
alias: watering 1
trigger:
platform: template
value_template: "{{ states('sensor.time') == states('sensor.water_time_1') }}"
condition:
condition: template
value_template: >
{% set today = 'input_boolean.wateringweekday_' ~ now().strftime("%a") | lower ~ '_1' %}
{{ is_state('input_boolean.wateringstatus_1', 'on') and is_state(today, 'on') }}
action:
- service: switch.turn_on
entity_id: switch.bomba_riego
- delay: "{{ states('input_number.wateringduringminutes_1') | multiply(60) | int }}"
- service: switch.turn_off
entity_id: switch.bomba_riego
5 changes: 5 additions & 0 deletions docs/homeassistant/configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
input_boolean: !include input_boolean.yaml
input_number: !include input_number.yaml
sensor: !include sensor.yaml
mqtt: !include mqtt_draco_watering.yaml
automation: !include automation.yaml
26 changes: 26 additions & 0 deletions docs/homeassistant/input_boolean.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#watering system
#input_boolean:
wateringstatus_1:
name: Water Station 1
icon: mdi:water-pump
wateringweekday_mon_1:
name: Monday
icon: mdi:calendar
wateringweekday_tue_1:
name: Tuesday
icon: mdi:calendar
wateringweekday_wed_1:
name: Wednesday
icon: mdi:calendar
wateringweekday_thu_1:
name: Thursday
icon: mdi:calendar
wateringweekday_fri_1:
name: Friday
icon: mdi:calendar
wateringweekday_sat_1:
name: Saturday
icon: mdi:calendar
wateringweekday_sun_1:
name: Sunday
icon: mdi:calendar
19 changes: 19 additions & 0 deletions docs/homeassistant/input_number.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#watering system
#input_number:
wateringhourstart_1:
name: Hour
min: 00
max: 23
step: 1
icon: mdi:clock-start
wateringminutesstart_1:
name: Minutes
min: 00
max: 59
step: 1
wateringduringminutes_1:
name: Watering time [min]
min: 00
max: 5
step: 1
icon: mdi:water-sync
86 changes: 86 additions & 0 deletions docs/homeassistant/lovelace_watering.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#lovelace UI for watering card
type: vertical-stack
cards:
- type: entities
entities:
- entity: input_boolean.wateringstatus_1
name: Mode
- entity: sensor.water_time_1
name: Water Time
- entity: input_number.wateringhourstart_1
- entity: input_number.wateringminutesstart_1
- entity: input_number.wateringduringminutes_1
title: Riego
show_header_toggle: false
- type: horizontal-stack
cards:
- type: button
tap_action:
action: toggle
hold_action:
action: none
show_icon: true
show_name: true
entity: input_boolean.wateringweekday_mon_1
name: Mon
icon_height: 40px
- type: button
tap_action:
action: toggle
hold_action:
action: none
show_icon: true
show_name: true
entity: input_boolean.wateringweekday_tue_1
name: Tue
icon_height: 40px
- type: button
tap_action:
action: toggle
hold_action:
action: none
show_icon: true
show_name: true
entity: input_boolean.wateringweekday_wed_1
name: Wed
icon_height: 40px
- type: button
tap_action:
action: toggle
hold_action:
action: none
show_icon: true
show_name: true
entity: input_boolean.wateringweekday_thu_1
name: Thu
icon_height: 40px
- type: button
tap_action:
action: toggle
hold_action:
action: none
show_icon: true
show_name: true
entity: input_boolean.wateringweekday_fri_1
name: Fri
icon_height: 40px
- type: button
tap_action:
action: toggle
hold_action:
action: none
show_icon: true
show_name: true
entity: input_boolean.wateringweekday_sat_1
name: Sat
icon_height: 40px
- type: button
tap_action:
action: toggle
hold_action:
action: none
show_icon: true
show_name: true
entity: input_boolean.wateringweekday_sun_1
name: Sun
icon_height: 40px
2 changes: 2 additions & 0 deletions docs/homeassistant/mqtt_draco_watering.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#watering system
#mqtt:
switch:
- unique_id: draco_waterpump
name: "Bomba riego"
Expand Down
3 changes: 3 additions & 0 deletions docs/homeassistant/readme.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
How to create a custom card in home assistant
=======================
Modify the configuration.yaml and add all the files .yaml except lovelace_watering.yaml, that it the yaml code that you have to introduce in a custom card in the UI of homeassistant
11 changes: 11 additions & 0 deletions docs/homeassistant/sensor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#watering system
#sensor:
- platform: template
sensors:
water_time_1:
friendly_name: 'Water Time 1'
value_template: "{{'{:02d}:{:02d}'.format(states('input_number.wateringhourstart_1') | int, states('input_number.wateringminutesstart_1') | int) }}"

- platform: time_date
display_options:
- 'time'
6 changes: 6 additions & 0 deletions docs/systemd/how_to_systemd.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
How to configure a systemd service
=======================
.. code:: shell
$ cp draco.service ~/.config/systemd/user/draco.service
$ systemctl --user enable draco.service
2 changes: 0 additions & 2 deletions docs/systemd/how_to_systemd.txt

This file was deleted.

0 comments on commit 11e22ed

Please sign in to comment.