bob1de / hass-apps

Some useful apps and snippets to empower Home Assistant and AppDaemon even more.
Apache License 2.0
86 stars 23 forks source link

[schedy] expression for switch actor didn't parse #24

Closed insajd closed 5 years ago

insajd commented 5 years ago

Hi, While writing this, got my issue solved. But here's what got me confused: Here is my config which was failing.

  actor_type: switch
  schedule_prepend:
  - x: "on" if state("sun.sun", elevation) <= 0 else Skip()
  - v: "off"

This is error log which I was receiving

2018-12-18 22:13:39.067703 WARNING AppDaemon: parser says
2018-12-18 22:13:39.067971 WARNING AppDaemon:   in "<unicode string>", line 30, column 13:
      - x: "on" if state("sun.sun", elevation) < ... 
                ^
2018-12-18 22:13:39.068046 WARNING AppDaemon: expected <block end>, but found '<scalar>' while parsing a block mapping

These variants fail as well:

Approach which worked (found on Generic Actor documentation page):

bob1de commented 5 years ago

Hmm, have to investigate this further. The expression you tried should actually be accepted.

bob1de commented 5 years ago

Ok, having a string at the beginning of the expression is considered as invalid YAML by the parser. I'll change all examples to quote the whole expression, because what you used as a workaround is in fact working, but might be difficult to understand why for people not familiar with Python.