Mercurial > code > home > repos > homeauto
annotate service/frontDoorLock/tasks.py @ 575:1209229cd56e
faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
Ignore-this: f8fca86291d3082cb309524fbd5baf1c
author | drewp@bigasterisk.com |
---|---|
date | Mon, 06 May 2019 21:06:08 -0700 |
parents | 2a24a6c7a843 |
children | 013e2a89b345 |
rev | line source |
---|---|
563 | 1 from invoke import task |
377
5b690bfc31b2
docker/etc initial version of front door mqtt<->rdf using some rx
drewp@bigasterisk.com
parents:
diff
changeset
|
2 |
563 | 3 JOB = 'front_door_lock' |
4 PORT = 10011 | |
5 TAG = f'bang6:5000/{JOB}_x86:latest' | |
6 ANSIBLE_TAG = 'door' | |
7 | |
8 @task | |
9 def build_image(ctx): | |
10 ctx.run(f'docker build --network=host -t {TAG} .') | |
11 | |
12 @task(pre=[build_image]) | |
13 def push_image(ctx): | |
14 ctx.run(f'docker push {TAG}') | |
377
5b690bfc31b2
docker/etc initial version of front door mqtt<->rdf using some rx
drewp@bigasterisk.com
parents:
diff
changeset
|
15 |
563 | 16 @task(pre=[build_image]) |
17 def shell(ctx): | |
18 ctx.run(f'docker run --name={JOB}_shell --rm -it --cap-add SYS_PTRACE --net=host {TAG} /bin/bash', pty=True) | |
426
bfe555dd0c91
talk to store graph, second button for holding unlocked, etc
drewp@bigasterisk.com
parents:
379
diff
changeset
|
19 |
563 | 20 @task(pre=[build_image]) |
21 def local_run(ctx): | |
22 ctx.run(f'docker run --name={JOB}_local --rm -it --net=host -v `pwd`/index.html:/opt/index.html {TAG} python3 ./front_door_lock.py -v', pty=True) | |
23 | |
24 @task(pre=[push_image]) | |
25 def redeploy(ctx): | |
26 ctx.run(f'sudo /my/proj/ansible/playbook -l bang -t {ANSIBLE_TAG}') | |
27 ctx.run(f'supervisorctl -s http://bang:9001/ restart {JOB}_{PORT}') | |
567
2a24a6c7a843
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
drewp@bigasterisk.com
parents:
563
diff
changeset
|
28 |
2a24a6c7a843
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
drewp@bigasterisk.com
parents:
563
diff
changeset
|
29 @task |
2a24a6c7a843
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
drewp@bigasterisk.com
parents:
563
diff
changeset
|
30 def program_board_over_usb(ctx): |
2a24a6c7a843
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
drewp@bigasterisk.com
parents:
563
diff
changeset
|
31 tag = 'esphome/esphome' |
2a24a6c7a843
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
drewp@bigasterisk.com
parents:
563
diff
changeset
|
32 ctx.run(f"docker pull {tag}") |
2a24a6c7a843
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
drewp@bigasterisk.com
parents:
563
diff
changeset
|
33 ctx.run(f"docker run --rm -v `pwd`:/config --device=/dev/ttyUSB0 -it {tag} door.yaml run", pty=True) |
2a24a6c7a843
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
drewp@bigasterisk.com
parents:
563
diff
changeset
|
34 |
2a24a6c7a843
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
drewp@bigasterisk.com
parents:
563
diff
changeset
|
35 @task |
2a24a6c7a843
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
drewp@bigasterisk.com
parents:
563
diff
changeset
|
36 def monitor_usb(ctx): |
2a24a6c7a843
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
drewp@bigasterisk.com
parents:
563
diff
changeset
|
37 tag = 'esphome/esphome' |
2a24a6c7a843
update esphome version. rename esp board to be distinct from pi board. new invoke rules for esp programming
drewp@bigasterisk.com
parents:
563
diff
changeset
|
38 ctx.run(f"docker run --rm -v `pwd`:/config --device=/dev/ttyUSB0 -it {tag} door.yaml logs", pty=True) |
575
1209229cd56e
faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp@bigasterisk.com
parents:
567
diff
changeset
|
39 |
1209229cd56e
faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp@bigasterisk.com
parents:
567
diff
changeset
|
40 @task |
1209229cd56e
faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp@bigasterisk.com
parents:
567
diff
changeset
|
41 def tail_mqtt(ctx): |
1209229cd56e
faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp@bigasterisk.com
parents:
567
diff
changeset
|
42 ctx.run(f'mosquitto_sub -h bang -p 10010 -d -v -t \#') |
1209229cd56e
faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp@bigasterisk.com
parents:
567
diff
changeset
|
43 |
1209229cd56e
faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp@bigasterisk.com
parents:
567
diff
changeset
|
44 @task |
1209229cd56e
faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp@bigasterisk.com
parents:
567
diff
changeset
|
45 def mqtt_force_open(ctx): |
1209229cd56e
faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp@bigasterisk.com
parents:
567
diff
changeset
|
46 ctx.run(f'mosquitto_pub -h bang -p 10010 -t frontdoorlock/switch/strike/command -m ON') |
1209229cd56e
faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp@bigasterisk.com
parents:
567
diff
changeset
|
47 |
1209229cd56e
faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp@bigasterisk.com
parents:
567
diff
changeset
|
48 @task |
1209229cd56e
faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp@bigasterisk.com
parents:
567
diff
changeset
|
49 def mqtt_force_lock(ctx): |
1209229cd56e
faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp@bigasterisk.com
parents:
567
diff
changeset
|
50 ctx.run(f'mosquitto_pub -h bang -p 10010 -t frontdoorlock/switch/strike/command -m OFF') |
1209229cd56e
faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py
drewp@bigasterisk.com
parents:
567
diff
changeset
|
51 |