Does anyone know why I am getting the following error when trying to add a command_line sensor to check the status of a service:
2019-01-29 18:53:08 ERROR (SyncWorker_0) [homeassistant.util.yaml] mapping values are not allowed here
in "/home/homeassistant/.homeassistant/configuration.yaml", line 188, column 76
2019-01-29 18:53:08 ERROR (MainThread) [homeassistant.bootstrap] Error loading /home/homeassistant/.homeassistant/configuration.yaml: mapping values are not allowed here
in "/home/homeassistant/.homeassistant/configuration.yaml", line 188, column 76
I am using the configuration:
sensor:
- platform: command_line
name: Plex Service
command: systemctl status plexmediaserver.service | grep -oP '(?<=Active: ).\w+'
line 188, column 76 is the : in (?<=Active: )
When the above code is run as a command line at a console it works ok, giving active or inactive as the result depending on the service status
Searching the forums does find others with this error, but none of the solutions for them fixes the case here.
2019-01-29 20:00:19 ERROR (SyncWorker_0) [homeassistant.util.yaml] while scanning a double-quoted scalar
in "/home/homeassistant/.homeassistant/configuration.yaml", line 188, column 13
found unknown escape character 'w'
in "/home/homeassistant/.homeassistant/configuration.yaml", line 188, column 82
2019-01-29 20:00:19 ERROR (MainThread) [homeassistant.bootstrap] Error loading /home/homeassistant/.homeassistant/configuration.yaml: while scanning a double-quoted scalar
in "/home/homeassistant/.homeassistant/configuration.yaml", line 188, column 13
found unknown escape character 'w'
in "/home/homeassistant/.homeassistant/configuration.yaml", line 188, column 82
this is strange, when I try the other way there are no errors, but also no new sensors in HA (I have a 2nd entry for the appdaemon service too, I often forget to start appdaemon after an HA restart)
here is the first few lines of the output:
systemctl status plexmediaserver.service
â—Ź plexmediaserver.service - Plex Media Server for Linux
Loaded: loaded (/lib/systemd/system/plexmediaserver.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2019-01-19 23:27:53 UTC; 1 weeks 2 days ago
Main PID: 1054 (sh)
Tasks: 122 (limit: 4915)
CGroup: /system.slice/plexmediaserver.service
To be honest, I don’t really understand it, I modified a couple of examples found on the internet and managed to get the output I needed.
Your solution works well too, and I prefer your solution, I understand it
Now time to add some HA automation to alert me for when I next forget to start appdaemon