How to read fields from android widget service call?

I have a very simple rest command service in my configuration.yaml file:

rest_command:
    send_ping:
        url: 'http://192.168.3.33:33333/custom/create'
        method: POST
        content_type: "application/json"
        payload: '{
            "title":"fizz",
            "attributes":"event=fizz",
            "content":"test!"
        }'

This works great. However, I want to have multiple different versions of this, where the payload is the only thing that changes. I could make 5 or 6 versions of this service, but I noticed in the Android widget configuration options, there’s the ability to add new fields to the service call (via the ‘ADD FIELDS’ button).

However, I’ve been unable to discover what those extra fields do, and if data included in those fields would be usable in the service; ideally to replace the title/attributes/content values with ones provided by the fields. That way, I can keep having just one service, and instead make 5 or 6 different widgets on my phone, each with their own unique fields.

Is this possible? Or to put it another way; what do the fields in Android widgets do?

Are you talking about these widgets? Android Widgets | Home Assistant Companion Docs

Yep I am. I found that doc page but it doesn’t seem to have any info on the additional fields you can add to the Service Call widget.

I had a look at my phone and I figured that was it. I am figuring it is for something like a brightness: or color: in a service call for a light.

Does that mean I can use that field for my own rest call service?

I don’t know, perhaps try it?

I added a custom field, but it had no effect. Looking at the HA logs, I didn’t see any difference either. The issue is that the rest service docs don’t mention anything about receiving data from a call either.

Well it is templatable, so the answer may lie there.

Do you know if it’s possible to use templates to receive data from service calls? From what I can see it’s only for putting in entity values…

Not sure what you mean by “receive data from service calls”.

So my payload now looks like this:

payload: '{
            "title":"fizz",
            "attributes":"event=fizz",
            "content":"{{value}}, {{value_json}}, {{value_json.test}}, {{value_json.Test}},"
        }'

I’m trying to use this info in the docs. On my phone, I’ve made my service widget have a new field called test, which has a value wazz.

However, when I try the call, I get this in my logs:

  • Template variable warning: ‘value’ is undefined when rendering ‘{ “title”:“fizz”, “attributes”:“event=fizz”, “content”:"{{value}}, {{value_json}}, {{value_json.test}}, {{value_json.Test}}," }’
  • Template variable warning: ‘value_json’ is undefined when rendering ‘{ “title”:“fizz”, “attributes”:“event=fizz”, “content”:"{{value}}, {{value_json}}, {{value_json.test}}, {{value_json.Test}}," }’

So it looks like it’s not receiving these widget field values in this way at least.