#At my wit's end trying to store text for a dashboard card

1 messages · Page 1 of 1 (latest)

brave inlet
#

I have an automation that makes a call to openai to scrape a school lunch menu PDF, format it into an HTML page, and send it back. I then have a pyscript action that feeds the info to a python script, which writes to a file in /local. I've been working on this for like a solid two days, and I cannot get anything to write properly. Right now, it's not writing anything to the file. I've been using GPT to help with the scripting, in particular because I don't know Python. What's going wrong, or is there a better way to do this?

I attached the GPT response that is being passed to the {{ middlebrook_menu }} variable, as well as the python script.

Here is my action:

action: pyscript.write_html_file
metadata: {}
data:
  filename: middlebrook.html
  directory: school_menus
  data: |
    "{{ middlebrook_menu }}"
slender plover
#

I would probably do this a different way. Get the AI to return a json list rather than html store it in a file in the shared area in HA. Once it is in a file you can use a rest sensor to load it, and format the attributes how ever you want.

Perhaps something like this

- platform: rest
  name: roborock_rooms
  resource: http://192.168.1.245:8123/local/menu.json
  value_template: "{{ now() }}"
  json_attributes:
    - meals

That way you should not need any python

#