Vscode extension

Can you list your relevant installation steps so I can understand better your environment?

OTA link is tested by me under Windows only

1 Like

Sure (and thanks for reply):
Synology, inside is Virtual machine. Then i installed HA according to
THIS topic. All went fine, HA is running supervised. Then i installed vscode addon, and when i run it showed this error:

Could not execute ESPHome. Make sure you can run ESPHome from the command line.

if i have set “settings --ESPHome” to local (no matter what i enter in address line).
Addon itself is happy with “dashboard” setting and above error goes away when i enter correct IP and port, but OTA doesn’t work in any way - it ends with same terminal error as @andrepia’s picture.

Then i installed terminal add-on and installed esphome with command “pip3 install esphome”. After that command “esphome” is recognized in terminal add-on, but not in vscode add-on - it still shows same error when i click on OTA. (error esphome unknown command).

ESPHome is configured to “leave_front_door_open”, port 6052 is entered in “network host” of plugin.

All this is done locally (so with using 192.168.x.x:8123), not from outside address.

It’s not big deal, i can always upload in esphome plugin. It’s just that your vscode plugin is waaay better than original editor.

So you are using vscode addon inside home assistant (it comes preloaded with esphome vscode addon)

That thing is preconfigured to run in dashboard mode. That is esphome is not installed locally inside the addon.

You can try install esphome there:

Open terminal - new terminal (this terminal has to be the one embedded in vscode, at bottom right of screen. You open this terminal from the menu at the top left, the three horizontal bars)

Then

  • apt update
  • apt install python3-pip
  • pip install esphome

Then change on the settings to use local esphome

This will get you another installation of esphome you will
Have to keep updated manually

1 Like

yeeeeeeyyyyy!!! THANKS!
it works, i set addon to local and entered my local ip:6052. addon doesn’t complain and OTA uploads perfect.

btw
 apt update showed that i have 8 packages upgradable. should i run apt upgrade?

The address is only used when in dashboard mode.

I don’t know about other packages

1 Like

I guess that it can’t hurt, so i did upgrade. All things are still alive, so it’s ok. I guess that those are only system updates

Thanks again!

OK, feeling stupid here


The extension is installed and appears to be connected and working. Tooltips appear when I hover over keywords. But, what should I be seeing in terms of validation? Nothing happens when I intentionally insert errors.

You should definitely see errors being reported, such as:

Where I intentionally put ‘data’ where it shouldn’t be.

Or:

where I messed up the indentation.

Not sure what the fix would be for you though. Are there any warning / error messages in the bottom right of the screen when you load Studio Code Server?

Thanks for the repsonse. No luck when I inttroduce similar errors in the code.

The only warning that comes up when I start VS Code is a deprecation warning related to the Home Assistant extension.

Validation works differently than hover tooltips.

Do you have ESPHome installed locally or in the HA as add on?

You should configure that in the extension settings.

ESPHome is installed as an HA add on. leave_front_door open is set to true.

I’ve got the correct URL in the extenstion settings and dashboard is selected for Validator.

I’m able to open the dashboard in a browser using the same URL.

See these is my test setup:




I have problem with VSCode refusing to compile valid ESPHome yaml. It has issue with script parameters.

esphome:
  name: test

esp8266:
  board: nodemcuv2

logger:

api:

ota:


wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  ap:
    ssid: "test"
    password: "esp.home"

captive_portal:


script:
  - id: set_limit
    parameters:
      start: int
      end: int
    then:
      - logger.log: "Pass"

VSCode reports this:

INFO Reading configuration esphome/test.yaml...
Failed config

script: [source esphome/test.yaml:26]
  
  'id' is a required option for [script].
  - 
    Unable to find action with the name 'id'.
    id: set_limit
    parameters: 
      start: int
      end: int
    then: 

 *  The terminal process "/usr/bin/zsh '-c', 'esphome run esphome/test.yaml --device OTA'" terminated with exit code: 2. 

If I remove parameters part form script definition, then it passes yaml to compilation.

This happens with all my yaml that have scripts with parameters. all of them compile properly when run form ESPHome editor.

Maybe I need to configure something?

When I create new yaml file in VSCode it uses four spaces for indentation and if I paste.
If i use two spaces for indentation it marks it red.

But, after I save file, close it and reopen, then it acts normaly with two space indentation.

When I copy part of other yaml and paste it it is pasted indented according to the previous line in yaml I am pasting into. It disregards actual cursor position.

If I place cursor at beginning of new line and paste copied code, it is indented according to previous line, not at the place where cursor is.

Scripts parameters are a new feature from last release I believe.
The add on should work ok with this, as it really does not perform validation itself, i.e. esphome is running validation, so this looks like you’re validating against an old version of esphome but compiling it with a latest version of esphome.

Check the esphome vscode extension configuration and check that the validator it is using (local or dashboard) is an updated one.

Home Asistant prompted me today with info of new version of VSCode. I updated and now it behaves as expected. No more issue with script parameters.