How to make restful script

I want to make a switch with restful script service. Could somebody give a help?

This may help you:

1 Like

Have you looked at this:

Does it not provide the functionality you need? If not, you’ll need to provide more details about what you’re trying to do.

1 Like

I now use MQTT to post sensor updates for those that I can’t integrate with HA, but if you don’t want/can’t use MQTT you can simply post data straight into HA.
Check this post that I wrote a while back that should get you started

the main area for you to look at is

def HA_API_State(Device_Id, Value, Unit):
	url = "http://192.168.0.24:8123/api/states/" + str(Device_Id) + "?api_password=SECRET" 
	data={"state":"" + str(Value) + "", "attributes": {"unit_of_measurement": "" + str(Unit) + ""}}
	headers = {'Content-type':'application/json', 'Accept-Encoding': 'text/plain', 'Accept': 'text/plain'}
	r = requests.post(url, data=json.dumps(data), headers=headers)
	c = r.content
	result = simplejson.loads(c)

Check REST API | Home Assistant Developer Docs for more info

1 Like