Text variables in dashboard markdown card

Hello, first time poster here. So, the issue I’m facing is that I’m using OpenAI’s API to use ChatGPT to send me notifications about electricity prices and I’m trying to make a “notifications” board for my dashboard. The issue here is that the ‘input text’ I’m trying to set and show in a markdown-card, shows up as “unknown” even though the automation trace shows it as being set correctly.
The research I’ve done suggests that the ChatGPT response might be longer than 255 char limit on the input text, so it won’t show it.

If anyone has a better solution or a work around. I’d appreaciate it alot.

I’ve added all of the relevant information as YAML and a picture.

Apparently new users can only add one picture. :sweat_smile:

Automation

alias: openai electricity price
description: ""
trigger: []
condition: []
action:
  - service: conversation.process
    data:
      agent_id: 980018072708513dbc69c57957e9302c
      text: >-
        Can you tell me how todays electricity price looks like and which time
        of day should i keep the usage at a minimum? any recommendations what
        time would be the best to use my appliances by looking at the price
        data? Units used are c/kWh. Here is the price data
        {{states('sensor.nordpool_kwh_fi_eur_3_095_024')}}.
    response_variable: elec_price_agent
  - service: notify.mobile_app_iphone_jonne
    data:
      message: "{{elec_price_agent.response.speech.plain.speech}}"
      title: Sähkön hinta tänään
  - service: input_text.set_value
    metadata: {}
    data:
      value: "{{elec_price_agent.response.speech.plain.speech | string }}"
    target:
      entity_id: input_text.e_price
mode: single

Automation trace

The input text is being set by my automation correctly.

