Sending HTTP post from HASS

I have a particle photon that I’m trying to use to remotely control a relay and send sensor data. I tried getting MQTT to work on it, but I have no idea what I’m doing and can hardly understand MQTT in the first place. I have been able to control an LED using a tasker HTTP post task.

Server:Port  https://api.particle.io
Path /v1/devices/<my device>/led?access_token=<my access token>
Data/File  params=on

I’ve tried using REST switch in my configuration.yaml file

switch 3:
  name: Particle
  platform: rest
  resource:  https://api.particle.io/v1/devices/<my device>/led?access_token=<my access token>
 method: PUT
 body_on: "ON"
 body_off: "OFF"

Any advice? My switch shows up in my states as switch.particle, but I don’t think it’s communicating with my particle.

I could be way off here so take what I say with a pinch of salt seeing as I’m days into HA myself.

Your example shows sending params=on where as your config shows just sending ON or OFF.

If you were sending json you could do:

body_on: "{\"params\":\"on\"}"

Not sure if it’s just normal http params that doing this is the alternative:

body_on: "params=on"

Thanks for the reply. Just tried it. Unfortunately it didn’t work.

Tried both?

I’ve just looked at the python requests doc and the first example should be correct. Could try:

body_on: "{'params': 'on'}"

Yeah still nothing.

body_on: "{'on': 'true'}"
?

Nope. I think I need to read up on the particle more.

Try this:

switch 3:
  name: Particle
  platform: rest
  resource:  https://api.particle.io/v1/devices/<my device>/led?access_token=<my access token>
  body_on: "params=on"
  body_off: "params=off"

Enybody got this to work? Sitting with the exact same problem as firs post!

anyone , anyone… bueller?

1 Like

Guess not, huh…