For the record:
Iām not certain what you are saying here and donāt think it has anything to do with my problem. In my case by moving everything to command_line.yaml the entity is now invalid. Commenting it out gives me the entity is not available.
My post was not addressed to you personally.
In your case you have a wrong syntax.
A valid structure is smth like this:
Check the documentation here.
I donāt see http_tasmota_switch1
as a possible option in the switch
map, so just remove it, or change it to be the value of a unique_id
key (without the colon at the end). Youāll also need to change the friendly_name
key to name
.
If you add a unique_id
key, you will be able to edit some of the entity properties through the UI.
This is what worked for me:
In configurations.yaml I added:
command_line: !include command_lines.yaml
Then in the new command_lines.yaml file I had to remove the
command_line:
line at the top. I guess it was redundant and was producing the same errors everyone was seeing.
This is the contents of my command_lines.yaml file in full as an example. Notice there is no starting line as ācommand_line:ā as some were suggesting above.:
- switch:
name: d_nvr
command_on: curl http:/{edit}@192.168.1.{edit}/outlet?1=ON
command_off: curl http:///{edit}@192.168.1.{edit}/outlet?1=OFF
- switch:
name: d_danmain
command_on: curl http:/{edit}@192.168.1.{edit}/outlet?1=ON
command_off: curl http:///{edit}@192.168.1.{edit}/outlet?1=OFF
- switch:
name: d_nvr`
name: d_danmain
So how do you get these to appear as entities so they can be added to the dashboard ?
My old dashboard worked as before. Use these entities:
switch.d_nvr
switch.d_danmain
Both appear on my custom outlet/switch dashboard I made and the on/off calls are working. I have them appear in my dashboard by just adding these two entities above. Hope that helps.!
Just chipping in with what worked for me - and thanks for the tips here, which helped me get this far.
I got this warning after upgrading to 2023.6.0
Command Line YAML configuration has moved. This stops working in version 2023.8.0. Please address before upgrading. Configuring Command Line
binary_sensor
using YAML has moved. Consult the documentation to move your YAML configuration to integration key and restart Home Assistant to fix this issue.
I use include files in my configuration.yaml - and the culprit was in my binary_sensor.yaml which looked like this:
- platform: command_line
name: OctoPrint camera status
device_class: connectivity
command: >
response=$(curl -LIk -m 5 http://octopi.local/webcam/ -o /dev/null -w
"%{http_code}\n" -s); test "$response" -eq 400 && echo "ON" || echo "OFF"
scan_interval: 60
value_template: '{{ value }}'
I removed that entry from the file and added this line to my configuration.yaml:
command_line: !include command_line.yaml
In command_line.yaml I added the following:
- binary_sensor:
name: OctoPrint camera status
device_class: connectivity
command: >
response=$(curl -LIk -m 5 http://octopi.local/webcam/ -o /dev/null -w
"%{http_code}\n" -s); test "$response" -eq 400 && echo "ON" || echo "OFF"
scan_interval: 60
value_template: '{{ value }}'
Rebooted and the warning disappeared. Hope that helps someone
Where exactly did you add the entities ?
Hi,
I am trying to fix these sensors but was not able.
I get duplicate entry error when moving the command line sensor from sensor.yaml to command_line.yaml, and not able to move the btc_price template sensor to template.yaml without getting any errors.
I would appreciate any help. Thanks in advance.
#############################
# CoinMarketCap Integration #
#############################
- platform: command_line
name: coinmarketcap_curl
command: 'curl -X GET -H "X-CMC_PRO_API_KEY: my_api_key" -H "Accept: application/json" -d "symbol=BTC,ADA,BNB,LTC,THETA,DOGE,BAKE,DOT&convert=USD" -G "https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest"'
value_template: '{{ value_json.value }}'
scan_interval: 900 #15 mins refresh (at 300 with 3 coins it will use 288 credits per day out of the allocated 333 credits)
json_attributes:
- data
- platform: template
sensors:
btc_price:
unique_id: 'btc_price'
friendly_name: 'Bitcoin Price'
unit_of_measurement: 'USD'
value_template: '{{ ((states.sensor.coinmarketcap_curl.attributes.data.BTC.quote.USD.price) | float) | round(5) }}'
sensor.yaml:
- platform: template
sensors:
btc_price:
....
command_line.yaml:
- sensor:
name: ...
command: ...
value_template: ...
configuration.yaml:
sensor: !include sensor.yaml
command_line: !include command_line.yaml
Hello,
Any ideas how to make this work with command_line?
switch:
- platform: rpi_gpio
ports:
23: Tehnoruum
invert_logic: true
Dear Community,
I had a command line switch, which I moved to command_line integration into a separate command_line yaml:
command_line:
- switch:
name: dahua_gate_open
command_on: "/usr/bin/curl -s --globoff --digest --user X:X 'http://192.168.0.251/cgi-bin/accessControl.cgi?action=openDoor&channel=1&UserID=101&Type=Remote'"
unique_id: dahua_gate_open
My problem is that I cannot call switch turn on service for this reconfigured switch, because I cannot reference the switch itself (not even in developer call service, not as a device, nor as an entitiy, and I donāt even see in the state list (not by name or unique_id), also not visible under Devices/entites listā¦
How can I call turn_on service for a command_line defined switch??
Trying to call turn on service in developer tools, command_line switch is not found:
I had the same issue as OP. I thought Iād post my previous YAML and my new YAML, which seems to be working now.
configuration.yaml
switch:
- platform: command_line
switches:
raspberry_pi_shutdown:
command_on: "ssh -i /config/ssh_keys/pi -o StrictHostKeyChecking=no [email protected] sudo /sbin/shutdown -h now"
hallway_pi_shutdown:
command_on: "ssh -i /config/ssh_keys/id_ed25519 -o StrictHostKeyChecking=no [email protected] pcp sd"
master_bedroom_pi_shutdown:
command_on: "ssh -i /config/ssh_keys/id_ed25519 -o StrictHostKeyChecking=no [email protected] pcp sd"
hallway_pi_reboot:
command_on: "ssh -i /config/ssh_keys/id_ed25519 -o StrictHostKeyChecking=no [email protected] pcp rb"
master_bedroom_pi_reboot:
command_on: "ssh -i /config/ssh_keys/id_ed25519 -o StrictHostKeyChecking=no [email protected] pcp rb"
And now, Iāve changed it to:
command_line:
- switch:
name: raspberry_pi_shutdown
command_on: "ssh -i /config/ssh_keys/pi -o StrictHostKeyChecking=no [email protected] sudo /sbin/shutdown -h now"
command_off: ""
- switch:
name: hallway_pi_shutdown
command_on: "ssh -i /config/ssh_keys/id_ed25519 -o StrictHostKeyChecking=no [email protected] pcp sd"
command_off: ""
- switch:
name: master_bedroom_pi_shutdown
command_on: "ssh -i /config/ssh_keys/id_ed25519 -o StrictHostKeyChecking=no [email protected] pcp sd"
command_off: ""
- switch:
name: hallway_pi_reboot
command_on: "ssh -i /config/ssh_keys/id_ed25519 -o StrictHostKeyChecking=no [email protected] pcp rb"
command_off: ""
- switch:
name: master_bedroom_pi_reboot
command_on: "ssh -i /config/ssh_keys/id_ed25519 -o StrictHostKeyChecking=no [email protected] pcp rb"
command_off: ""
Iām pretty sure this works.
I also had the same issueā¦ Here is my code that now works.
Old - Switch.yaml
- platform: command_line
switches:
http_tasmota_switch1:
command_on: /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.51/cm?cmnd=Power%20On'
command_off: /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.51/cm?cmnd=Power%20Off'
command_state: /usr/bin/curl -s -m 5 -X GET 'http://192.168.0.51/cm?cmnd=Power' || echo -n {\"POWER\":\"OFF\"}
value_template: '{{value_json.POWER == "ON" }}'
friendly_name: "Http_Tasmota 1"
http_tasmota_switch2:
command_on: /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.52/cm?cmnd=Power%20On'
command_off: /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.52/cm?cmnd=Power%20Off'
command_state: /usr/bin/curl -s -m 5 -X GET 'http://192.168.0.52/cm?cmnd=Power' || echo -n {\"POWER\":\"OFF\"}
value_template: '{{value_json.POWER == "ON" }}'
friendly_name: "Http_Tasmota 2"
http_tasmota_switch3:
command_on: /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.53/cm?cmnd=Power%20On'
command_off: /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.53/cm?cmnd=Power%20Off'
command_state: /usr/bin/curl -s -m 5 -X GET 'http://192.168.0.53/cm?cmnd=Power' || echo -n {\"POWER\":\"OFF\"}
value_template: '{{value_json.POWER == "ON" }}'
friendly_name: "Http_Tasmota 3"
http_tasmota_combo_switch:
command_on: /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.54/cm?cmnd=Power1%20On'
command_off: /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.54/cm?cmnd=Power1%20Off'
command_state: /usr/bin/curl -s -m 5 -X GET 'http://192.168.0.54/cm?cmnd=Power1' || echo -n {\"POWER\":\"OFF\"}
value_template: '{{value_json.POWER1 == "ON" }}'
friendly_name: "Http_Combo Switch 1"
http_tasmota_combo_switch2:
command_on: /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.54/cm?cmnd=Power2%20On'
command_off: /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.54/cm?cmnd=Power2%20Off'
command_state: /usr/bin/curl -s -m 5 -X GET 'http://192.168.0.54/cm?cmnd=Power2' || echo -n {\"POWER\":\"OFF\"}
value_template: '{{value_json.POWER2 == "ON" }}'
friendly_name: "Http_Combo Switch 2"
New Command_Line.yaml
- switch:
# http_tasmota_switch1:
command_on: /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.51/cm?cmnd=Power%20On'
command_off: /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.51/cm?cmnd=Power%20Off'
command_state: /usr/bin/curl -s -m 5 -X GET 'http://192.168.0.51/cm?cmnd=Power' || echo -n {\"POWER\":\"OFF\"}
value_template: '{{value_json.POWER == "ON" }}'
name: "Http_Tasmota 1"
unique_id: http_tasmota_switch1
- switch:
# http_tasmota_switch2:
command_on: /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.52/cm?cmnd=Power%20On'
command_off: /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.52/cm?cmnd=Power%20Off'
command_state: /usr/bin/curl -s -m 5 -X GET 'http://192.168.0.52/cm?cmnd=Power' || echo -n {\"POWER\":\"OFF\"}
value_template: '{{value_json.POWER == "ON" }}'
name: "Http_Tasmota 2"
unique_id: http_tasmota_switch2
- switch:
# http_tasmota_switch3:
command_on: /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.53/cm?cmnd=Power%20On'
command_off: /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.53/cm?cmnd=Power%20Off'
command_state: /usr/bin/curl -s -m 5 -X GET 'http://192.168.0.53/cm?cmnd=Power' || echo -n {\"POWER\":\"OFF\"}
value_template: '{{value_json.POWER == "ON" }}'
name: "Http_Tasmota 3"
unique_id: http_tasmota_switch3
- switch:
# http_tasmota_combo_switch1:
command_on: /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.54/cm?cmnd=Power1%20On'
command_off: /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.54/cm?cmnd=Power1%20Off'
command_state: /usr/bin/curl -s -m 5 -X GET 'http://192.168.0.54/cm?cmnd=Power1' || echo -n {\"POWER\":\"OFF\"}
value_template: '{{value_json.POWER2 == "ON" }}'
name: "Http_Combo Switch 1"
unique_id: http_tasmota_combo_switch 1
- switch:
# http_tasmota_combo_switch2:
command_on: /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.54/cm?cmnd=Power2%20On'
command_off: /usr/bin/curl -s -m 5 -X POST 'http://192.168.0.54/cm?cmnd=Power2%20Off'
command_state: /usr/bin/curl -s -m 5 -X GET 'http://192.168.0.54/cm?cmnd=Power2' || echo -n {\"POWER\":\"OFF\"}
value_template: '{{value_json.POWER2 == "ON" }}'
name: "Http_Combo Switch 2"
unique_id: http_tasmota_combo_switch 2
@scharmach
I always feel a bit stupid reading answers like this. āThe solution is in this postā
Why not being specific?
I think you need to get rid of the ācommand_line:ā at the top. It already knows itās a command_line when you included the command_line yaml file. This is what happened to me. Hope it maybe helps.
Hello everyone!
At the moment I have managed to make the rest of the sensors work for me with the new method
The problem comes to me with the systemmonitor integration, since it falls under sensor.
As:
sensor:
- platform: systemmonitor
resources:
-type: disk_use_percent
arg: /config
-type: memory_free
Does anyone know how to make it accept it and the warning not come?
I also additionally gave an example that is listed in the breaking changes (2023.6: Network storage, favorite light colors, new integrations dashboard - Home Assistant) and the solution has a link to the relevant documentation.
Hm, if Iām not mistaken, thatās not the case unfortunately, at least according to my previous experiences: the file name could be anything, the content matters. I splitted my configuration in to different yamls, and call them with āinclude dirā in main configuration yaml, but it doesnāt look at the filename, rather the content.
if I don define command_line at the beginning of the file, I get the following error upon yaml config validation in developer tools:
expected a dictionary for dictionary value @ data['packages']['command_line']
But you gave me a good idea, to try out the command_line integration in the main configuration, maybe it works there.