Switch with response indicator

Hello everyone, I’m an absolute beginner and unfortunately I don’t know where to start looking for the many possibilities.

I have built a switch that sends a restful command when pressed (scan a library). This library returns the code 204 if everything is good.

The question now is how could I modify the switch so that this confirmation is somehow visible, e.g. green light on success or red light on failure? The switch would of course have to be reset after a certain time for a new scan.

My switch:

If what you want is effectively a sensor why aren’t you using a REST sensor?

Ok, thank you. I have added following code in the configuration.yaml

  - platform: rest
    name: "Scan Library"
    method: post
    payload: '{"refreshAllFiles": false,"refreshModifiedFiles": true}'
        x-api-key: "Wxxxxxxxxxxxxxxxxxxxxxxxg"

Error comes from the method: post /

Invalid config for ‘rest’ from integration ‘sensor’ at configuration.yaml, line 26: value must be one of [‘GET’, ‘POST’] for dictionary value ‘method’, got ‘post’

And, how can I integrate this sensor in homeassistant. And where I have to add the response code “204”? A guide for dummies would be useful.

As the error states, you have set the method as post which is not one of the valid options… it needs to be POST.

You can use the value_template configuration variable to return your desired state values for whatever is returned from API call. The exact setup of the template will depend on the exact value being returned by the call.

POST - works now.thanks - for all the other stuff cant follow you. Maybe I have first to unterstand all this things in the next 5 years :frowning: