keesschollaart81 / vscode-home-assistant

Visual Studio Code Extension for Home Assistant. ⭐ if you think this is cool!
544 stars 115 forks source link

Autocompletion not working when typing in an !include file #3086

Open baudneo opened 6 months ago

baudneo commented 6 months ago

Problem/Motivation

So, maybe I am missing a setting but, I cant get auto complete of entities to work when I am editing a file that has been !include'd from configuration.yaml. If I move the file contents out of the !include file and put it in its configuration section in configuration.yaml, the entities get autocompleted.

Is there a way to get the !include file autocomplete working? The Home Assistant Config Helper extension says it is enabled globally.

Expected behaviour

Autocompletion of entity values in the file defined in !include

Actual behaviour

No autocompletion of entities

Steps to reproduce

Example

Not Autocompleting

configuration.yaml
emulated_hue: !include emulated_hue.yaml
emulated_hue.yaml
type: alexa
host_ip: 10.0.1.20
listen_port: 80
expose_by_default: false
entities:
  light.overhead:
    name: "Room overhead"
    hidden: false

I can't get autocomplete to work when typing light.

Autocomplete works

configuration.yaml
emulated_hue:
  type: alexa
  host_ip: 10.0.1.20
  listen_port: 80
  expose_by_default: false
  entities:
    light.overhead:
      name: "Room overhead"
      hidden: false

I get autocompletion when typing light.

Proposed changes

(If you have a proposed change, workaround or fix, describe the rationale behind it)

mikesalz commented 5 months ago

The developer broke this integration back in January and stopped responding to reported issues. You'll probably need to roll back to 1.39.0.

pganansia commented 5 months ago

Try to install back v1.39.0 Rgds.

baudneo commented 5 months ago

I can confirm that downgrading to 1.39.0 works

Edit: Keeping this issue open for now.

mauritsivs commented 4 months ago

downgrading didnt work for me, i cant get any autocomplete to work. Every now and then it works for a few seconds right after opening VScode. but then it just stops. Output window does not give any errors on the plugin

baudneo commented 3 months ago

downgrading didnt work for me, i cant get any autocomplete to work. Every now and then it works for a few seconds right after opening VScode. but then it just stops. Output window does not give any errors on the plugin

Are you certain that the downgrade took effect and there are no TCP comm issues? Is this in the vscode Hass add-on or a vscode install on another machine?

I use the vscode add-on and also use a remote vscode install on another machine, both are working using 1.39.0

mauritsivs commented 3 months ago

Are you certain that the downgrade took effect and there are no TCP comm issues?

Yes, downgraded for sure, i see no comm issues. As soon as I purposely set a wrong host URL in settings it gives me a connection error.

Is this in the vscode Hass add-on or a vscode install on another machine?

Both! add-on wont work, and vscode on windows, with SMB connection

it all used to be working very well. unfortunately i have no idea when things changed, its been a while since i actively worked on any code.

baudneo commented 3 months ago

I would assume theres something wrong with your specific setup. Can you try a different PC or device and set up a new connection to HASS with it? That would help rule out some things.

mauritsivs commented 3 months ago

i have now noticed that it actually does work most of the time, but its EXTREMELY slow... it takes at least 10 seconds for anything to show up for autocomplete.

there is no difference when using any other PC

and by the way, this is happening with all files, from configuration.yaml to any !include or /packages files

baudneo commented 3 months ago

It being slow really leans me towards a network issue of some sort, have you tried opening the chrome dev tools while this issue is going on? (F12)

mauritsivs commented 3 months ago

Since this happens even in the HA add-on directly on the machine itself, i doubt this has to do with a network issue right? And i am only working purely local, local network. I am more leaning towards the idea that there are big/wrong files its trying to read/access in the workspace that makes it so slow?

mauritsivs commented 3 months ago

everytime i start writing in a file, it throws this in the output window: it starts re-indexing everything(?) and sometimes it crashes and restarts aparently...

