Skip to content

Commit

Permalink
gdo optionally swap sensors
Browse files Browse the repository at this point in the history
swap inputs not outputs

Typo fix
  • Loading branch information
markirb committed Oct 7, 2024
1 parent 1dfb448 commit 89d45a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions mos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ config_schema:

- ["gdo", "o", {title: "Garage door settings", abstract: true}]
- ["gdo.name", "s", "Garage Door", {title: "Accessory name"}]
- ["gdo.sensor_swap", "b", false, {title: "Whether to swap the two input sensors"}]
- ["gdo.close_sensor_mode", "i", 0, {title: "Close sensor mode: 0 - normally closed, 1 - normally open"}]
- ["gdo.open_sensor_mode", "i", 0, {title: "Close sensor mode: 0 - normally closed, 1 - normally open, 2 - disabled"}]
- ["gdo.out_mode", "i", 0, {title: "Output mode: 0 - single (open=close=1), 1 - dual (1=open, 2=close), 2 - single inverted (open=close=1)"}]
Expand Down
5 changes: 5 additions & 0 deletions src/shelly_hap_garage_door_opener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,11 @@ void CreateHAPGDO(int id, Input *in_close, Input *in_open, Output *out_close,
HAPAccessoryServerRef *svr, bool to_pri_acc) {
struct mgos_config_gdo *gdo2_cfg = (struct mgos_config_gdo *) gdo_cfg;

if (gdo_cfg->sensor_swap) {
Input *tmp = in_close;
in_close = in_open;
in_open = tmp;
}
std::unique_ptr<hap::GarageDoorOpener> gdo(new hap::GarageDoorOpener(
id, in_close, in_open, out_close, out_open, gdo2_cfg));
auto st = gdo->Init();
Expand Down

0 comments on commit 89d45a6

Please sign in to comment.