Code Monkey home page Code Monkey logo

vscode-home-assistant's Introduction

Home Assistant Config Helper for Visual Studio Code

Marketplace Version GitHub release

Getting started

  1. Install via the VS Code Marketplace

  2. Open your (local copy of the) Home Assistant Configuration with VS Code

  3. Configure the connection to Home Assistant via the HA Section in the VS Code Settings UI

    More details in the How-To in the Wiki

  4. Enjoy the features showcased below 👇

  5. Continue reading in the Wiki:

Features

Completion for Entity IDs, Services, Scenes and Triggers

When connected with your Home Assistant server, entity id' and services will be auto-completed.

Completion & Validation for Configuration & Lovelace Schema

Most of the scheme's of Home Assistant will be validated and things like properties, values and enums will be auto-completed. This extension understands the behaviour of Home Assistant '!include...' behaviour and use this to provide scoped validation for all your files.

Deprecation Warnings:

Schema Documentation

Go to Definition for Includes

Easy navigate between your files references via the different !include... tags using 'f12' / 'Go to Definition'.

Snippets

Snippets allow you to create commonly used data structures very quickly.

Commands

Commands allow you to quickly interact with Home Assistant! Find them using Cmd+shift+P and type 'Home Assistant'

Render templates

Evaluate jinja templates via Home Assistant's API and see how they would render.

image

Contribution

Release Notes

Read all the recent changes in the GitHub releases section

Feedback / Ideas

Create an issue, reach out to me on Twitter or the Home Assistant Discord.

Things to do / up for grabs

  • Go to Definition for entities, scripts and automations
  • Autocomplete !secrets
  • Check local config with HA Server

Telemetry

This extension collects telemetry data to help us build a better experience for using VS Code with Home Assistant. We use vscode-extension-telemetry, which reports the following data:

  • Extension name
  • Extension version
  • Machine ID and session ID from VS Code
  • Operating system
  • Platform version

Additionally, if the language server fails to activate, we report the diagnostic data the language server produces. The extension respects the telemetry.enableTelemetry setting, which you can learn more about at VS Code's telemetry FAQ.

vscode-home-assistant's People

Contributors

acshef avatar adobin avatar aohzan avatar avee87 avatar awoodley avatar balloob avatar bdr99 avatar bohmandan avatar chrisromp avatar christophcaina avatar dependabot-preview[bot] avatar dependabot[bot] avatar erates avatar farmio avatar frenck avatar georgesg avatar hemanthpai avatar keesschollaart81 avatar kubawolanin avatar michalchecinski avatar osre77 avatar pedrolamas avatar piitaya avatar rbnis avatar rccoleman avatar ryanjohnsontv avatar sverleysen avatar tetienne avatar tntlarsn avatar tomlut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-home-assistant's Issues

Feature Request: AppDaemon Support

I had thoughts around trying to attempt this myself, but it looks like you've added quite a bit of functionality since I forked your code and it may be a little more than I can chew at this point.