{
  "trace": {
    "last_step": "action/2",
    "run_id": "2aea2abba983aedee57cdcebb809d2ee",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2024-05-19T18:22:30.442765+00:00",
      "finish": "2024-05-19T18:22:33.816378+00:00"
    },
    "domain": "automation",
    "item_id": "1716135532303",
    "trigger": null,
    "trace": {
      "trigger": [
        {
          "path": "trigger",
          "timestamp": "2024-05-19T18:22:30.442831+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.openai_electricity_price",
              "state": "on",
              "attributes": {
                "id": "1716135532303",
                "last_triggered": "2024-05-19T18:20:16.985370+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "openai electricity price"
              },
              "last_changed": "2024-05-19T18:22:28.956992+00:00",
              "last_reported": "2024-05-19T18:22:28.956992+00:00",
              "last_updated": "2024-05-19T18:22:28.956992+00:00",
              "context": {
                "id": "01HY91EGJW50WT1CDVMTQ2F3RD",
                "parent_id": null,
                "user_id": null
              }
            },
            "trigger": {
              "platform": null
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2024-05-19T18:22:30.443877+00:00",
          "changed_variables": {
            "context": {
              "id": "01HY91EJ1A96QTGPHPDA2VXFNE",
              "parent_id": "01HY91EJ1AH20DBHNHWN88QPZN",
              "user_id": null
            },
            "elec_price_agent": {
              "response": {
                "speech": {
                  "plain": {
                    "speech": "Tänään sähkön hinta näyttää olevan -0.001 c/kWh. Sehän on melkein liian hyvää ollakseen totta - taitaa olla parempi pitää silmällä mittareita, ettei tule maksettua liikaa!\n\nJos hinta on todella negatiivinen, suosittelen hyödyntämään sähkölaitteita silloin. Miksi et esimerkiksi pesisi pyykkiä tai kokkaisi herkkuillallista juuri silloin, kun sähkö on \"ilmaista\"? Aikamoinen herkkupäivä taitaa olla tiedossa, kun saa käyttää sähkölaitteita niin halvalla!",
                    "extra_data": null
                  }
                },
                "card": {},
                "language": "fi",
                "response_type": "action_done",
                "data": {
                  "targets": [],
                  "success": [],
                  "failed": []
                }
              },
              "conversation_id": "01HY91EJ1CNSZYRJX4H824X2SA"
            }
          },
          "result": {
            "params": {
              "domain": "conversation",
              "service": "process",
              "service_data": {
                "agent_id": "980018072708513dbc69c57957e9302c",
                "text": "Can you tell me how todays electricity price looks like and which time of day should i keep the usage at a minimum? any recommendations what time would be the best to use my appliances by looking at the price data? Units used are c/kWh. Here is the price data -0.001."
              },
              "target": {}
            },
            "running_script": false
          }
        }
      ],
      "action/1": [
        {
          "path": "action/1",
          "timestamp": "2024-05-19T18:22:33.331250+00:00",
          "result": {
            "params": {
              "domain": "notify",
              "service": "mobile_app_iphone_jonne",
              "service_data": {
                "message": "Tänään sähkön hinta näyttää olevan -0.001 c/kWh. Sehän on melkein liian hyvää ollakseen totta - taitaa olla parempi pitää silmällä mittareita, ettei tule maksettua liikaa!\n\nJos hinta on todella negatiivinen, suosittelen hyödyntämään sähkölaitteita silloin. Miksi et esimerkiksi pesisi pyykkiä tai kokkaisi herkkuillallista juuri silloin, kun sähkö on \"ilmaista\"? Aikamoinen herkkupäivä taitaa olla tiedossa, kun saa käyttää sähkölaitteita niin halvalla!",
                "title": "Sähkön hinta tänään"
              },
              "target": {}
            },
            "running_script": false
          }
        }
      ],
      "action/2": [
        {
          "path": "action/2",
          "timestamp": "2024-05-19T18:22:33.810512+00:00",
          "result": {
            "params": {
              "domain": "input_text",
              "service": "set_value",
              "service_data": {
                "value": "Tänään sähkön hinta näyttää olevan -0.001 c/kWh. Sehän on melkein liian hyvää ollakseen totta - taitaa olla parempi pitää silmällä mittareita, ettei tule maksettua liikaa!\n\nJos hinta on todella negatiivinen, suosittelen hyödyntämään sähkölaitteita silloin. Miksi et esimerkiksi pesisi pyykkiä tai kokkaisi herkkuillallista juuri silloin, kun sähkö on \"ilmaista\"? Aikamoinen herkkupäivä taitaa olla tiedossa, kun saa käyttää sähkölaitteita niin halvalla!",
                "entity_id": [
                  "input_text.e_price"
                ]
              },
              "target": {
                "entity_id": [
                  "input_text.e_price"
                ]
              }
            },
            "running_script": false
          }
        }
      ]
    },
    "config": {
      "id": "1716135532303",
      "alias": "openai electricity price",
      "description": "",
      "trigger": [],
      "condition": [],
      "action": [
        {
          "service": "conversation.process",
          "data": {
            "agent_id": "980018072708513dbc69c57957e9302c",
            "text": "Can you tell me how todays electricity price looks like and which time of day should i keep the usage at a minimum? any recommendations what time would be the best to use my appliances by looking at the price data? Units used are c/kWh. Here is the price data {{states('sensor.nordpool_kwh_fi_eur_3_095_024')}}."
          },
          "response_variable": "elec_price_agent"
        },
        {
          "service": "notify.mobile_app_iphone_jonne",
          "data": {
            "message": "{{elec_price_agent.response.speech.plain.speech}}",
            "title": "Sähkön hinta tänään"
          }
        },
        {
          "service": "input_text.set_value",
          "metadata": {},
          "data": {
            "value": "{{elec_price_agent.response.speech.plain.speech | string }}"
          },
          "target": {
            "entity_id": "input_text.e_price"
          }
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01HY91EJ1A96QTGPHPDA2VXFNE",
      "parent_id": "01HY91EJ1AH20DBHNHWN88QPZN",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "openai electricity price",
      "message": "triggered",
      "source": null,
      "entity_id": "automation.openai_electricity_price",
      "context_id": "01HY91EJ1A96QTGPHPDA2VXFNE",
      "when": 1716142950.4434414,
      "domain": "automation"
    }
  ]
}

Dashboard

The issue is that the input text is showing up as “unknown” and the input variable is being set a read-only.

type: markdown
content: |-
  **Electricity Price Info**: {{ states('input_text.e_price') }}
  {{states('elec_price_agent.response.speech.plain.speech')}}
title: Notifications

Your automation does not have a trigger.
I believe you could make this a triggered template sensor and set the value to the attribute.

I’m triggering the automation manually for now. Will add a time based trigger once i get the text variable working. The input text is being set regardless, will return the value “unknown”

Now after triggering it works some what, but the input text isn’t updated everytime the automation is ran. :thinking:

---

GPT: {{ states('input_text.e_price') }}

---

### Kello on {{ now().strftime('%H:%M:%S') }}
Keskiarvo hinta {{ state_attr('sensor.nordpool_kwh_fi_eur_3_095_024', 'average') }} {{ state_attr('sensor.nordpool_kwh_fi_eur_3_095_024', 'unit_of_measurement') }}
Minimi hinta {{ state_attr('sensor.nordpool_kwh_fi_eur_3_095_024', 'min') }} {{ state_attr('sensor.nordpool_kwh_fi_eur_3_095_024', 'unit_of_measurement') }}
Maksimi hinta {{ state_attr('sensor.nordpool_kwh_fi_eur_3_095_024', 'max') }} {{ state_attr('sensor.nordpool_kwh_fi_eur_3_095_024', 'unit_of_measurement') }}
Mediaani hinta {{ state_attr('sensor.nordpool_kwh_fi_eur_3_095_024', 'mean') }} {{ state_attr('sensor.nordpool_kwh_fi_eur_3_095_024', 'unit_of_measurement') }}

### **Tämän hetkinen hinta {{ state_attr('sensor.nordpool_kwh_fi_eur_3_095_024', 'current_price') }} {{ state_attr('sensor.nordpool_kwh_fi_eur_3_095_024', 'unit_of_measurement') }}**

---

How many characters are in the value you’re attempting to store in the Input Text?

It can only store a maximum of 255 characters.


EDIT

Here’s the value.

Tänään sähkön hinta näyttää olevan -0.001 c/kWh. Sehän on melkein liian hyvää ollakseen totta - taitaa olla parempi pitää silmällä mittareita, ettei tule maksettua liikaa!\n\nJos hinta on todella negatiivinen, suosittelen hyödyntämään sähkölaitteita silloin. Miksi et esimerkiksi pesisi pyykkiä tai kokkaisi herkkuillallista juuri silloin, kun sähkö on "ilmaista"? Aikamoinen herkkupäivä taitaa olla tiedossa, kun saa käyttää sähkölaitteita niin halvalla!

The first line is about 40 characters.
So that makes me estimate it to be about 200 characters in the input_text.

You should change it to a template sensor and store it in the attribute, as I said before.
Or you can make it complex and split the string in two parts to two input_text.