Discover all configuration files because file:///z%3A/scripts.yaml got updated and new files were found...
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Applying schemas to 24 of your configuration files...
Assigning z:/configuration.yaml the configuration.yaml schema
Assigning z:/automations.yaml the configuration.yaml/automation schema
Assigning z:/automations.yaml the configuration.yaml/automation schema
Assigning z:/scripts.yaml the configuration.yaml/script schema
Assigning z:/scenes.yaml the configuration.yaml/scene schema
Assigning z:/binary_sensors.yaml the configuration.yaml/binary_sensor schema
Assigning z:/input_booleans.yaml the configuration.yaml/input_boolean schema
Assigning z:/input_numbers.yaml the configuration.yaml/input_number schema
Assigning z:/input_texts.yaml the configuration.yaml/input_text schema
Assigning z:/templates.yaml the configuration.yaml/template schema
Assigning z:/packages%5Ccovers.yaml the configuration.yaml/homeassistant/packages schema
Assigning z:/packages%5Cgoogle_assistant.yaml the configuration.yaml/homeassistant/packages schema
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<Object>".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

Node.js v18.18.2
[Info  - 12:58:26 PM] Connection to server got closed. Server will restart.
[Home Assistant Language Server(12780)] Started and initialize received
Connecting to Home Assistant...
[Auth phase] Initializing WebSocket connection to Home Assistant
[Auth Phase] Connecting to Home Assistant... Tries left: 3
[Auth phase] Received a message of type auth_required
[Auth phase] Received a message of type auth_ok
Connected to Home Assistant
Applying schemas to 24 of your configuration files...
Assigning z:/configuration.yaml the configuration.yaml schema
Assigning z:/automations.yaml the configuration.yaml/automation schema
Assigning z:/automations.yaml the configuration.yaml/automation schema
Assigning z:/scripts.yaml the configuration.yaml/script schema
Assigning z:/scenes.yaml the configuration.yaml/scene schema
Assigning z:/binary_sensors.yaml the configuration.yaml/binary_sensor schema
Assigning z:/input_booleans.yaml the configuration.yaml/input_boolean schema
Assigning z:/input_numbers.yaml the configuration.yaml/input_number schema
Assigning z:/input_texts.yaml the configuration.yaml/input_text schema
Assigning z:/templates.yaml the configuration.yaml/template schema
Assigning z:/packages%5Ccovers.yaml the configuration.yaml/homeassistant/packages schema
Assigning z:/packages%5Cgoogle_assistant.yaml the configuration.yaml/homeassistant/packages schema
Assigning z:/packages%5Cgroups.yaml the configuration.yaml/homeassistant/packages schema
Assigning z:/packages%5Cirrigation_unlimited.yaml the configuration.yaml/homeassistant/packages schema
Assigning z:/packages%5Cirrigation_unlimited_controls.yaml the configuration.yaml/homeassistant/packages schema
Assigning z:/packages%5Craingauge.yaml the configuration.yaml/homeassistant/packages schema
Assigning z:/packages%5Cswitches.yaml the configuration.yaml/homeassistant/packages schema
Assigning z:/packages%5Cutilitymeter.yaml the configuration.yaml/homeassistant/packages schema
Schemas updated!
Discover all configuration files because file:///z%3A/scripts.yaml got updated and new files were found...
Applying schemas to 24 of your configuration files...
Assigning z:/configuration.yaml the configuration.yaml schema
Assigning z:/automations.yaml the configuration.yaml/automation schema
Assigning z:/automations.yaml the configuration.yaml/automation schema
Assigning z:/scripts.yaml the configuration.yaml/script schema
Assigning z:/scenes.yaml the configuration.yaml/scene schema
Assigning z:/binary_sensors.yaml the configuration.yaml/binary_sensor schema
Assigning z:/input_booleans.yaml the configuration.yaml/input_boolean schema
Assigning z:/input_numbers.yaml the configuration.yaml/input_number schema
Assigning z:/input_texts.yaml the configuration.yaml/input_text schema
Assigning z:/templates.yaml the configuration.yaml/template schema
Assigning z:/packages%5Ccovers.yaml the configuration.yaml/homeassistant/packages schema
Assigning z:/packages%5Cgoogle_assistant.yaml the configuration.yaml/homeassistant/packages schema
Assigning z:/packages%5Cgroups.yaml the configuration.yaml/homeassistant/packages schema
Assigning z:/packages%5Cirrigation_unlimited.yaml the configuration.yaml/homeassistant/packages schema
Assigning z:/packages%5Cirrigation_unlimited_controls.yaml the configuration.yaml/homeassistant/packages schema
Assigning z:/packages%5Craingauge.yaml the configuration.yaml/homeassistant/packages schema
Assigning z:/packages%5Cswitches.yaml the configuration.yaml/homeassistant/packages schema
Assigning z:/packages%5Cutilitymeter.yaml the configuration.yaml/homeassistant/packages schema
Schemas updated!
Discover all configuration files because file:///z%3A/scripts.yaml got updated and new files were found...
Got 956 entities from Home Assistant
Applying schemas to 24 of your configuration files...
Assigning z:/configuration.yaml the configuration.yaml schema
Assigning z:/automations.yaml the configuration.yaml/automation schema
Assigning z:/automations.yaml the configuration.yaml/automation schema
Assigning z:/scripts.yaml the configuration.yaml/script schema
Assigning z:/scenes.yaml the configuration.yaml/scene schema
Assigning z:/binary_sensors.yaml the configuration.yaml/binary_sensor schema
Assigning z:/input_booleans.yaml the configuration.yaml/input_boolean schema
Assigning z:/input_numbers.yaml the configuration.yaml/input_number schema
Assigning z:/input_texts.yaml the configuration.yaml/input_text schema
Assigning z:/templates.yaml the configuration.yaml/template schema
Assigning z:/packages%5Ccovers.yaml the configuration.yaml/homeassistant/packages schema
Assigning z:/packages%5Cgoogle_assistant.yaml the configuration.yaml/homeassistant/packages schema
Assigning z:/packages%5Cgroups.yaml the configuration.yaml/homeassistant/packages schema
Assigning z:/packages%5Cirrigation_unlimited.yaml the configuration.yaml/homeassistant/packages schema
Assigning z:/packages%5Cirrigation_unlimited_controls.yaml the configuration.yaml/homeassistant/packages schema
Assigning z:/packages%5Craingauge.yaml the configuration.yaml/homeassistant/packages schema
Assigning z:/packages%5Cswitches.yaml the configuration.yaml/homeassistant/packages schema
Assigning z:/packages%5Cutilitymeter.yaml the configuration.yaml/homeassistant/packages schema
Schemas updated!
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Got 956 entities from Home Assistant
Discover all configuration files because file:///z%3A/scripts.yaml got updated and new files were found...
baudneo commented 3 months ago

