New Command Line Syntax

Trying to get ahead of breaking changes with this, but i can’t seem to get the new syntax to work. Here is my current code:

- platform: command_line
  name: GPT Katie Turn Off TV
  json_attributes:
    - choices
  command: "curl -XPOST https://api.openai.com/v1/chat/completions -H 'Content-Type: application/json' -H 'Authorization: Bearer xxxxx' -d '{\"model\": \"gpt-3.5-turbo\", \"messages\": [{\"role\": \"user\", \"content\": \"xxxx\"}], \"top_p\": 1, \"temperature\": 0.85, \"max_tokens\": 250, \"presence_penalty\": 1}'"
  value_template: "{{ now() }}"
  scan_interval: 86400

Here is what i have for the new syntax:

command_line:
#   - sensor:
#       - name: GPT Katie Turn Off TV
#         json_attributes:
#           - choices
#         command: "curl -XPOST https://api.openai.com/v1/chat/completions -H 'Content-Type: application/json' -H 'Authorization: Bearer xxxxx' -d '{\"model\": \"gpt-3.5-turbo\", \"messages\": [{\"role\": \"user\", \"content\": \"xxxx\"}], \"top_p\": 1, \"temperature\": 0.85, \"max_tokens\": 250, \"presence_penalty\": 1}'"
#         value_template: "{{ now() }}"
#         scan_interval: 86400

I’ve tried several different iterations of this. I also watched Slacker Labs Youtube video on this and followed his syntax layout, but no go.

What am i missing?

Name shouldn’t be hyphenated and everything from name down is indented too far.

The Slacker Labs video showed the same problem and talked about fixing it in the last two minutes or so of the video you linked.

Yeah, i watched the video.

command_line:
  sensor:
    name: GPT Katie Turn Off TV
    json_attributes:
      - choices
    command: "curl -XPOST https://api.openai.com/v1/chat/completions -H 'Content-Type: application/json' -H 'Authorization: Bearer xxxx' -d '{\"model\": \"gpt-3.5-turbo\", \"messages\": [{\"role\": \"user\", \"content\": \"xxxx\"}], \"top_p\": 1, \"temperature\": 0.85, \"max_tokens\": 250, \"presence_penalty\": 1}'"
    value_template: "{{ now() }}"
    scan_interval: 60

This doesn’t work either.

You need the hyphen for sensor. You need no other hyphens.

command_line:
  - sensor:
      name: GPT Katie Turn Off TV
      json_attributes:
        - choices
      command: "curl -XPOST https://api.openai.com/v1/chat/completions -H 'Content-Type: application/json' -H 'Authorization: Bearer xxxxx' -d '{\"model\": \"gpt-3.5-turbo\", \"messages\": [{\"role\": \"user\", \"content\": \"xxxx\"}], \"top_p\": 1, \"temperature\": 0.85, \"max_tokens\": 250, \"presence_penalty\": 1}'"
      value_template: "{{ now() }}"
      scan_interval: 86400
1 Like

moved it from my sensors.yaml to configuration.yaml and now it works. no hypens. did i miss that it has to go in configuration.yaml?

** edit **
this is what worked when i moved it:

command_line:
  sensor:
    name: GPT Katie Turn Off TV
    json_attributes:
      - choices
    command: "curl -XPOST https://api.openai.com/v1/chat/completions -H 'Content-Type: application/json' -H 'Authorization: Bearer xxxx' -d '{\"model\": \"gpt-3.5-turbo\", \"messages\": [{\"role\": \"user\", \"content\": \"xxxx\"}], \"top_p\": 1, \"temperature\": 0.85, \"max_tokens\": 250, \"presence_penalty\": 1}'"
    value_template: "{{ now() }}"
    scan_interval: 60

Yes you must have missed that. Its covered in the docs

:man_facepalming:
well, crap. details…