Hey i need some help, i have a working commandline sensor in a command_line.yaml file thats included like this command_line: !include command_line.yaml in the configuration.yaml.
Now i moved it from the config directory into the packages folder, renamed it to speedtest.yaml and include it like this homeassistant: packages: !include_dir_named packages
But its not working now even though i adapted the config to the new syntax.
I attached both .yaml files, i am assuming it might be connected to the path, but it should not have changed since all since the .json files the sensors are calling stayed in the same place. Hope this is an easy issues for some of you experts
#Moving a work Command_line sensor in another config but it doesnt work
1 messages · Page 1 of 1 (latest)
neither of those starts with command_line:
seems like you just changed the original definition and broke it: https://www.home-assistant.io/integrations/command_line/
thats what the platform key is for isnt it? i am not understanding what you mean
It makes sense that the file you include doesn't start with command_line: as you already have that in configuration.yaml
But in packages you need to add the integration
you need to follow the complete definition in your new package
but am i not doing that with the platform: command_line key? i am doing something similar with template sensors and this works as follows:
# Template Sensors
- platform: template
sensors:
speedtest_cron_download:
unique_id: "speedtest_cron_download"
friendly_name: Download
value_template: '{{ states.sensor.speedtest_cron.attributes.download.bandwidth | multiply(0.000008) | round(2) }}'
unit_of_measurement: 'Mbit/s'
availability_template: '{{ states("sensor.speedtest_cron") != "unavailable" and states.sensor.speedtest_cron.attributes.download.bandwidth is defined }}'```
you can't use platform: command_line anymore
see the docs
that's been gone for a long time
and it wasn't what you were using before
you can use whatever you had in configuration.yaml in a package directly, as-is. You don't need to go and modify anything
you're doing extra work and breaking things
ahh okay i understand now, i thought the syntax with the platform key is for all keys just depending on how they are called in the config
no, you need to follow the docs for each integration
everything is slowly moving away from the platform: xxx syntax
Alright i understand now, thank you i have it working now with the following
- sensor:
name: speedtest_cron
unique_id: speedtest_cron
command: "cat /config/speedtest_cmd/speedtest-result-crontab.json"
scan_interval: 120
command_timeout: 5
json_attributes:
- isp
- download
- upload
- interface
- server
- timestamp
value_template: "{{ value_json.download['bandwidth'] }} / {{ value_json.upload['bandwidth'] }}"
- sensor:
name: ping_test_cron
unique_id: "ping_test_cron"
command: "cat /config/speedtest_cmd/ping-result-crontab.json"
scan_interval: 120
command_timeout: 5
json_attributes:
- report
value_template: "{{ value_json.report.mtr['dst'] }}"```
you can also just include the file exactly like before if you want
which one would be the " better" or correcter way to do it?
entirely personal preference
if the reason that led you to include the file before is negated by moving to a package, keep what you have above
alright then ill go with the one above
reason for moving away from what i had before was, that my sensors and things were all scattered and i want to put them into packages so i have everything related to "speedtest" for example in the same file, before or when i setup HA for the first time i thought seperating by type would be best but now that i hav alot more stuff i find myself searching for things alot, so id like to group them better
but if everything is moving away from the platform syntax, ill definetly move away from it, i have that probably everywhere 😄 gues sill do that in the same process now