diff --git a/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/api/HydrawiseConnectionException.java b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/api/HydrawiseConnectionException.java index 0421f15e2e0..acfc1fb6979 100644 --- a/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/api/HydrawiseConnectionException.java +++ b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/api/HydrawiseConnectionException.java @@ -23,6 +23,9 @@ import org.eclipse.jdt.annotation.NonNullByDefault; public class HydrawiseConnectionException extends Exception { private static final long serialVersionUID = 1L; + private int code = 0; + private String response = ""; + public HydrawiseConnectionException(Exception e) { super(e); } @@ -30,4 +33,22 @@ public class HydrawiseConnectionException extends Exception { public HydrawiseConnectionException(String message) { super(message); } + + public HydrawiseConnectionException(String message, int code, String response) { + super(message); + this.code = code; + this.response = response; + } + + public static long getSerialversionuid() { + return serialVersionUID; + } + + public int getCode() { + return code; + } + + public String getResponse() { + return response; + } } diff --git a/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/api/graphql/HydrawiseGraphQLClient.java b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/api/graphql/HydrawiseGraphQLClient.java index 381d78000eb..4d933306324 100644 --- a/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/api/graphql/HydrawiseGraphQLClient.java +++ b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/api/graphql/HydrawiseGraphQLClient.java @@ -36,6 +36,7 @@ import org.openhab.binding.hydrawise.internal.api.HydrawiseCommandException; import org.openhab.binding.hydrawise.internal.api.HydrawiseConnectionException; import org.openhab.binding.hydrawise.internal.api.graphql.dto.ControllerStatus; import org.openhab.binding.hydrawise.internal.api.graphql.dto.Forecast; +import org.openhab.binding.hydrawise.internal.api.graphql.dto.Hardware; import org.openhab.binding.hydrawise.internal.api.graphql.dto.Mutation; import org.openhab.binding.hydrawise.internal.api.graphql.dto.MutationResponse; import org.openhab.binding.hydrawise.internal.api.graphql.dto.MutationResponse.MutationResponseStatus; @@ -77,7 +78,8 @@ public class HydrawiseGraphQLClient { .registerTypeAdapter(ZoneRun.class, new ResponseDeserializer()) .registerTypeAdapter(Forecast.class, new ResponseDeserializer()) .registerTypeAdapter(Sensor.class, new ResponseDeserializer()) - .registerTypeAdapter(ControllerStatus.class, new ResponseDeserializer()).create(); + .registerTypeAdapter(ControllerStatus.class, new ResponseDeserializer()) + .registerTypeAdapter(Hardware.class, new ResponseDeserializer()).create(); private static final String GRAPH_URL = "https://app.hydrawise.com/api/v2/graph"; private static final String MUTATION_START_ZONE = "startZone(zoneId: %d) { status }"; @@ -94,6 +96,7 @@ public class HydrawiseGraphQLClient { private final HttpClient httpClient; private final OAuthClientService oAuthService; private String queryString = ""; + private String weatherString = ""; public HydrawiseGraphQLClient(HttpClient httpClient, OAuthClientService oAuthService) { this.httpClient = httpClient; @@ -110,19 +113,48 @@ public class HydrawiseGraphQLClient { public @Nullable QueryResponse queryControllers() throws HydrawiseConnectionException, HydrawiseAuthenticationException { try { - QueryRequest query = new QueryRequest(getQueryString()); - String queryJson = gson.toJson(query); - String response = sendGraphQLQuery(queryJson); - try { - return gson.fromJson(response, QueryResponse.class); - } catch (JsonSyntaxException e) { - throw new HydrawiseConnectionException("Invalid Response: " + response); - } + return queryRequest(getQueryString()); } catch (IOException e) { throw new HydrawiseConnectionException(e); } } + /** + * Sends a GrapQL query for controller data + * + * @return QueryResponse + * @throws HydrawiseConnectionException + * @throws HydrawiseAuthenticationException + */ + public @Nullable QueryResponse queryWeather() + throws HydrawiseConnectionException, HydrawiseAuthenticationException { + try { + return queryRequest(getWeatherString()); + } catch (IOException e) { + throw new HydrawiseConnectionException(e); + } + } + + /** + * Sends a GrapQL query for controller data + * + * @param queryString + * @return QueryResponse + * @throws HydrawiseConnectionException + * @throws HydrawiseAuthenticationException + */ + private @Nullable QueryResponse queryRequest(String queryString) + throws HydrawiseConnectionException, HydrawiseAuthenticationException { + QueryRequest query = new QueryRequest(queryString); + String queryJson = gson.toJson(query); + String response = sendGraphQLQuery(queryJson); + try { + return gson.fromJson(response, QueryResponse.class); + } catch (JsonSyntaxException e) { + throw new HydrawiseConnectionException("Invalid Response: " + response); + } + } + /*** * Stops a given relay * @@ -313,7 +345,8 @@ public class HydrawiseGraphQLClient { int statusCode = response.getStatus(); if (!HttpStatus.isSuccess(statusCode)) { throw new HydrawiseConnectionException( - "Request failed with HTTP status code: " + statusCode + " response: " + stringResponse); + "Request failed with HTTP status code: " + statusCode + " response: " + stringResponse, + statusCode, stringResponse); } return stringResponse; } catch (InterruptedException | TimeoutException | OAuthException | IOException e) { @@ -338,15 +371,25 @@ public class HydrawiseGraphQLClient { private String getQueryString() throws IOException { if (queryString.isBlank()) { - try (InputStream inputStream = HydrawiseGraphQLClient.class.getClassLoader() - .getResourceAsStream("query.graphql"); - BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))) { - queryString = bufferedReader.lines().collect(Collectors.joining("\n")); - } + queryString = getResourceString("query.graphql"); } return queryString; } + private String getWeatherString() throws IOException { + if (weatherString.isBlank()) { + weatherString = getResourceString("weather.graphql"); + } + return weatherString; + } + + private String getResourceString(String name) throws IOException { + try (InputStream inputStream = HydrawiseGraphQLClient.class.getClassLoader().getResourceAsStream(name); + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))) { + return bufferedReader.lines().collect(Collectors.joining("\n")); + } + } + class ResponseDeserializer implements JsonDeserializer { @Override @Nullable diff --git a/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/api/graphql/dto/Controller.java b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/api/graphql/dto/Controller.java index d339efe4a62..e5e3d794f9b 100644 --- a/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/api/graphql/dto/Controller.java +++ b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/api/graphql/dto/Controller.java @@ -22,8 +22,8 @@ public class Controller { public Integer id; public String name; public ControllerStatus status; + public Hardware hardware; public Location location; public List zones = null; public List sensors = null; - public List forecast = null; } diff --git a/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/api/graphql/dto/Hardware.java b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/api/graphql/dto/Hardware.java new file mode 100644 index 00000000000..478a144b294 --- /dev/null +++ b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/api/graphql/dto/Hardware.java @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2010-2024 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.hydrawise.internal.api.graphql.dto; + +/** + * + * @author Dan Cunningham - Initial contribution + * + */ +public class Hardware { + public String version; + public Model model; +} diff --git a/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/api/graphql/dto/Model.java b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/api/graphql/dto/Model.java new file mode 100644 index 00000000000..0981ca7c9f0 --- /dev/null +++ b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/api/graphql/dto/Model.java @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2010-2024 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.hydrawise.internal.api.graphql.dto; + +/** + * + * @author Dan Cunningham - Initial contribution + * + */ +public class Model { + public Integer maxZones; + public String name; + public String description; +} diff --git a/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/discovery/HydrawiseCloudControllerDiscoveryService.java b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/discovery/HydrawiseCloudControllerDiscoveryService.java index b01ab606325..fe8c8c11e06 100644 --- a/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/discovery/HydrawiseCloudControllerDiscoveryService.java +++ b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/discovery/HydrawiseCloudControllerDiscoveryService.java @@ -12,22 +12,23 @@ */ package org.openhab.binding.hydrawise.internal.discovery; -import java.time.Instant; +import java.util.Date; import java.util.List; import java.util.Set; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.hydrawise.internal.HydrawiseBindingConstants; import org.openhab.binding.hydrawise.internal.HydrawiseControllerListener; import org.openhab.binding.hydrawise.internal.api.graphql.dto.Controller; import org.openhab.binding.hydrawise.internal.api.graphql.dto.Customer; import org.openhab.binding.hydrawise.internal.handler.HydrawiseAccountHandler; -import org.openhab.core.config.discovery.AbstractThingHandlerDiscoveryService; +import org.openhab.core.config.discovery.AbstractDiscoveryService; import org.openhab.core.config.discovery.DiscoveryResultBuilder; import org.openhab.core.thing.ThingUID; +import org.openhab.core.thing.binding.ThingHandler; import org.openhab.core.thing.binding.ThingHandlerService; import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.ServiceScope; /** * @@ -36,33 +37,44 @@ import org.osgi.service.component.annotations.ServiceScope; */ @NonNullByDefault -@Component(scope = ServiceScope.PROTOTYPE, service = ThingHandlerService.class) -public class HydrawiseCloudControllerDiscoveryService - extends AbstractThingHandlerDiscoveryService implements HydrawiseControllerListener { +@Component(service = ThingHandlerService.class) +public class HydrawiseCloudControllerDiscoveryService extends AbstractDiscoveryService + implements HydrawiseControllerListener, ThingHandlerService { + private static final int TIMEOUT = 5; + @Nullable + HydrawiseAccountHandler handler; public HydrawiseCloudControllerDiscoveryService() { - super(HydrawiseAccountHandler.class, Set.of(HydrawiseBindingConstants.THING_TYPE_CONTROLLER), TIMEOUT, true); + super(Set.of(HydrawiseBindingConstants.THING_TYPE_CONTROLLER), TIMEOUT, true); } @Override protected void startScan() { - Customer data = thingHandler.lastData(); - if (data != null) { - data.controllers.forEach(controller -> addDiscoveryResults(controller)); + HydrawiseAccountHandler localHandler = this.handler; + if (localHandler != null) { + Customer data = localHandler.lastData(); + if (data != null) { + data.controllers.forEach(controller -> addDiscoveryResults(controller)); + } } } @Override - public void dispose() { - super.dispose(); - removeOlderResults(Instant.now().toEpochMilli(), thingHandler.getThing().getUID()); + public void deactivate() { + HydrawiseAccountHandler localHandler = this.handler; + if (localHandler != null) { + removeOlderResults(new Date().getTime(), localHandler.getThing().getUID()); + } } @Override protected synchronized void stopScan() { super.stopScan(); - removeOlderResults(getTimestampOfLastScan(), thingHandler.getThing().getUID()); + HydrawiseAccountHandler localHandler = this.handler; + if (localHandler != null) { + removeOlderResults(getTimestampOfLastScan(), localHandler.getThing().getUID()); + } } @Override @@ -71,19 +83,27 @@ public class HydrawiseCloudControllerDiscoveryService } @Override - public void initialize() { - thingHandler.addControllerListeners(this); - super.initialize(); + public void setThingHandler(ThingHandler handler) { + this.handler = (HydrawiseAccountHandler) handler; + this.handler.addControllerListeners(this); + } + + @Override + public @Nullable ThingHandler getThingHandler() { + return handler; } private void addDiscoveryResults(Controller controller) { - String label = String.format("Hydrawise Controller %s", controller.name); - int id = controller.id; - ThingUID bridgeUID = thingHandler.getThing().getUID(); - ThingUID thingUID = new ThingUID(HydrawiseBindingConstants.THING_TYPE_CONTROLLER, bridgeUID, - String.valueOf(id)); - thingDiscovered(DiscoveryResultBuilder.create(thingUID).withLabel(label).withBridge(bridgeUID) - .withProperty(HydrawiseBindingConstants.CONFIG_CONTROLLER_ID, id) - .withRepresentationProperty(HydrawiseBindingConstants.CONFIG_CONTROLLER_ID).build()); + HydrawiseAccountHandler localHandler = this.handler; + if (localHandler != null) { + String label = String.format("Hydrawise Controller %s", controller.name); + int id = controller.id; + ThingUID bridgeUID = localHandler.getThing().getUID(); + ThingUID thingUID = new ThingUID(HydrawiseBindingConstants.THING_TYPE_CONTROLLER, bridgeUID, + String.valueOf(id)); + thingDiscovered(DiscoveryResultBuilder.create(thingUID).withLabel(label).withBridge(bridgeUID) + .withProperty(HydrawiseBindingConstants.CONFIG_CONTROLLER_ID, id) + .withRepresentationProperty(HydrawiseBindingConstants.CONFIG_CONTROLLER_ID).build()); + } } } diff --git a/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/handler/HydrawiseAccountHandler.java b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/handler/HydrawiseAccountHandler.java index 8be5e5c2e1b..f12ab20bc90 100644 --- a/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/handler/HydrawiseAccountHandler.java +++ b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/handler/HydrawiseAccountHandler.java @@ -63,6 +63,7 @@ public class HydrawiseAccountHandler extends BaseBridgeHandler implements Access */ private static final int MIN_REFRESH_SECONDS = 30; private static final int TOKEN_REFRESH_SECONDS = 60; + private static final int WEATHER_REFRESH_MILLIS = 60 * 60 * 1000; // 1 hour private static final String BASE_URL = "https://app.hydrawise.com/api/v2/"; private static final String AUTH_URL = BASE_URL + "oauth/access-token"; private static final String CLIENT_SECRET = "zn3CrjglwNV1"; @@ -77,6 +78,7 @@ public class HydrawiseAccountHandler extends BaseBridgeHandler implements Access private @Nullable ScheduledFuture pollFuture; private @Nullable ScheduledFuture tokenFuture; private @Nullable Customer lastData; + private long lastWeatherUpdate; private int refresh; public HydrawiseAccountHandler(final Bridge bridge, final HttpClient httpClient, final OAuthFactory oAuthFactory) { @@ -228,6 +230,11 @@ public class HydrawiseAccountHandler extends BaseBridgeHandler implements Access } private void poll(boolean retry) { + HydrawiseGraphQLClient apiClient = this.apiClient; + if (apiClient == null) { + logger.debug("apiclient not initalized"); + return; + } try { QueryResponse response = apiClient.queryControllers(); if (response == null) { @@ -240,6 +247,21 @@ public class HydrawiseAccountHandler extends BaseBridgeHandler implements Access if (getThing().getStatus() != ThingStatus.ONLINE) { updateStatus(ThingStatus.ONLINE); } + long currentTime = System.currentTimeMillis(); + if (currentTime > lastWeatherUpdate + WEATHER_REFRESH_MILLIS) { + lastWeatherUpdate = currentTime; + try { + QueryResponse weatherResponse = apiClient.queryWeather(); + if (weatherResponse != null) { + response.data.me.controllers.forEach(controller -> { + weatherResponse.data.me.controllers.stream().filter(c -> c.id.equals(controller.id)) + .findFirst().ifPresent(c -> controller.location.forecast = c.location.forecast); + }); + } + } catch (HydrawiseConnectionException e) { + logger.debug("Weather data is not supported", e); + } + } lastData = response.data.me; synchronized (controllerListeners) { controllerListeners.forEach(listener -> { diff --git a/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/handler/HydrawiseControllerHandler.java b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/handler/HydrawiseControllerHandler.java index 60c90f82ef1..218a9ed92ae 100644 --- a/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/handler/HydrawiseControllerHandler.java +++ b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/handler/HydrawiseControllerHandler.java @@ -27,6 +27,8 @@ import java.util.Locale; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; +import javax.measure.quantity.Speed; +import javax.measure.quantity.Temperature; import javax.measure.quantity.Volume; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -250,7 +252,7 @@ public class HydrawiseControllerHandler extends BaseThingHandler implements Hydr updateForecast(controller.location.forecast); } if (controller.zones != null) { - updateZones(controller.zones); + updateZones(controller.zones, controller.hardware.model.maxZones); } // update values with what the cloud tells us even though the controller may be offline @@ -278,20 +280,22 @@ public class HydrawiseControllerHandler extends BaseThingHandler implements Hydr : UnDefType.NULL); } - private void updateZones(List zones) { + private void updateZones(List zones, int maxZones) { AtomicReference anyRunning = new AtomicReference<>(false); AtomicReference anySuspended = new AtomicReference<>(false); for (Zone zone : zones) { - // there are 12 relays per expander, expanders will have a zoneNumber like: + // for expansion modules who zones numbers are > 99 + // there are maxZones relays per expander, expanders will have a zoneNumber like: + // maxZones = 12 // 10 for expander 0, relay 10 = zone10 // 101 for expander 1, relay 1 = zone13 // 212 for expander 2, relay 12 = zone36 // division of integers in Java give whole numbers, not remainders FYI - int zoneNumber = ((zone.number.value / 100) * 12) + (zone.number.value % 100); - + int zoneNumber = zone.number.value <= 99 ? zone.number.value + : ((zone.number.value / 100) * maxZones) + (zone.number.value % 100); String group = "zone" + zoneNumber; zoneMaps.put(group, zone); - logger.trace("Updateing Zone {} {} ", group, zone.name); + logger.trace("Updating Zone {} {} ", group, zone.name); updateGroupState(group, CHANNEL_ZONE_NAME, new StringType(zone.name)); updateGroupState(group, CHANNEL_ZONE_ICON, new StringType(BASE_IMAGE_URL + zone.icon.fileName)); if (zone.scheduledRuns != null) { @@ -328,8 +332,9 @@ public class HydrawiseControllerHandler extends BaseThingHandler implements Hydr updateGroupState(group, CHANNEL_ZONE_SUSPENDUNTIL, UnDefType.UNDEF); } } - updateGroupState(CHANNEL_GROUP_ALLZONES, CHANNEL_ZONE_RUN, OnOffType.from(anyRunning.get())); - updateGroupState(CHANNEL_GROUP_ALLZONES, CHANNEL_ZONE_SUSPEND, OnOffType.from(anySuspended.get())); + updateGroupState(CHANNEL_GROUP_ALLZONES, CHANNEL_ZONE_RUN, anyRunning.get() ? OnOffType.ON : OnOffType.OFF); + updateGroupState(CHANNEL_GROUP_ALLZONES, CHANNEL_ZONE_SUSPEND, + anySuspended.get() ? OnOffType.ON : OnOffType.OFF); updateGroupState(CHANNEL_GROUP_ALLZONES, CHANNEL_ZONE_SUSPENDUNTIL, UnDefType.UNDEF); } @@ -362,6 +367,7 @@ public class HydrawiseControllerHandler extends BaseThingHandler implements Hydr int i = 1; for (Forecast forecast : forecasts) { String group = "forecast" + (i++); + logger.trace("Updating {} {}", group, forecast.time); updateGroupState(group, CHANNEL_FORECAST_TIME, stringToDateTime(forecast.time)); updateGroupState(group, CHANNEL_FORECAST_CONDITIONS, new StringType(forecast.conditions)); updateGroupState(group, CHANNEL_FORECAST_HUMIDITY, new DecimalType(forecast.averageHumidity.intValue())); @@ -383,12 +389,12 @@ public class HydrawiseControllerHandler extends BaseThingHandler implements Hydr private void updateTemperature(UnitValue temperature, String group, String channel) { logger.debug("TEMP {} {} {} {}", group, channel, temperature.unit, temperature.value); - updateGroupState(group, channel, new QuantityType<>(temperature.value, - "\\u00b0F".equals(temperature.unit) ? ImperialUnits.FAHRENHEIT : SIUnits.CELSIUS)); + updateGroupState(group, channel, new QuantityType(temperature.value, + temperature.unit.indexOf("F") >= 0 ? ImperialUnits.FAHRENHEIT : SIUnits.CELSIUS)); } private void updateWindspeed(UnitValue wind, String group, String channel) { - updateGroupState(group, channel, new QuantityType<>(wind.value, + updateGroupState(group, channel, new QuantityType(wind.value, "mph".equals(wind.unit) ? ImperialUnits.MILES_PER_HOUR : SIUnits.KILOMETRE_PER_HOUR)); } @@ -439,10 +445,7 @@ public class HydrawiseControllerHandler extends BaseThingHandler implements Hydr } private QuantityType waterFlowToQuantityType(Number flow, String units) { - double waterFlow = flow.doubleValue(); - if ("gals".equals(units)) { - waterFlow = waterFlow * 3.785; - } - return new QuantityType<>(waterFlow, Units.LITRE); + return new QuantityType<>(flow.doubleValue(), + "gal".equals(units) ? ImperialUnits.GALLON_LIQUID_US : Units.LITRE); } } diff --git a/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/handler/HydrawiseLocalHandler.java b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/handler/HydrawiseLocalHandler.java index 667f7c0a801..e57d527c743 100644 --- a/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/handler/HydrawiseLocalHandler.java +++ b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/handler/HydrawiseLocalHandler.java @@ -214,7 +214,8 @@ public class HydrawiseLocalHandler extends BaseThingHandler { updateGroupState(group, CHANNEL_ZONE_TIME_LEFT, new QuantityType<>(0, Units.SECOND)); } - updateGroupState(CHANNEL_GROUP_ALLZONES, CHANNEL_ZONE_RUN, OnOffType.from(!status.running.isEmpty())); + updateGroupState(CHANNEL_GROUP_ALLZONES, CHANNEL_ZONE_RUN, + !status.running.isEmpty() ? OnOffType.ON : OnOffType.OFF); }); } diff --git a/bundles/org.openhab.binding.hydrawise/src/main/resources/OH-INF/thing/things.xml b/bundles/org.openhab.binding.hydrawise/src/main/resources/OH-INF/thing/things.xml index 8f0434e97e3..1998c62bd57 100644 --- a/bundles/org.openhab.binding.hydrawise/src/main/resources/OH-INF/thing/things.xml +++ b/bundles/org.openhab.binding.hydrawise/src/main/resources/OH-INF/thing/things.xml @@ -38,7 +38,8 @@ Hydrawise connected irrigation controller - @@ -230,6 +231,78 @@ Sprinkler Zone 36 + + + Sprinkler Zone 37 + + + + Sprinkler Zone 38 + + + + Sprinkler Zone 39 + + + + Sprinkler Zone 40 + + + + Sprinkler Zone 41 + + + + Sprinkler Zone 42 + + + + Sprinkler Zone 43 + + + + Sprinkler Zone 44 + + + + Sprinkler Zone 45 + + + + Sprinkler Zone 46 + + + + Sprinkler Zone 47 + + + + Sprinkler Zone 48 + + + + Sprinkler Zone 49 + + + + Sprinkler Zone 50 + + + + Sprinkler Zone 51 + + + + Sprinkler Zone 52 + + + + Sprinkler Zone 53 + + + + Sprinkler Zone 54 + diff --git a/bundles/org.openhab.binding.hydrawise/src/main/resources/query.graphql b/bundles/org.openhab.binding.hydrawise/src/main/resources/query.graphql index 6699a943c69..b20d9ab8b69 100644 --- a/bundles/org.openhab.binding.hydrawise/src/main/resources/query.graphql +++ b/bundles/org.openhab.binding.hydrawise/src/main/resources/query.graphql @@ -5,41 +5,26 @@ controllers { id name - status { + status { summary online lastContact { timestamp } - } + } + hardware { + version + model { + maxZones + name + description + } + } location { coordinates { latitude longitude } - forecast(days: 3) { - time - updateTime - conditions - averageWindSpeed { - value - unit - } - highTemperature { - value - unit - } - lowTemperature { - value - unit - } - probabilityOfPrecipitation - precipitation { - value - unit - } - averageHumidity - } } zones { id diff --git a/bundles/org.openhab.binding.hydrawise/src/main/resources/weather.graphql b/bundles/org.openhab.binding.hydrawise/src/main/resources/weather.graphql new file mode 100644 index 00000000000..1b933f8118a --- /dev/null +++ b/bundles/org.openhab.binding.hydrawise/src/main/resources/weather.graphql @@ -0,0 +1,34 @@ +{ + me { + email + lastContact + controllers { + id + location { + forecast(days: 3) { + time + updateTime + conditions + averageWindSpeed { + value + unit + } + highTemperature { + value + unit + } + lowTemperature { + value + unit + } + probabilityOfPrecipitation + precipitation { + value + unit + } + averageHumidity + } + } + } + } +}