But what I'd be very interested in is being able to leverage what you've already done around entity and service auto-completion and using it in AppDaemon. So, I can think of the following things it would need:

  • Support for .py files in the appdaemon directory
  • If a .py file is open, provide service auto-completion support. Service call always begins with self.call_service("domain/service_name", so for example self.call_service("light/turn_on"
  • Entities are generally referenced with the variables entity or entity_id. So, auto-complete after any of the following are typed would be desired:
    • entity = "
    • entity == "
    • entity_id = "
    • entity_id == "

I'm definitely a novice when it comes to VS Code extensions but I'd be happy to help as much as possible.

VSCode version incompatibility?

Getting this error when installing:
Unable to install because, the extension 'keesschollaart.vscode-home-assistant' compatible with current version '1.31.1' of VS Code is not found.

unexpected property message in trigger

With the trigger below, I get an unexpected property message in VS Code. The for property seems to be the problem.

  trigger:
  - platform: template
    value_template: "{% if is_state_attr('proximity.home', 'dir_of_travel', 'towards') %}false{% endif %}"
    for: '00:05:00'

Checking the configuration doesn't return a error message. And according to the document this for property is correct however: https://www.home-assistant.io/docs/automation/trigger/#template-trigger

Hint on objects from Home Assistant does not work without "restarting" the extension

Hint on objects from Home Assistant does not work without "restarting" the extension.
Writes "no suggestion".
It does not try to connect to the Home Assistant.
If I open the properties of an extension, disable it and then enable it again, everything will start working until the next VSCode restart.
OS: Windows 10
VSCode: 1.37.0
Extension: 1.0.2
screen

Material Design Icons Intellisense

I was using this extension when I was working with Lovelace YAML files designated as the YAML language in VS Code, but since switching to designate them as Home Assistant files, the MDI extension no longer suggests icons using Intellisense.

Conditional Entity in Picture Elements Card

Entity "binary_sensor.openclose_9" is being highlighted - "Incorrect Type. Expected "object".

Works OK in HA.

Example:

type: picture-elements
image: /local/images/ground_floor_plan.png
elements:
  - type: conditional
    conditions:
      - entity: binary_sensor.openclose_9
        state: 'on'
    elements:
      - type: image
        image: /local/images/ground_floor_plan_open-patio-doors.png
        style:
          top: 5.7%
          left: 50.17%
          width: 16.15%

Copy / Paste indentation incorrect.

When I copy some configuration to duplicate and edit it, the indentation of the pasted configuration is incorrect. The pasted strings take the indentation of the previous line no matter how many blank lines are in between the copy/paste.

e.g. copying these two lines of customization yaml,..

light.bar_downlights:
  icon: mdi:track-light

... and pasting to a blank line below it produces this:

light.bar_downlights:
  icon: mdi:track-light

  light.bar_downlights:
    icon: mdi:track-light

This makes an absolute mess of copying and pasting Lovelace cards in a stack.

Merge key error

        entities:
          - entity: light.lroom_light
            <<: &ceiling-light
              type: custom:slider-entity-row
              toggle: false
              hide_state: true

<<: &ceiling-light is highlighted: Property << is not allowed.

Can't see HA Files

I'm new to VS Code but I think I've installed your extension OK with the URL and LLAT. However, I can't see any of the HA config files - do I need to setup an SSH connection to HA as well? Thanks!

Mulitple package definitions seen as error

I'm using packages to group configurations. Only one string is expected although more are possible.

Example:
  packages:
    shelly: !include package/shelly/shelly_package.yaml
    sonoff: !include package/sonoff/sonoff_package.yaml
    glance: !include package/glance/glance_package.yaml

Error message:
Incorrect type. Expected "string"

mdi icons inserted incorrectly

Is the mdi Explorer part of this extension?
Using "Inset Icon Into Editor" inserts it as:

mdi-alert instead of
mdi:alert

Also on a similar note, any idea when the file icons will be updated?

Packages

Unless I am doing something wrong the auto-complete does not seem to support packages.
If I am wrong can you tell me what I might be doing and if I am right can you say if this is ever likely to be a possibility?

This is a great extension even with the (apparently) limited functionality with packages, so thanks for creating it!

Dependabot can't resolve your JavaScript dependency files

Dependabot can't resolve your JavaScript dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Error whilst updating @types/node in /package-lock.json:
No matching version found for [email protected]

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

You can mention @dependabot in the comments below to contact the Dependabot team.

Configuration.yaml contains !secret values

I recently introduced a few !secret values into my configuration.yaml file, and I started getting this error from the extension:
image

I'm not sure if this is the same as another issue I saw about !includes, but my !includes seem to be fine. My configuration.yaml is pretty bare-bones, as most of my components are in packages:

homeassistant:
  # Name of the location where Home Assistant is running
  name: Home
  
  auth_providers:
    - type: homeassistant
    # uncomment this to enable backwards compatible API password support
    #- type: legacy_api_password

  # Location required to calculate the time the sun rises and sets
  latitude: !secret home_latitude
  longitude: !secret home_longitude
  
  # Impacts weather/sunrise data (altitude above sea level in meters)
  elevation: 0
  
  # metric for Metric, imperial for Imperial
  unit_system: metric
  
  # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  time_zone: America/Halifax
  
  # Customization file
  customize: !include customize.yaml

  # Packages
  packages: !include_dir_named packages

http:
  # api_password: !secret http_password
  base_url: !secret base_url
  use_x_forwarded_for: true
  trusted_proxies:
    - 127.0.0.1

api:

person:

False errors

I have found two more small ones.
image
To be honest it is probably more correct to have continue_on_timeout: false (no quotes) but I seem to have a mix in my config and as it is valid either way I thought you'd like to know.
But if it is definitely more correct without quotes feel free to tell me and leave the extension as it is.

Also
you don't allow for ThomasLoven's custom popup card:
image

YAML node anchors

I'm using in my lovelace file a few YAML node anchors.
Unfortunately it show as an error within Visual Studio

image

Incorrect type. Expected "string".

automation:
  - alias: 'test'
    trigger:
      - platform: homeassistant
        event: start
    action:
      - wait_template: "{{ is_state('binary_sensor.entrance', 'on') }}"
        timeout:
          minutes: 5

minutes: 5 is highlighted, although it is a correct syntax.

Support Jinja2 extension types

Would great if it supported Jinja2 (.j2) template extensions.

Currently any Jinja2 templated yaml files in my configuration wont auto complete.

High CPU usage

Ever since the version which added "Go to definition" for include files, the CPU usage has skyrocketed for me.

When i am editing a file and saving it, it maxes out one core on my Intel NUC and it is really slow to perform the schema-check.

I am not getting any errors, just a very slow VSCode. Is there any other information i can provide you with to help troubleshoot?

EDIT: I monitored the CPU using top, and as soon as i start to edit a .yaml file the CPU usage goes through the roof so its not just on saving the file. It seems to be the syntax-check which is causing the problem.

In contrast, if i edit a python program i get at most 40% CPU usage, while this extension showed at most 164% CPU usage

Complicated value template breaks up yaml formatting

I have a complicatied value template for a sensor in configuration.yaml (Thanks Petro!)

But it breaks the yaml markup of the visual studio code addon.

It's this part:

sensor:
  - platform: rest
    name: "Grocy Meal Plan" 
    resource: https://grocy.org/api/objects/meal_plan
    headers:
      GROCY-API-KEY: !secret GROCY-API-KEY
      accept: application/json
    value_template: >
      {% set today = now().strftime('%Y-%m-%d') %}
      {% set items = value_json | selectattr('day','eq',today) | list | first %}
      {% set attributes = ['day', 'recipe_id', 'servings'] %}
      {{ items.items() | selectattr(0, 'in', attributes) | sort(attribute=0) | map(attribute=1) | join(',') }}      

Everything after it is marked as text, but it isn't. It also passes the configuration test of Home Assistant and works as it should.

See image below:

afbeelding

Can't insert token on mac

Hey Kees!

I'm not sure if this is is a quirk in the extension or something in Code itself.

When I install the plugin in Code on mac and select the option to "configure now", I'm not really able to configure the plugin:

Pasting the home assistant url goes fine, no problems there, but as soon as I move the focus from the editor to another window (alt+tab) to copy paste the long lived access token, the configuration "window" (The one input line), pops away and I can't paste my token anymore...

The token is too long to remember, so copy pasting would be highly preferred :)

I think will be able to insert the token somewhere in some file, so I'll find a workaround, but it would be nice if it worked :)

Thanks for the effort of creating this lovely plugin, I haven't used it yet, but I love it already 👍

EDIT: Typo's

Osx Installation

I´ve installed the extension into VSCode on OSx, i've configured the https url and the long live token, i followed method 2, but now don´t see the home assistant config files in the explorer.

Do i need to do something to make this files visible?

Extension keeping old settings

Hey! So the first time i ran the extension i accidentally typed in the wrong adress. I updated it in settings.json and restarted visual studio code but i still got an error. Strangley enough in the error message it listed the old url. So i removed every setting in settings.json under the extension and uninstalled the extension. Restarted visual and installed the extension again, but even without filling in any settings it still pops up the same connection error message with the old url?

Multiple servers

I have installed the addon and it is working great. However I have two HA servers running and the entity completion only works for a single server. Is it possible to make the settings for the add-on specific to a folder i.e. 'Folder settings' and then I could switch between the servers.

Error connecting to your Home Assistant Server

Installed extension, configured with server address (I'm sure that the address is correct cause I've tested on browser) and with long live token, then restarted VScode but I get this error:

Error connecting to your Home Assistant Server at https://192.168.1.65:8123, check your network or update your VS Code Settings. Error: 1

VScode:

Versione: 1.32.3 (user setup)
Commit: a3db5be9b5c6ba46bb7555ec5d60178ecc2eaae4
Data: 2019-03-14T23:43:35.476Z
Electron: 3.1.6
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Windows_NT x64 10.0.17134

Wrong errors

The following code snippets produces the wrong error: Missing property "event_data_template".

test:
  sequence:
    - event: flow_test
      event_data:
        state: "on"

I hope this can be fixed easily because it is really annoying :)

