initial commit

This commit is contained in:
greywolf 2019-09-29 19:30:33 +02:00
commit 9db11dbc76
9 changed files with 167 additions and 0 deletions

28
tasks/main.yml Normal file
View file

@ -0,0 +1,28 @@
---
# tasks file for shelly_shutter
#
- name: shelly_shutter | configure as shutter
uri:
url: "http://{{ ansible_host }}/settings?mode=roller"
method: GET
register: basic
tags:
- configuration
- debug:
msg: "{{ lookup('dict',basic) }}"
verbosity: 1
- debug:
msg: "{{ basic['json']['device'] }}"
verbosity: 1
- name: shelly_shutter | run per_shutter tasks
# https://www.reddit.com/r/ansible/comments/6zt66i/looping_over_a_block_of_tasks/
include: "per_shutter.yml current_shutter={{ cur_shutter }}"
loop_control:
loop_var: cur_shutter
loop: "{{ range(0,basic.json.device.num_rollers)|list }}"
# https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html#standard-loops

23
tasks/per_shutter.yml Normal file
View file

@ -0,0 +1,23 @@
---
- name: shelly_shutter per_shutter | configure schedule
# https://www.shellhacks.com/ansible-when-variable-is-defined-exists-empty-true/
when: shutter_schedule_rule is defined
uri:
url: "http://{{ ansible_host }}/settings/roller/{{ current_shutter }}"
method: POST
body:
schedule: true
schedule_rule: "{{shutter_schedule_rule }}"
tags:
- configuration
- name: shelly_shutter per_shutter | configure basics
# https://www.shellhacks.com/ansible-when-variable-is-defined-exists-empty-true/
uri:
url: "http://{{ ansible_host }}/settings/roller/{{ current_shutter }}"
method: POST
body:
schedule: true
schedule_rule: "{{shutter_schedule_rule }}"
tags:
- configuration