I’m building a wand project found where a raspberry pi processes wand gestures and sends the appropriate corresponding ids through a post API to trigger a switch or light.
From the
Given the section of the python wand code:
def PerformSpell(spell):
"""
Make the desired Home Assistant REST API call based on the spell
"""
if (spell=="incendio"):
hass.TriggerAutomation("automation.wand_insendio")
elif (spell=="aguamenti"):
hass.TriggerAutomation("automation.wand_aquamenti")
If a match occurs sends to this section of the HassApi.py
def TriggerAutomation(self, name):
url = self.url + "/api/services/automation/trigger"
headers = {
'Authorization': "Bearer " + self.token,
}
payload = {"entity_id": name}
response = requests.post(url, data=json.dumps(payload), headers=headers)
print(response.text)
This is the part where I get stuck. I’m new to HA and learned as much as I could before asking here. I’ve configured simple hardware switches that seemed like no brainers. Now I’ve gone deeper playing with APIs and that’s where I can’t seem to absorb.
I have a token and it works by testing through the curl commands.
How do I activate a switch given the information above through the UI?
Thanks!
Bob