petro
(Petro)
February 7, 2017, 11:40pm
1
I’m getting this error:
17-02-07 18:29:51 ERROR (Thread-1)
[homeassistant.util.yaml] mapping values are not allowed here
in "/home/homeassistant/.homeassistant/alexa.yaml", line 83, column 18
Line 83 is service: media_player.volume_set.
SetVolumeIntent:
action:
service: media_player.volume_set
entity_id: media_player.yamaha_receiver
volume_level: >-
{%- if Level|int in range(10,81) -%}
{%- set n = Level|float -%}
{{ (1.0-( n / 100.0 )) | round(0.00) }}
{%- endif -%}
speech:
type: plaintext
text: OK
I pasted the code into http://www.yamllint.com/ and got the same unhelpful error. What could be wrong?
rpitera
(Robert Pitera)
February 7, 2017, 11:46pm
2
Try this:
SetVolumeIntent:
action:
entity_id: media_player.yamaha_receiver
service: media_player.volume_set
volume_level: |-
{%- if Level|int in range(10,81) -%}
{%- set n = Level|float -%}
{{ (1.0-( n / 100.0 )) | round(0.00) }}
{%- endif -%}
speech:
text: OK
type: plaintext
petro
(Petro)
February 7, 2017, 11:48pm
3
Hmm, that shifted the error down. It appears that this line:
service: media_player.volume_set
is causing the problem.
rpitera
(Robert Pitera)
February 7, 2017, 11:51pm
4
Is it the same error though? It validated ok.
petro
(Petro)
February 7, 2017, 11:52pm
5
bah, missing a line:
SetVolumeIntent:
action:
service: media_player.volume_set
data_template: <-----------------------------------MISSING
entity_id: media_player.yamaha_receiver
volume_level: >-
{%- if Level|int in range(10,81) -%}
{%- set n = Level|float -%}
{{ (1.0-( n / 100.0 )) | round(0.00) }}
{%- endif -%}
speech:
type: plaintext
text: OK
rpitera
(Robert Pitera)
February 7, 2017, 11:55pm
6
I was wondering about that. I saw the volume level and it looked like a data template to me but I haven’t really access the media players programmatically so I thought maybe it was something I hadn’t learned yet.
I’m always afraid to open my mouth and look foolish but in this case it would have helped. LOL
petro
(Petro)
February 8, 2017, 12:00am
7
Yeah, i’m learning this. I’m not really sure what is a yaml requirement and what is a HA requirement. I usually see code and attempt to replicate it. I probably should sit down and actually learn yaml. I usually learn by doing though.
rpitera
(Robert Pitera)
February 8, 2017, 2:45am
8
That’s how I’ve been doing it. Also when it comes to templates, this is a big help:
http://jinja.pocoo.org/docs/2.9/templates/