Skip to content

Commit 91bf8f8

Browse files
authored
Merge pull request #9 from MobilGame06/master
Added area
2 parents 5b44127 + ae2cf6b commit 91bf8f8

4 files changed

Lines changed: 25 additions & 2 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,8 @@ Component: "light.bedroom_light" (HA -> Developer Tools -> Services -> Entity)
8282
ha.setComponent("light.bedroom_light");
8383
ha.sendHA();
8484
```
85+
```
86+
// 8. Set URL and Send area to HA
87+
ha.setURL("/api/services/light/turn_on");
88+
ha.sendHAArea("bedroom");
89+
```

examples/HAToggleLight/HAToggleLight.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,13 @@ void loop() {
8686
//ha.setURL("/api/services/light/turn_on");
8787
//ha.setComponent("light.bedroom_light");
8888
//ha.sendHA();
89+
90+
// 8. Set URL and Send area to HA
91+
//ha.setURL("/api/services/light/turn_on");
92+
//ha.sendHAArea("bedroom");
8993

9094
// Instead of Turn on light, lets toggle it
9195
ha.setURL("/api/services/light/toggle");
9296
ha.sendHAComponent("light.bedroom_3_light");
9397
}
94-
}
98+
}

src/HARestAPI.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,18 @@ bool HARestAPI::sendHAComponent(String URL, String Component)
317317
return sendPostHA(URL, Message);
318318
}
319319

320+
bool HARestAPI::sendHAArea(String Component)
321+
{
322+
String Message = "{\"area_id\":\"" + Component + "\"}";
323+
return sendPostHA(_url, Message);
324+
}
325+
326+
bool HARestAPI::sendHAArea(String URL , String Component)
327+
{
328+
String Message = "{\"area_id\":\"" + Component + "\"}";
329+
return sendPostHA(URL, Message);
330+
}
331+
320332
bool HARestAPI::sendHAURL(String URL)
321333
{
322334
String Message = "{\"entity_id\":\"" + _component + "\"}";
@@ -427,4 +439,4 @@ bool HARestAPI::sendHAAutomation(bool AutoStatus, String Component)
427439
{
428440
return sendPostHA("/api/services/automation/turn_off", Message);
429441
}
430-
}
442+
}

src/HARestAPI.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class HARestAPI
3434
bool sendHAURL(String);
3535
bool sendHAComponent(String);
3636
bool sendHAComponent(String, String);
37+
bool sendHAArea(String);
38+
bool sendHAArea(String, String);
3739
bool sendHARGBLight(void);
3840
bool sendHARGBLight(uint8_t, uint8_t, uint8_t);
3941
bool sendHARGBLight(String);

0 commit comments

Comments
 (0)