Mercurial > code > home > repos > homeauto
comparison espNode/tasks.py @ 1741:097bfd91187d
cam deploy code that might not work
author | drewp@bigasterisk.com |
---|---|
date | Fri, 01 Sep 2023 17:14:25 -0700 |
parents | 82213d91471c |
children |
comparison
equal
deleted
inserted
replaced
1740:c77b5ab7b99d | 1741:097bfd91187d |
---|---|
1 from invoke import task | 1 from invoke import task |
2 from pathlib import Path | 2 from pathlib import Path |
3 | 3 |
4 port = '/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0' | 4 port = 'usb-1a86_USB_Serial-if00-port0' |
5 | 5 |
6 tag = 'docker.io/esphome/esphome:2022.7.0-dev20220807' | 6 tag = 'docker.io/esphome/esphome:2023.2.4' |
7 | 7 |
8 esphome = ( | 8 esphome = ( |
9 'docker run --rm ' + # | 9 'docker run --rm ' + # |
10 '-v `pwd`:/config ' + # | 10 '-v `pwd`:/config ' + # |
11 '-v /usr/share/fonts:/usr/share/fonts ' + # | 11 '-v /usr/share/fonts:/usr/share/fonts ' + # |
57 | 57 |
58 # device up? | 58 # device up? |
59 # nmap -Pn -p 3232,6053 10.2.0.21 | 59 # nmap -Pn -p 3232,6053 10.2.0.21 |
60 | 60 |
61 | 61 |
62 @task | |
63 def program_cam_usb(ctx, name='0'): | |
64 idVendor = '1a86' | |
65 port = f'/dev/serial/by-id/usb-{idVendor}_USB_Serial-if00-port0' | |
66 ctx.run( | |
67 f"{esphome} " # | |
68 + f"-s camname cam{name}" # | |
69 + " run cam.yaml " # | |
70 + f'--device={port} ', | |
71 pty=True, | |
72 echo=True) | |
73 | |
74 | 62 |
75 # -s k v seemed to have no effect | 63 # -s k v seemed to have no effect |
76 def config_replace(in_file, out_file, repls): | 64 def config_replace(in_file, out_file, repls): |
77 yaml_text = open(in_file, 'rt').read() | 65 yaml_text = open(in_file, 'rt').read() |
78 for k, v in repls.items(): | 66 for k, v in repls.items(): |
86 ctx.run(f'mkdir -p {tmp}') | 74 ctx.run(f'mkdir -p {tmp}') |
87 ctx.run(f'rsync -a component secrets.yaml {tmp}') | 75 ctx.run(f'rsync -a component secrets.yaml {tmp}') |
88 return tmp | 76 return tmp |
89 | 77 |
90 | 78 |
79 def replace_yaml_for_cam(inPath, outPath, camName): | |
80 config_replace(inPath, outPath, { | |
81 '$build_path': outPath.parent, | |
82 '$addr': '10.2.0.22', | |
83 '$name': camName, | |
84 }) | |
85 | |
86 @task | |
87 def program_cam_usb(ctx, name='cam-foo'): | |
88 idVendor = '1a86' | |
89 port = f'/dev/serial/by-id/usb-{idVendor}_USB_Serial-if00-port0' | |
90 tmp = prep_tmp(ctx, 'cam') | |
91 tmpyaml = tmp / 'cam.yaml' | |
92 replace_yaml_for_cam("cam.yaml", tmpyaml, name) | |
93 ctx.run( | |
94 f"{esphome} " # | |
95 + f" run {tmpyaml} " # | |
96 + f'--device={port} ', | |
97 pty=True, | |
98 echo=True) | |
99 | |
91 @task | 100 @task |
92 def program_cam_ota(ctx, name='0'): | 101 def program_cam_ota(ctx, name='0'): |
93 tmp = prep_tmp(ctx, 'cam') | 102 tmp = prep_tmp(ctx, 'cam') |
94 tmpyaml = tmp / 'cam.yaml' | 103 tmpyaml = tmp / 'cam.yaml' |
95 config_replace('cam.yaml', tmpyaml, { | 104 replace_yaml_for_cam("cam.yaml", tmpyaml, name) |
96 '$build_path': tmp, | |
97 '$addr': '10.2.0.22', | |
98 '$name': f'cam{name}' | |
99 }) | |
100 ctx.run( | 105 ctx.run( |
101 f"{esphome} " # | 106 f"{esphome} " # |
102 + f"run {tmpyaml} " # | 107 + f"run {tmpyaml} " # |
103 + "--device=OTA --no-logs" # | 108 + "--device=OTA --no-logs" # |
104 , | 109 , |