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.onewire.internal.device;
15 import static org.openhab.binding.onewire.internal.OwBindingConstants.CHANNEL_COUNTER;
17 import java.util.List;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.openhab.binding.onewire.internal.OwException;
21 import org.openhab.binding.onewire.internal.SensorId;
22 import org.openhab.binding.onewire.internal.handler.OwBaseThingHandler;
23 import org.openhab.binding.onewire.internal.handler.OwserverBridgeHandler;
24 import org.openhab.binding.onewire.internal.owserver.OwserverDeviceParameter;
25 import org.openhab.core.types.State;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
30 * The {@link DS2423} class defines a DS2423 device
32 * @author Jan N. Klug - Initial contribution
35 public class DS2423 extends AbstractOwDevice {
36 private final Logger logger = LoggerFactory.getLogger(DS2423.class);
37 private final OwserverDeviceParameter counterParameter = new OwserverDeviceParameter("/counters.ALL");
39 public DS2423(SensorId sensorId, OwBaseThingHandler callback) {
40 super(sensorId, callback);
44 public void configureChannels() throws OwException {
49 public void refresh(OwserverBridgeHandler bridgeHandler, Boolean forcedRefresh) throws OwException {
51 logger.trace("refresh of sensor {} started", sensorId);
52 List<State> states = bridgeHandler.readDecimalTypeArray(sensorId, counterParameter);
54 if (states.size() != 2) {
55 throw new OwException("Expected exactly two values, got " + String.valueOf(states.size()));
57 callback.postUpdate(CHANNEL_COUNTER + "0", states.get(0));
58 callback.postUpdate(CHANNEL_COUNTER + "1", states.get(1));