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;
23 * The {@link Ws0265Processor} is responsible for updating
24 * the channels associated with the WS-0265 series weather stations in
25 * response to the receipt of a weather data update from the Ambient
26 * Weather real-time API.
28 * @author Mark Hilbush - Initial contribution
31 public class Ws0265Processor extends AbstractProcessor {
34 public void setChannelGroupId() {
35 channelGroupId = CHGRP_WS0265;
39 public void setNumberOfSensors() {
40 remoteSensor.setNumberOfSensors(7);
44 public void processInfoUpdate(AmbientWeatherStationHandler handler, String station, String name, String location) {
45 // Update name and location channels
46 handler.updateString(CHGRP_STATION, CH_NAME, name);
47 handler.updateString(CHGRP_STATION, CH_LOCATION, location);
51 public void processWeatherData(AmbientWeatherStationHandler handler, String station, String jsonData) {
52 EventDataJson data = parseEventData(station, jsonData);
57 // Update the weather data channels
58 handler.updateDate(channelGroupId, CH_OBSERVATION_TIME, data.date);
59 handler.updateQuantity(channelGroupId, CH_TEMPERATURE, data.tempinf, ImperialUnits.FAHRENHEIT);
61 // Update the remote sensor channels
62 remoteSensor.updateChannels(handler, jsonData);