Seems like its in some sort of weird loop. The .catch() is obviously an issue that ends up closing the language server and seems to restart the looping errors.

Let me check what my dev tools console outputs. Where are you pulling those logs from? I dont see any of that in dev tools or the vscode add-on logs in HASS.

mauritsivs commented 3 months ago

this is from the output window in VScode Screenshot 2024-05-28 140720

baudneo commented 3 months ago

Kk, I don't usually use vscode. Basically just for Hass and hyprland config stuff. When I get home I'll take a look what my output is, I can't really get a good look on mobile.

baudneo commented 3 months ago
[Home Assistant Language Server(560849)] Started and initialize received
Applying schemas to 34 of your configuration files...
Assigning /homeassistant/configuration.yaml the configuration.yaml schema
Assigning /homeassistant/automations.yaml the configuration.yaml/automation schema
Assigning /homeassistant/blueprints/automation/Blackshome/appliance-notifications.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/Blackshome/sensor-light-add-on.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/Rod_Poplarchick/blue-print-to-work-with-aqara-vibration-sensor-for-automation-to-trigger-notification-or-other-action-when-dishwasher-or-washing-machine-is-done.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/Twanne/multi_click_button.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/Twanne/party_lights.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/homeassistant/motion_light.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/homeassistant/notify_leaving_zone.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/hugalafutro/Z2M_Hue_Dimmer_Switch.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/hugalafutro/Z2M_Hue_Dimmer_Switch_v2.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/panhans/heating_control_dev.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/panhans/zone_notification_extended.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/patpac9/Hue_Dimmer_Switch_Easy_Custom_Buttons.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/pbergman/ERS-10TZBVK-AA.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/sbyx/wake-up-light-alarm-with-sunrise-effect.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/script/homeassistant/confirmable_notification.yaml the blueprints/script schema
Assigning /homeassistant/blueprints/script/samuelthng/notifications.yaml the blueprints/script schema
Assigning /homeassistant/customize.yaml the configuration.yaml/homeassistant/customize schema
Assigning /homeassistant/automations.yaml the configuration.yaml/automation schema
Assigning /homeassistant/scripts.yaml the configuration.yaml/script schema
Assigning /homeassistant/scenes.yaml the configuration.yaml/scene schema
Assigning /homeassistant/sensor.yaml the configuration.yaml/sensor schema
Schemas updated!
Connecting to Home Assistant...
[Auth phase] Initializing WebSocket connection to Home Assistant
[Auth Phase] Connecting to Home Assistant... Tries left: 3
[Auth phase] Received a message of type auth_required
[Auth phase] Received a message of type auth_ok
Connected to Home Assistant
Discover all configuration files because file:///config/emulated_hue.yaml got updated and new files were found...
Applying schemas to 34 of your configuration files...
Assigning /homeassistant/configuration.yaml the configuration.yaml schema
Assigning /homeassistant/automations.yaml the configuration.yaml/automation schema
Assigning /homeassistant/blueprints/automation/Blackshome/appliance-notifications.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/Blackshome/sensor-light-add-on.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/Rod_Poplarchick/blue-print-to-work-with-aqara-vibration-sensor-for-automation-to-trigger-notification-or-other-action-when-dishwasher-or-washing-machine-is-done.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/Twanne/multi_click_button.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/Twanne/party_lights.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/homeassistant/motion_light.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/homeassistant/notify_leaving_zone.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/hugalafutro/Z2M_Hue_Dimmer_Switch.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/hugalafutro/Z2M_Hue_Dimmer_Switch_v2.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/panhans/heating_control_dev.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/panhans/zone_notification_extended.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/patpac9/Hue_Dimmer_Switch_Easy_Custom_Buttons.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/pbergman/ERS-10TZBVK-AA.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/automation/sbyx/wake-up-light-alarm-with-sunrise-effect.yaml the blueprints/automation schema
Assigning /homeassistant/blueprints/script/homeassistant/confirmable_notification.yaml the blueprints/script schema
Assigning /homeassistant/blueprints/script/samuelthng/notifications.yaml the blueprints/script schema
Assigning /homeassistant/customize.yaml the configuration.yaml/homeassistant/customize schema
Assigning /homeassistant/automations.yaml the configuration.yaml/automation schema
Assigning /homeassistant/scripts.yaml the configuration.yaml/script schema
Assigning /homeassistant/scenes.yaml the configuration.yaml/scene schema
Assigning /homeassistant/sensor.yaml the configuration.yaml/sensor schema
Schemas updated!

I would create a VM or LXC, install vscode and the home assiatnt extension and try setting it up to see what happens.

Only thing I can think of is you may have some gibberish or zero width chars in one of the files that is causing an issue.