Fix handling of multiple sprinklers (#16630)

Signed-off-by: Mark Hilbush <mark@hilbush.com>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
Mark Hilbush 2024-04-14 14:04:39 -04:00 committed by Ciprian Pascu
parent e0cf6777d5
commit b9fb88a023
2 changed files with 6 additions and 6 deletions

View File

@ -321,11 +321,11 @@ public class OrbitBhyveBridgeHandler extends ConfigStatusBridgeHandler {
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);
}
}
@ -345,9 +345,9 @@ public class OrbitBhyveBridgeHandler extends ConfigStatusBridgeHandler {
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);
}

View File

@ -120,7 +120,7 @@ public class OrbitBhyveSprinklerHandler extends BaseThingHandler {
}
}
private String getSprinklerId() {
public String getSprinklerId() {
return getThing().getConfiguration().get("id") != null ? getThing().getConfiguration().get("id").toString()
: "";
}