esphome/esphome-vscode

unknown tag <!lambda> when lambda used to return a value

marcoaddario opened this issue · 6 comments

the !lambda syntax is not recognised when used to return a value
image

while it is recognized (and accepted) by the ESPHome integrated editor

The code is recognized as ESPHome (and not home assistant ;-) )

VSCode version: 1.75.1
ESPhome plugin version: v2022.11.0

Is anybody able to reproduce this?
I cannot:

image
image

Same issue here:
image

VSCode version: 1.76.0
ESPhome plugin version: v2022.11.0

vb7445 commented

Yes I'm getting this lambda unknown tag error in the yaml file in Home Assistant File Editor but not when editing from the ESPHome editor.

this is the code snippet
`binary_sensor:

  • platform: gpio
    id: gpio21
    name: Water Sensor
    pin:
    number: 21
    mode:
    input: True
    pullup: False
    pulldown: True
    filters:
    • delayed_on: 30ms
      on_press:
      then:
      • switch.turn_on: gpio2
        - delay: !lambda "return id(glob_drain_delay) * 60000;"
      • switch.turn_off: gpio2
        `

this is the error message

`unknown tag !<!lambda> (78:64)

75 | ...
76 | ...
77 | ...
78 | ... id(glob_drain_delay) * 60000;"
-----------------------------------------^
79 | ...
80 | ...`

In VSCode I'm getting Unresolved tag: !lambda YAML
However, if using the ESPHome Validator in VSCode with the ESPHome Extension installed I don't get an error.

I'm getting same error unknown tag <!lambda>YAML

VSCode version: 1.85.1
VSCode ESPhome extension version: v2023.9.0 - 2023-10-09
ESPhome Home Assistant AddOn version: 2023.11.6

image
glmnet commented

Do you have the redhat yaml extension installed? Try disabling it for the workspace

If you want to keep the redhat yaml extension enabled you can add it as a custom tag in settings.json:

    "yaml.customTags": [
        "!lambda scalar"
    ]

redhat-developer/vscode-yaml#669 (comment)