Tasmota: Use new powerswitch interface

master
Michael Zanetti 2019-07-04 21:06:21 +02:00
parent 3206f285ba
commit 13ce5bb748
2 changed files with 10 additions and 2 deletions

View File

@ -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) {

View File

@ -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",