Mercurial > code > home > repos > homeauto
annotate espNode/tasks.py @ 1716:2bed2f68243c
older work
author | drewp@bigasterisk.com |
---|---|
date | Sun, 07 Aug 2022 02:25:40 -0700 |
parents | 33747dcf57ea |
children | e9540ee0cf73 |
rev | line source |
---|---|
596 | 1 from invoke import task |
2 | |
1701 | 3 port = '/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0' |
4 | |
5 tag = 'esphome/esphome' | |
6 | |
1576
0bf15b97f25a
don't insist on ttyUSB0 device when doing OTA updates
drewp@bigasterisk.com
parents:
800
diff
changeset
|
7 esphome = f'docker run --rm -v `pwd`:/config -v /usr/share/fonts:/usr/share/fonts -it {tag}' |
1701 | 8 esphomeUsb = esphome.replace('--rm', f'--rm --device={port}') |
1576
0bf15b97f25a
don't insist on ttyUSB0 device when doing OTA updates
drewp@bigasterisk.com
parents:
800
diff
changeset
|
9 # on dash for lcd code for theater display: |
0bf15b97f25a
don't insist on ttyUSB0 device when doing OTA updates
drewp@bigasterisk.com
parents:
800
diff
changeset
|
10 #tag = 'esphome_dev' |
0bf15b97f25a
don't insist on ttyUSB0 device when doing OTA updates
drewp@bigasterisk.com
parents:
800
diff
changeset
|
11 #esphome = '/home/drewp/Downloads/esphome/env/bin/esphome' |
800 | 12 |
13 @task | |
14 def get_dev_esphome(ctx): | |
15 ctx.run(f'docker build -t esphome_dev -f docker/Dockerfile https://github.com/MasterTim17/esphome.git#dev') | |
686 | 16 |
17 @task | |
18 def pull_esphome(ctx): | |
19 ctx.run(f"docker pull {tag}") | |
20 | |
596 | 21 @task |
22 def program_board_over_usb(ctx, board): | |
800 | 23 board = board.replace('.yaml', '') |
773 | 24 print('connect gnd, 3v3, rx/tx per https://randomnerdtutorials.com/esp32-cam-video-streaming-web-server-camera-home-assistant/, ') |
25 print('rts to reset (if possible), dtr to gpio0 per https://github.com/espressif/esptool/wiki/ESP32-Boot-Mode-Selection#automatic-bootloader') | |
1701 | 26 ctx.run(f"{esphomeUsb} run {board}.yaml --device={port}", pty=True, echo=True) |
596 | 27 |
28 @task | |
29 def program_board_over_wifi(ctx, board): | |
1716 | 30 global esphome |
800 | 31 board = board.replace('.yaml', '') |
1716 | 32 if board == 'theater_lcd': |
33 tag = 'esphome_dev' | |
34 esphome = 'esphome-local/env/bin/esphome' | |
35 | |
800 | 36 ctx.run(f"{esphome} {board}.yaml run", pty=True) |
596 | 37 |
1716 | 38 |
596 | 39 @task |
40 def monitor_usb(ctx, board): | |
800 | 41 board = board.replace('.yaml', '') |
1701 | 42 ctx.run(f"{esphomeUsb} logs {board}.yaml --device={port}", pty=True) |
686 | 43 |
44 # device up? | |
45 # nmap -Pn -p 3232,6053 10.2.0.21 |