I am trying to call a turn_on through services on my relay from Python. This is my python code:
import requests as req
headers = {'x-ha-access': ':-P', 'content-type': 'application/json'}
url = 'http://localhost:8123/api/services/turn_on'
data = 'service_data={"entity_id": "switch.relay_3"}'
response = req.post(url, headers=headers, data=data)
print(response.text)
All I get is 404: Not Found…
I tried the data as follows also
data = {“entity_id”: “switch.relay_3”}
data = ‘{“entity_id”: “switch.relay_3”}’
those did not work either.