From 13ce5bb748be6f7033c40904233373b87996ddfc Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Thu, 4 Jul 2019 21:06:21 +0200 Subject: [PATCH] Tasmota: Use new powerswitch interface --- tasmota/deviceplugintasmota.cpp | 8 ++++++++ tasmota/deviceplugintasmota.json | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tasmota/deviceplugintasmota.cpp b/tasmota/deviceplugintasmota.cpp index bff8a25a..f2b1444f 100644 --- a/tasmota/deviceplugintasmota.cpp +++ b/tasmota/deviceplugintasmota.cpp @@ -213,6 +213,10 @@ Device::DeviceError DevicePluginTasmota::executeAction(Device *device, const Act if (m_powerStateTypeMap.contains(device->deviceClassId())) { Device *parentDev = myDevices().findById(device->parentId()); MqttChannel *channel = m_mqttChannels.value(parentDev); + if (!channel) { + qCWarning(dcTasmota()) << "No mqtt channel for this device."; + return Device::DeviceErrorHardwareNotAvailable; + } ParamTypeId channelParamTypeId = m_channelParamTypeMap.value(device->deviceClassId()); ParamTypeId powerActionParamTypeId = ParamTypeId(m_powerStateTypeMap.value(device->deviceClassId()).toString()); qCDebug(dcTasmota) << "Publishing:" << channel->topicPrefix() + "/sonoff/cmnd/" + device->paramValue(channelParamTypeId).toString() << (action.param(powerActionParamTypeId).value().toBool() ? "ON" : "OFF"); @@ -223,6 +227,10 @@ Device::DeviceError DevicePluginTasmota::executeAction(Device *device, const Act if (device->deviceClassId() == tasmotaShutterDeviceClassId) { Device *parentDev = myDevices().findById(device->parentId()); MqttChannel *channel = m_mqttChannels.value(parentDev); + if (!channel) { + qCWarning(dcTasmota()) << "No mqtt channel for this device."; + return Device::DeviceErrorHardwareNotAvailable; + } ParamTypeId openingChannelParamTypeId = m_openingChannelParamTypeMap.value(device->deviceClassId()); ParamTypeId closingChannelParamTypeId = m_closingChannelParamTypeMap.value(device->deviceClassId()); if (action.actionTypeId() == tasmotaShutterOpenActionTypeId) { diff --git a/tasmota/deviceplugintasmota.json b/tasmota/deviceplugintasmota.json index 2ce49ca4..776132f7 100644 --- a/tasmota/deviceplugintasmota.json +++ b/tasmota/deviceplugintasmota.json @@ -5,7 +5,7 @@ "vendors": [ { "name": "tasmota", - "displayName": "Sonoff-Tasmota", + "displayName": "Tasmota", "id": "789e6173-3de3-44ef-8664-9492c9d15d44", "deviceClasses": [ { @@ -147,7 +147,7 @@ "name": "tasmotaSwitch", "displayName": "Tasmota power switch", "createMethods": ["auto"], - "interfaces": ["power", "connectable"], + "interfaces": ["powerswitch", "connectable"], "paramTypes": [ { "id": "564cf6c6-86eb-41a5-9b87-fb32f1b6fcd6",