mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[mqtt.homeassistant] Re-fix null component name (#18021)
Re-fixes #15427, regressed from #17933 Signed-off-by: Cody Cutrer <cody@cutrer.us>
This commit is contained in:
parent
d6476042ec
commit
22c7ca99ad
@ -289,7 +289,7 @@ public abstract class AbstractComponent<C extends AbstractChannelConfiguration>
|
|||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
String result = channelConfiguration.getName();
|
String result = channelConfiguration.getName();
|
||||||
if (result.isBlank()) {
|
if (result != null && result.isBlank()) {
|
||||||
result = null;
|
result = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +166,54 @@ public class SwitchTests extends AbstractComponentTests {
|
|||||||
assertPublished("zigbee2mqtt/th1/set/auto_lock", "AUTO");
|
assertPublished("zigbee2mqtt/th1/set/auto_lock", "AUTO");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSwitchNoName() {
|
||||||
|
var component = discoverComponent(configTopicToMqtt(CONFIG_TOPIC), """
|
||||||
|
{
|
||||||
|
"availability": [
|
||||||
|
{
|
||||||
|
"topic": "zigbee2mqtt/bridge/state",
|
||||||
|
"value_template": "{{ value_json.state }}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"topic": "zigbee2mqtt/Master Bedroom Subwoofer/availability",
|
||||||
|
"value_template": "{{ value_json.state }}"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"availability_mode": "all",
|
||||||
|
"command_topic": "zigbee2mqtt/Master Bedroom Subwoofer/set",
|
||||||
|
"device": {
|
||||||
|
"configuration_url": "http://z2m:8084/#/device/0x00124b0029e7388c/info",
|
||||||
|
"identifiers": [
|
||||||
|
"zigbee2mqtt_0x00124b0029e7388c"
|
||||||
|
],
|
||||||
|
"manufacturer": "SONOFF",
|
||||||
|
"model": "15A Zigbee smart plug (S40ZBTPB)",
|
||||||
|
"name": "Master Bedroom Subwoofer",
|
||||||
|
"sw_version": "1.1.0",
|
||||||
|
"via_device": "zigbee2mqtt_bridge_0xe0798dfffe882ce4"
|
||||||
|
},
|
||||||
|
"name": null,
|
||||||
|
"object_id": "master_bedroom_subwoofer",
|
||||||
|
"origin": {
|
||||||
|
"name": "Zigbee2MQTT",
|
||||||
|
"sw": "1.42.0-dev",
|
||||||
|
"url": "https://www.zigbee2mqtt.io"
|
||||||
|
},
|
||||||
|
"payload_off": "OFF",
|
||||||
|
"payload_on": "ON",
|
||||||
|
"state_topic": "zigbee2mqtt/Master Bedroom Subwoofer",
|
||||||
|
"unique_id": "0x00124b0029e7388c_switch_zigbee2mqtt",
|
||||||
|
"value_template": "{{ value_json.state }}"
|
||||||
|
}
|
||||||
|
""");
|
||||||
|
|
||||||
|
assertThat(component.channels.size(), is(1));
|
||||||
|
assertThat(component.getName(), is("Master Bedroom Subwoofer"));
|
||||||
|
assertChannel(component, Switch.SWITCH_CHANNEL_ID, "zigbee2mqtt/Master Bedroom Subwoofer",
|
||||||
|
"zigbee2mqtt/Master Bedroom Subwoofer/set", "Master Bedroom Subwoofer", OnOffValue.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Set<String> getConfigTopics() {
|
protected Set<String> getConfigTopics() {
|
||||||
return Set.of(CONFIG_TOPIC);
|
return Set.of(CONFIG_TOPIC);
|
||||||
|
Loading…
Reference in New Issue
Block a user