Hand sensor data/ status to Python-script?

Hi!

I’m learning from day to day but still am a noob obviously :slight_smile:

I’m trying to hand over sensor data/ values to a python script, specifically for the Awtrix-Display. I use this script to send messages to the display and it works just fine

trigger:
    platform: time_pattern
    # You can also match on interval. This will match every minute
    minutes: "/1"
  action:
    - service: python_script.awtrix
      data: 
       { "text":"testmessage","iconnr":"22","count":"4" }

Question: How can I write sensor data to the “text”-field? Do I have to use a data-template?

What I want to achieve:

 data: 
       { "text":"The temperature is <<sensordata>>","iconnr":"22","count":"4" }

Please help me :slight_smile:

First, you don’t need to write it as a json object. Just use yaml. Second, Yes, use data_template, then learn templates and populate the text field with whatever code you want.

  trigger:
    platform: time_pattern
    # You can also match on interval. This will match every minute
    minutes: "/1"
  action:
    - service: python_script.awtrix
      data_template: 
        text: "{{ <insert template here> }}"
        iconnr: 22
        count: 4