I try to make a sensor that gets the aviation weather data from de closest airport.
I made 2 sensors that give me my latitude & longitude: sensor.erik_latitude & sensor.erik_longitude
No problem so far.
When I create a command_line sensor like this it works and I receive the correct data:
D’oh! I just noticed a typo that was in your original template that I’ve been inadvertently copying. You had states.sensor.erik_latitude.state for both lat & lon!
Ok, figured it out. Seems the command_line sensor first splits the command from the arguments by doing a split(’ ', 1), then whatever was to the right of the first space becomes the arguments, and only the arguments are evaluated as a template. So:
ERROR (SyncWorker_6) [homeassistant.util.yaml] mapping values are not allowed here in "/home/homeassistant/.homeassistant/sensor.yaml", line 505, column 150
Obviously it’s a different website, and I’m using different entities for the lat & lon, but it works. Oh, and this is in a package file, hence the sensor: keyword.
EDIT: And this is what I see in my log:
2018-07-26 09:38:36 INFO (Thread-14) [homeassistant.components.sensor.command_line] Running command: curl 'https://api.sunrise-sunset.org/json?lat=REDACTED&lng=REDACTED'
It was still failing because you didn’t fix it like I suggested. You still have the first double-quote character in the wrong place. It needs to be right before the beginning of the arguments, not before the curl command. I.e., not this:
BTW, the reason the other one works as-is (i.e., the one with the fixed lat & lon), is because it’s not using a template. For the command_line sensor, if you want to use a template, it has to be for the command arguments part only (everything after the first space.)
What did you see in the log (where it says, “Running command: …”)?
Did you see my earlier post where I first recommended this? I showed what I saw in the log, and the quotes were there. I don’t understand why it wouldn’t work for you, too.