Incorrect type. Expected "object"

I use a config like @frenck using a lot of !include

I have a script.yaml file with

script: !include_dir_named ../../scripts

This way the name of the files in folder script is used as the entity_id of each script. But the home assistant add-on see errors in all files of this folder with the error message in title of the issue.
Home Assistant raises no error with those files and work as expected.
You can see example in my repo.

False problems?

I think the extension might be highlighting some false problems.

  1. input_boolean with nothing else defined e.g.
input_boolean:
  my_boolean1:

  my_boolean2:
  1. I find that wait_template often (always?) gets highlighted as a problem
    image
    image

Env vars HASS_SERVER & HASS_TOKEN not used

The support for HASS_TOKEN & HASS_SERVER environment variables (added in #11) no longer work in the latest version.

It seems that these were lost in translation during the migration/refactor towards the language server. This causes a problem for the Home Assistant Visual Studio Code add-on for Hass.io, since it relies on them.

The result is the add-on now spawns continues popups:

image

No pop-up appears

I went to "file -> open folder". Selected my hass folder and nothing pops up.

I think the docs are missing something.

Allow the "icon-height" property for the "entity-button" Lovelace card

The entity-button Lovelace card supports setting the height of the assigned icon using the icon-height property, but the current scheme (v0.6.0) doesn't allow this property.

image

Example:

      - type: entity-button
        icon_height: 100px
        tap_action:
          action: toggle
        name: Všetky svetlá v byte
        entity: group.all_lights
        hold_action:
          action: more-info

Incorrect error flag for lovelace entity filter card

When using the entity filter card is used, errors are raised for some card properties:

Schermafbeelding 2019-07-20 om 09 57 59

Example code:

  - type: entity-filter
    entities:
      - entity: binary_sensor.frontdoor_contact_sensor
      - entity: binary_sensor.master_bedroom_outside_door_sensor
        name: Balkondeur
    state_filter:
      - 'on'
    card:
      type: glance
      title: Open contacten
      show_state: false
    show_empty: false

!include errors

Latest version gets error with config using !includes. It used to be OK.

This works fine in HA but VSCODE shows red wavy lines under all the lovelace/********.yaml - "Incorrect type. Expected object"

    - type: vertical-stack
      cards:
        - !include lovelace/living_room.yaml
        - !include lovelace/kitchen.yaml
        - !include lovelace/utility.yaml
        - !include lovelace/toilet.yaml
        - !include lovelace/hall.yaml
        - !include lovelace/gardens.yaml
        - !include lovelace/garage.yaml

Incorrect error

I think there is an incorrect error being flagged in Lovelace picture-entity.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.