Tag: HOWTO

  • HOWTO: login via ssh into home assistant’s esphome container

    I work a lot on esphome configs, I’m often doing this via ssh.
    I got annoyed that I always have to ssh to home assistant, search for the container’s name, login to that, switch to /config/esphome.

    So here’s a script that does all of that, the home assistant host is called “ha” in my network:

    #!/bin/bash
    HOMEASSISTANT="ha"
    ESPHOME_DOCKER_CONTAINER=$(ssh $HOMEASSISTANT 'docker container list|grep esphome'|awk '{print $10}' -)
    ssh -t $HOMEASSISTANT "docker exec -it $ESPHOME_DOCKER_CONTAINER bash -c 'cd /config/esphome && exec bash'"                                                                                                                                                                                                                                                                                                                                                                                                                                                                     

    As esphome tends to hang up from time to time in my setup, I wrote a script to restart the esphome container too:

    #!/bin/bash
    HOMEASSISTANT="ha"
    ESPHOME_DOCKER_CONTAINER=$(ssh $HOMEASSISTANT 'docker container list|grep esphome'|awk '{print $10}' -)
    ssh -t $HOMEASSISTANT "docker container restart $ESPHOME_DOCKER_CONTAINER"