Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid characters in HASS configuration #1227

Closed
robin13 opened this issue Sep 24, 2018 · 2 comments
Closed

Invalid characters in HASS configuration #1227

robin13 opened this issue Sep 24, 2018 · 2 comments

Comments

@robin13
Copy link

robin13 commented Sep 24, 2018

For the unit_of_measurement, the bare % is invalid:

sensor:
  - name: sonoff_th16_02_humidity
    platform: mqtt
    state_topic: sonoff-th16-02/humidity
    unit_of_measurement: %

Should be enclosed with quotes:

    unit_of_measurement: "%"
@mcspr
Copy link
Collaborator

mcspr commented Sep 25, 2018

Regarding f01f245, there was previous issue with the same change dfa7327 at #850

unit is wrongly quoted in discovery:

[010968] [MQTT] Sending homeassistant/sensor/espurnadev/config => {"name":"espurnadev_humidity","platform":"mqtt","state_topic":"test/espurnadev/humidity","unit_of_measurement":"\"%\""} (PID 12)

ha.config yaml:

sensor:
  - name: espurnadev_humidity
    platform: mqtt
    state_topic: test/espurnadev/humidity
    unit_of_measurement: "%"

I think quoting should happen at ha.config code instead.

sidenote There are sleep-inducing yaml spec rules of what can be without quotes and cannot, becoming yaml language directive instead of string:
http://yaml.org/spec/1.1/current.html#id868988
http://yaml.org/spec/1.1/current.html#id870919

Easier read at camel docs, python yaml lib. ctrl+f for a plain scalar to be a string, it must meet these restrictions:
https://camel.readthedocs.io/en/latest/yamlref.html#scalars

edit current yaml version by pyyaml (which hass uses), direct examples

xoseperez added a commit that referenced this issue Sep 25, 2018
@xoseperez
Copy link
Owner

True. I changed that too quick and dirty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants