2 * Copyright (c) 2010-2021 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.wled.internal.api;
15 import static org.openhab.binding.wled.internal.WLedBindingConstants.*;
17 import java.util.ArrayList;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jetty.client.HttpClient;
21 import org.openhab.binding.wled.internal.WLedHandler;
22 import org.openhab.core.library.types.StringType;
23 import org.openhab.core.thing.Channel;
26 * The {@link WledApiV0130} is the json Api methods for firmware version 0.13.0 and newer
27 * as newer firmwares come out with breaking changes, extend this class into a newer firmware version class.
29 * @author Matthew Skinner - Initial contribution
32 public class WledApiV0130 extends WledApiV0110 {
34 public WledApiV0130(WLedHandler handler, HttpClient httpClient) {
35 super(handler, httpClient);
39 public void initialize() throws ApiException {
41 ArrayList<Channel> removeChannels = new ArrayList<>();
42 // This version of firmware removed these channels
43 Channel channel = handler.getThing().getChannel(CHANNEL_PRESET_DURATION);
44 if (channel != null) {
45 removeChannels.add(channel);
47 channel = handler.getThing().getChannel(CHANNEL_PRESET_CYCLE);
48 if (channel != null) {
49 removeChannels.add(channel);
51 handler.removeChannels(removeChannels);
55 protected void processState() throws ApiException {
57 handler.update(CHANNEL_PLAYLISTS, new StringType(Integer.toString(state.stateResponse.pl)));