Skip to content

Commit

Permalink
Fix handling of multiple sprinklers (openhab#16630)
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Hilbush <[email protected]>
  • Loading branch information
mhilbush authored Apr 14, 2024
1 parent 5cf2a99 commit 815ada9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,11 @@ private void updateAllStatuses() {
List<OrbitBhyveDevice> devices = getDevices();
for (Thing th : getThing().getThings()) {
if (th.isEnabled()) {
String deviceId = th.getUID().getId();
ThingHandler handler = th.getHandler();
if (handler instanceof OrbitBhyveSprinklerHandler sprinklerHandler) {
String deviceId = sprinklerHandler.getSprinklerId();
for (OrbitBhyveDevice device : devices) {
if (deviceId.equals(th.getUID().getId())) {
if (deviceId.equals(device.getId())) {
updateDeviceStatus(device, sprinklerHandler);
}
}
Expand All @@ -345,9 +345,9 @@ private void updateDeviceStatus(@Nullable OrbitBhyveDevice device, @Nullable Orb

private void updateDeviceStatus(String deviceId) {
for (Thing th : getThing().getThings()) {
if (deviceId.equals(th.getUID().getId())) {
ThingHandler handler = th.getHandler();
if (handler instanceof OrbitBhyveSprinklerHandler sprinklerHandler) {
ThingHandler handler = th.getHandler();
if (handler instanceof OrbitBhyveSprinklerHandler sprinklerHandler) {
if (deviceId.equals(sprinklerHandler.getSprinklerId())) {
OrbitBhyveDevice device = getDevice(deviceId);
updateDeviceStatus(device, sprinklerHandler);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
}
}

private String getSprinklerId() {
public String getSprinklerId() {
return getThing().getConfiguration().get("id") != null ? getThing().getConfiguration().get("id").toString()
: "";
}
Expand Down

0 comments on commit 815ada9

Please sign in to comment.