esphome / esphome-vscode

ESPHome VSCode plugin
Other
75 stars 14 forks source link

How to configure it when running ESPHome locally? #72

Closed distante closed 1 year ago

distante commented 1 year ago

I am having problems understanding how to get the plugin to work when running esphome locally on my mac.

I start ESPHOMe with this docker-compose

version: '3.3'
services:
  esphome:
    container_name: esphome
    image: esphome/esphome
    volumes:
      - ./esphome/config:/config
      - ./esphome/cache:/cache
      - /etc/localtime:/etc/localtime:ro
    restart: never 
    # restart: always
    # --- WINDOWS / LINUX ---

  # privileged: true
  # network_mode: host
    # --- END WINDOWS / LINUX ---

    # --- MACOS ---
    ports:
      - '6052:6052'
    environment:
      - ESPHOME_DASHBOARD_USE_PING=true
    # --- END MACOS ---

How can I let the plugin know that it should take a look at localhost:6052 to get the info when I open my esphome/config/device-config.yml file?

I am running this completely outside of home assistant.

glmnet commented 1 year ago

this will be a "dashboard" mode, i.e. esphome is not locally on the vscode os.

I'm not sure if esphome has a login form enabled when running in docker, in that case you'll have to disable it, may be with and environment setting, something like - ESPHOME_LEAVE_FRONT_DOOR_OPEN=true but again I'm not sure this is needed or how it's done.

You know it should work if you go to http://localhost:6052/vscode and it says: Can "Upgrade" only to "WebSocket".

There is nothing to do on the device-config.yml file, you have to go to esphome settings ui in vscode image make sure to set localhost:6052 and dashboard for validator

last when you open your yaml file is vscode make sure at the right of the status bar it says ESPHome instead of Yaml or something else

distante commented 1 year ago

Ah! Thank worked changing the settings of the plugin, and, in my case, manually set ESPHOME instead of YAML`.

No extra changes required.

I think it would be good to have that screenshot on the README. To be honest, I didn't even realize that there were configurations in VS Code for the plugin. 🫣

Thank you!