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.ambientweather.internal.processor;
15 import static org.openhab.binding.ambientweather.internal.AmbientWeatherBindingConstants.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.ambientweather.internal.handler.AmbientWeatherStationHandler;
19 import org.openhab.binding.ambientweather.internal.model.EventDataJson;
20 import org.openhab.core.library.unit.ImperialUnits;
21 import org.openhab.core.library.unit.Units;
24 * The {@link Ws8482Processor} is responsible for updating
25 * the channels associated with the WS-1400-IP series weather stations in
26 * response to the receipt of a weather data update from the Ambient
27 * Weather real-time API.
29 * @author Mark Hilbush - Initial contribution
32 public class Ws8482Processor extends AbstractProcessor {
35 public void setChannelGroupId() {
36 channelGroupId = CHGRP_WS8482;
40 public void setNumberOfSensors() {
41 remoteSensor.setNumberOfSensors(7);
45 public void processInfoUpdate(AmbientWeatherStationHandler handler, String station, String name, String location) {
46 // Update name and location channels
47 handler.updateString(CHGRP_STATION, CH_NAME, name);
48 handler.updateString(CHGRP_STATION, CH_LOCATION, location);
52 public void processWeatherData(AmbientWeatherStationHandler handler, String station, String jsonData) {
53 EventDataJson data = parseEventData(station, jsonData);
58 // Update the weather data channels
59 handler.updateDate(channelGroupId, CH_OBSERVATION_TIME, data.date);
60 handler.updateString(channelGroupId, CH_BATTERY_INDICATOR, data.battout);
61 handler.updateQuantity(channelGroupId, CH_TEMPERATURE, data.tempinf, ImperialUnits.FAHRENHEIT);
62 handler.updateQuantity(channelGroupId, CH_HUMIDITY, data.humidityin, Units.PERCENT);
64 // Update the remote sensor channels
65 remoteSensor.updateChannels(handler, jsonData);