2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.opensprinkler.internal.api;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jetty.client.HttpClient;
17 import org.openhab.binding.opensprinkler.internal.api.exception.CommunicationApiException;
18 import org.openhab.binding.opensprinkler.internal.api.exception.GeneralApiException;
19 import org.openhab.binding.opensprinkler.internal.api.exception.UnauthorizedApiException;
20 import org.openhab.binding.opensprinkler.internal.config.OpenSprinklerHttpInterfaceConfig;
23 * The {@link OpenSprinklerHttpApiV219} class is used for communicating with
24 * the firmware versions 2.1.9 and up.
26 * @author Matthew Skinner - Initial contribution
29 public class OpenSprinklerHttpApiV219 extends OpenSprinklerHttpApiV217 {
31 OpenSprinklerHttpApiV219(final HttpClient httpClient, final OpenSprinklerHttpInterfaceConfig config)
32 throws GeneralApiException, CommunicationApiException {
33 super(httpClient, config);
37 public void ignoreRain(int station, boolean command) throws CommunicationApiException, UnauthorizedApiException {
38 int arrayIndex = station / 8;
39 int bit = station % 8;
40 logger.debug("Ignore Rain for Station:{} is being looked in index: {} and bit:{}", station, arrayIndex, bit);
41 byte status = state.jnReply.ignoreRain[arrayIndex];
45 status &= ~(1 << bit);
47 http.sendHttpGet(getBaseUrl() + "cs", getRequestRequiredOptions() + "&i" + arrayIndex + "=" + status);
51 public boolean isIgnoringRain(int station) {
52 int arrayIndex = station / 8;
53 int bit = station % 8;
54 byte status = state.jnReply.ignoreRain[arrayIndex];
55 return (status & (1 << bit)) != 0;