2 * Copyright (c) 2010-2024 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 static org.hamcrest.CoreMatchers.is;
16 import static org.hamcrest.MatcherAssert.assertThat;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.junit.jupiter.api.Test;
22 import org.openhab.binding.mqtt.generic.values.TextValue;
25 * Tests for {@link DeviceTrigger}
27 * @author Cody Cutrer - Initial contribution
30 public class DeviceTriggerTests extends AbstractComponentTests {
31 public static final String CONFIG_TOPIC = "device_automation/0x8cf681fffe2fd2a6";
33 @SuppressWarnings("null")
35 public void test() throws InterruptedException {
36 var component = discoverComponent(configTopicToMqtt(CONFIG_TOPIC), """
38 "automation_type": "trigger",
40 "configuration_url": "#/device/0x8cf681fffe2fd2a6/info",
42 "zigbee2mqtt_0x8cf681fffe2fd2a6"
44 "manufacturer": "IKEA",
45 "model": "TRADFRI shortcut button (E1812)",
46 "name": "Charge Now Button",
47 "sw_version": "2.3.015"
51 "topic": "zigbee2mqtt/Charge Now Button/action",
56 assertThat(component.channels.size(), is(1));
57 assertThat(component.getName(), is("MQTT Device Trigger"));
59 assertChannel(component, "action", "zigbee2mqtt/Charge Now Button/action", "", "MQTT Device Trigger",
62 spyOnChannelUpdates(component, "action");
63 publishMessage("zigbee2mqtt/Charge Now Button/action", "on");
64 assertTriggered(component, "action", "on");
68 protected Set<String> getConfigTopics() {
69 return Set.of(CONFIG_TOPIC);