view service/frontDoorLock/tasks.py @ 1683:437d7263b515

checkpoint service/frontDoorLock
author drewp@bigasterisk.com
date Mon, 27 Sep 2021 23:13:49 -0700
parents 3f6055cfccb2
children c41af73a410f
line wrap: on
line source

from invoke import Collection, task

import sys
sys.path.append('/my/proj/release')
from serv_tasks import serv_tasks

ns = Collection()
serv_tasks(ns, 'serv.n3', 'front_door_lock')

@task
def program_board_over_usb(ctx):
    tag = 'esphome/esphome'
    ctx.run(f"docker pull {tag}")
    ctx.run(f"docker run --rm -v `pwd`:/config --device=/dev/ttyUSB0 -it {tag} door.yaml run", pty=True)

@task
def monitor_usb(ctx):
    tag = 'esphome/esphome'
    ctx.run(f"docker run --rm -v `pwd`:/config --device=/dev/ttyUSB0 -it {tag} door.yaml logs", pty=True)

@task
def tail_mqtt(ctx):
    ctx.run(f'mosquitto_sub -h bang -p 10210 -d -v -t \#')

@task
def mqtt_force_open(ctx):
    ctx.run(f'mosquitto_pub -h bang -p 10210 -t frontdoorlock/switch/strike/command -m ON')

@task
def mqtt_force_lock(ctx):
    ctx.run(f'mosquitto_pub -h bang -p 10210 -t frontdoorlock/switch/strike/command -m OFF')