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.mqtt.homeassistant.internal.component;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.mqtt.generic.values.TextValue;
18 import org.openhab.binding.mqtt.homeassistant.internal.config.dto.AbstractChannelConfiguration;
20 import com.google.gson.annotations.SerializedName;
23 * A MQTT scene, following the https://www.home-assistant.io/integrations/scene.mqtt/ specification.
25 * @author Cody Cutrer - Initial contribution
28 public class Scene extends AbstractComponent<Scene.ChannelConfiguration> {
29 public static final String SCENE_CHANNEL_ID = "scene";
32 * Configuration class for MQTT component
34 static class ChannelConfiguration extends AbstractChannelConfiguration {
35 ChannelConfiguration() {
39 @SerializedName("command_topic")
40 protected @Nullable String commandTopic;
42 @SerializedName("payload_on")
43 protected String payloadOn = "ON";
46 public Scene(ComponentFactory.ComponentConfiguration componentConfiguration) {
47 super(componentConfiguration, ChannelConfiguration.class);
49 TextValue value = new TextValue(new String[] { channelConfiguration.payloadOn });
51 buildChannel(SCENE_CHANNEL_ID, value, getName(), componentConfiguration.getUpdateListener())
52 .commandTopic(channelConfiguration.commandTopic, channelConfiguration.isRetain(),
53 channelConfiguration.getQos())