Merge PR #128: Tasmota: Use new powerswitch interface
This commit is contained in:
commit
df91880f5b
@ -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) {
|
||||
@ -291,6 +299,10 @@ void DevicePluginTasmota::onPublishReceived(MqttChannel *channel, const QString
|
||||
if (m_powerStateTypeMap.contains(child->deviceClassId())) {
|
||||
child->setStateValue(m_powerStateTypeMap.value(child->deviceClassId()), payload == "ON");
|
||||
}
|
||||
if (child->deviceClassId() == tasmotaSwitchDeviceClassId) {
|
||||
Event event(tasmotaSwitchPressedEventTypeId, child->id());
|
||||
emit emitEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (topic.startsWith(channel->topicPrefix() + "/sonoff/STATE")) {
|
||||
|
||||
@ -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",
|
||||
@ -176,6 +176,13 @@
|
||||
"defaultValue": false,
|
||||
"writable": true
|
||||
}
|
||||
],
|
||||
"eventTypes": [
|
||||
{
|
||||
"id": "1be4d6a1-475e-43bb-a47c-9063e279e78d",
|
||||
"name": "pressed",
|
||||
"displayName": "Pressed"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user