Python Script Not working2

I created the following python script to create random scripts for Alerts in my home. idea was to add some funk to my notifications

import random

q_comments = [
“A”,
“B”,
“C”,
“D”

]

random_comment = random.choice(q_comments)
hass.states.set(‘sensor.random_comment’, random_comment)

Then tried to call that script in an automation.

description: “”
trigger:
condition:
action:

  • service: python_script.q_comment
    data: {}
  • service: persistent_notification.create
    data:
    title: Reminder
    message: “{{states(‘sensor.random_comment’)}}”
    mode: single

I always get the response as Unknown.

Have you followed the “writing your first script” section of this documentation to ensure you have the integration set up correctly?

You can also test calling python_script.q_comment from the developer tools page to ensure the service is behaving as you expect.

Thanks for this.
I created the Hello World Script and that is showing in my logs.

I am being able to call the service but the value - sensor.random_comment is not getting created. I tried to use an existing helper instead of sensor.random_comment, even that does not work.