Yea if your command has both single and double quotes in it then you have to escape one of them. What I usually do is wrap the command in single quotes and then escape the single quotes inside, you do this by using a double single quote (''). There’s actually an example of this in the package at the top, here’s the command line sensor for the new addons one:
# Sensor to track details on new addons
- platform: command_line
name: New addons
command: 'curl http://supervisor/addons -H "Authorization: Bearer $(printenv SUPERVISOR_TOKEN)" 2> /dev/null | jq --slurpfile slugs /config/common/found_addon_slugs.txt ''{"addons":[.data.addons[] | select(.slug as $slug | $slugs | index($slug) | not)], "repositories":.data.repositories}'''
scan_interval: 900
unit_of_measurement: new release(s)
value_template: "{{ value_json.addons | length }}"
json_attributes:
- addons
- repositories
- addon_slugs
Notice the command has both single and double quotes in it so the single quotes are escaped inside.
The problem seems to be the RegEx part. As soon as I have at least one \ in the command_line sensor command, Visual Studio Code complains unknown escape sequence
Oh I see what you mean. Maybe try replacing all the single backslashes with \\? So that way the first interpreter sees the escape sequence for backslash and then passes on a backslash to the command itself.
I received a mail from GitHub, stating my “personal access token, HACS , has an outdated format”.
Looking at HACS, I do not see any option in updating the GitHub token in HACS.
Anyone has suggestions?
Thanks.
Hello and thanks for sharing this!
I’m rather new to HA and never tried packages before.
I’ve put your code in a yaml and linked it in config.yaml, but when I check the config I get “Package update_notification setup failed. Component alert has duplicate key ‘name’”.
Is there any way to fix this?
Thanks!
This error message tells you, that there is the name tag set twice in alert.
You should be able to find that in your package file, otherwise post the content of that file. Obviously there seem to be an error in your package file, as in the first post there is only one name tag under alert.
Hi, great job is done here, works lke a charm, much apreсiated.
I have a question though: I want to make those update sensors to look similar to standard binary_sensor.updater, which values are nice No updates and Update available, but here it’s just Off and OK.
Can I change those values somehow?
Update: Nevemind, found the solution in offical docs. Just add to those sensors:
Hopefully this grows into an addon itself that can be a one click install into home assistant.
I am just overwhelmed with all the config I have to do and i am afraid I am gonna mess my HA if I mess with this.
Thanks I did a search in my HA after you posted the the code and I found that I had already setup this sensor. I set this up the same time and the same way that I set up the core sensor. Now I need to remember why I didn’t add it to my system status card? I had an issue getting the current version. On the core I setup a “update sensor”