Tasmota: Use new powerswitch interface
This commit is contained in:
parent
3206f285ba
commit
13ce5bb748
@ -213,6 +213,10 @@ Device::DeviceError DevicePluginTasmota::executeAction(Device *device, const Act
|
|||||||
if (m_powerStateTypeMap.contains(device->deviceClassId())) {
|
if (m_powerStateTypeMap.contains(device->deviceClassId())) {
|
||||||
Device *parentDev = myDevices().findById(device->parentId());
|
Device *parentDev = myDevices().findById(device->parentId());
|
||||||
MqttChannel *channel = m_mqttChannels.value(parentDev);
|
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 channelParamTypeId = m_channelParamTypeMap.value(device->deviceClassId());
|
||||||
ParamTypeId powerActionParamTypeId = ParamTypeId(m_powerStateTypeMap.value(device->deviceClassId()).toString());
|
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");
|
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) {
|
if (device->deviceClassId() == tasmotaShutterDeviceClassId) {
|
||||||
Device *parentDev = myDevices().findById(device->parentId());
|
Device *parentDev = myDevices().findById(device->parentId());
|
||||||
MqttChannel *channel = m_mqttChannels.value(parentDev);
|
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 openingChannelParamTypeId = m_openingChannelParamTypeMap.value(device->deviceClassId());
|
||||||
ParamTypeId closingChannelParamTypeId = m_closingChannelParamTypeMap.value(device->deviceClassId());
|
ParamTypeId closingChannelParamTypeId = m_closingChannelParamTypeMap.value(device->deviceClassId());
|
||||||
if (action.actionTypeId() == tasmotaShutterOpenActionTypeId) {
|
if (action.actionTypeId() == tasmotaShutterOpenActionTypeId) {
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
"vendors": [
|
"vendors": [
|
||||||
{
|
{
|
||||||
"name": "tasmota",
|
"name": "tasmota",
|
||||||
"displayName": "Sonoff-Tasmota",
|
"displayName": "Tasmota",
|
||||||
"id": "789e6173-3de3-44ef-8664-9492c9d15d44",
|
"id": "789e6173-3de3-44ef-8664-9492c9d15d44",
|
||||||
"deviceClasses": [
|
"deviceClasses": [
|
||||||
{
|
{
|
||||||
@ -147,7 +147,7 @@
|
|||||||
"name": "tasmotaSwitch",
|
"name": "tasmotaSwitch",
|
||||||
"displayName": "Tasmota power switch",
|
"displayName": "Tasmota power switch",
|
||||||
"createMethods": ["auto"],
|
"createMethods": ["auto"],
|
||||||
"interfaces": ["power", "connectable"],
|
"interfaces": ["powerswitch", "connectable"],
|
||||||
"paramTypes": [
|
"paramTypes": [
|
||||||
{
|
{
|
||||||
"id": "564cf6c6-86eb-41a5-9b87-fb32f1b6fcd6",
|
"id": "564cf6c6-86eb-41a5-9b87-fb32f1b6fcd6",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user