Skip to content

Commit

Permalink
fix detatched input
Browse files Browse the repository at this point in the history
  • Loading branch information
markirb committed Jun 14, 2024
1 parent 51cf40f commit 87a72ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/ShellyPlus1/shelly_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ void CreateComponents(std::vector<std::unique_ptr<Component>> *comps,
HAPAccessoryServerRef *svr) {
bool gdo_mode = mgos_sys_config_get_shelly_mode() == (int) Mode::kGarageDoor;
bool ext_sensor_switch = (FindInput(2) != nullptr);
bool detatched_sensor =
(mgos_sys_config_get_sw1_in_mode() == (int) InMode::kDetached) &&
!gdo_mode && ext_sensor_switch;
bool single_accessory = sensors.empty() && !detatched_sensor;
bool addon_input = !gdo_mode && ext_sensor_switch;
bool single_accessory =
sensors.empty() && !addon_input &&
(mgos_sys_config_get_sw1_in_mode() != (int) InMode::kDetached);
if (gdo_mode) {
hap::CreateHAPGDO(1, FindInput(1), FindInput(2), FindOutput(1),
FindOutput(1), mgos_sys_config_get_gdo1(), comps, accs,
Expand All @@ -83,7 +83,7 @@ void CreateComponents(std::vector<std::unique_ptr<Component>> *comps,
if (!sensors.empty()) {
CreateHAPSensors(&sensors, comps, accs, svr);
}
if (ext_sensor_switch && !gdo_mode) {
if (addon_input) {
hap::CreateHAPInput(2, mgos_sys_config_get_in2(), comps, accs, svr);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/ShellyPlus1PM/shelly_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ void CreateComponents(std::vector<std::unique_ptr<Component>> *comps,
HAPAccessoryServerRef *svr) {
bool gdo_mode = mgos_sys_config_get_shelly_mode() == (int) Mode::kGarageDoor;
bool ext_sensor_switch = (FindInput(2) != nullptr);
bool detatched_sensor =
(mgos_sys_config_get_sw1_in_mode() == (int) InMode::kDetached) &&
!gdo_mode && ext_sensor_switch;
bool single_accessory = sensors.empty() && !detatched_sensor;
bool addon_input = !gdo_mode && ext_sensor_switch;
bool single_accessory =
sensors.empty() && !addon_input &&
(mgos_sys_config_get_sw1_in_mode() != (int) InMode::kDetached);
if (gdo_mode) {
hap::CreateHAPGDO(1, FindInput(1), FindInput(2), FindOutput(1),
FindOutput(1), mgos_sys_config_get_gdo1(), comps, accs,
Expand All @@ -145,7 +145,7 @@ void CreateComponents(std::vector<std::unique_ptr<Component>> *comps,
if (!sensors.empty()) {
CreateHAPSensors(&sensors, comps, accs, svr);
}
if (ext_sensor_switch && !gdo_mode) {
if (addon_input) {
hap::CreateHAPInput(2, mgos_sys_config_get_in2(), comps, accs, svr);
}
}
Expand Down

0 comments on commit 87a72ab

Please sign in to comment.