HARestAPI: Control Home Assistant Directly Using ESP8266
April 14, 20183 min read
📺 Watch the Video View on YouTube --- Control components on Home Assistant directly from ESP8266. This is an Arduino Library that can be used in vari...
Control components on Home Assistant directly from ESP8266. This is an Arduino Library that can be used in various projects without the requirement of setup of a MQTT sensor + automation on HA. This uses RESTful API commands.
Idea
•Control components on Home Assistant directly from ESP8266.
Implementation
•Develop an Arduino Library that can be used in various projects without the requirement of setup of a MQTT sensor + automation on HA. This uses RESTful API commands.
// 1. Send custom DATA to HA
ha.sendCustomHAData("/api/services/light/turn_on", "{\"entity_id\":\"light.bedroom_light\"}");
// 2. Set component and send light to HA // Will set tmpURL to "/api/services/light/turn_on"
ha.setComponent("light.bedroom_light");
ha.sendHALight(true);
// 3. Set light on/off as bool and component is 2nd input, Send Light to HA
// Will set tmpURL to "/api/services/light/turn_on"
ha.sendHALight(true, "light.bedroom_light");
// 4. Set component and URL is 2nd input, Send custom URL to HA
ha.setComponent("light.bedroom_light");
ha.sendHAURL("/api/services/light/turn_on");
// 5. Set URL and Send component to HA
ha.setURL("/api/services/light/turn_on");
ha.sendHAComponent("light.bedroom_light");
// 6. Set URL 1st argument, component 2nd, send to HA
ha.sendHAComponent("/api/services/light/turn_on", "light.bedroom_light");
// 7. Set URL , Set component, send to HA
ha.setURL("/api/services/light/turn_on");
ha.setComponent("light.bedroom_light");
ha.sendHA();