Merge landing-silo into main: drop waveshare-relay-d8
Promotes the single change sitting in landing-silo. Nothing else comes with it: the Fronius work is still in experimental-silo. The plugin had been in the tree since the initial commit but was built by nothing, absent from both PLUGIN_DIRS and debian/control, so no package has ever shipped it and no build target changes here. It stays in experimental-silo. Promoted on an explicit exception rather than on the named hardware validation the promotion criteria ask for: there is no hardware to validate, only source that nothing compiles. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
commit
997ea13b02
@ -1,223 +0,0 @@
|
||||
{
|
||||
"name": "WaveshareRelayD8",
|
||||
"displayName": "Waveshare Relay D8",
|
||||
"id": "028e7851-a6cc-4480-b174-b94ca638cf56",
|
||||
"vendors": [
|
||||
{
|
||||
"name": "waveshare",
|
||||
"displayName": "Waveshare",
|
||||
"id": "1b021659-70ae-4dbf-b837-f96db1ede396",
|
||||
"thingClasses": [
|
||||
{
|
||||
"name": "waveshareRelayD8",
|
||||
"displayName": "Waveshare Relay D8",
|
||||
"id": "8e8e5643-7dcf-4438-af9b-3d003e0fa0f5",
|
||||
"createMethods": ["discovery"],
|
||||
"interfaces": ["connectable"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "b4a727f1-ca3d-4674-864f-f625debf57e4",
|
||||
"name": "rtuMaster",
|
||||
"displayName": "Modbus RTU master UUID",
|
||||
"type": "QString",
|
||||
"defaultValue": ""
|
||||
},
|
||||
{
|
||||
"id": "ab68c9cd-4785-4b12-8752-b50e9fc60520",
|
||||
"name": "slaveAddress",
|
||||
"displayName": "Modbus slave address",
|
||||
"type": "int",
|
||||
"defaultValue": 1,
|
||||
"minValue": 1,
|
||||
"maxValue": 247
|
||||
}
|
||||
],
|
||||
"stateTypes": [
|
||||
{
|
||||
"id": "a43070ac-9784-4923-bc7f-16c206b822e1",
|
||||
"name": "connected",
|
||||
"displayName": "Connected",
|
||||
"type": "bool",
|
||||
"defaultValue": false,
|
||||
"cached": false
|
||||
},
|
||||
{
|
||||
"id": "29fcfe96-989d-494d-9717-ce08f992e281",
|
||||
"name": "relay1State",
|
||||
"displayName": "Relay 1",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "ba8e4946-6402-459b-bb92-e72b74294627",
|
||||
"name": "relay2State",
|
||||
"displayName": "Relay 2",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "00904d40-eb47-4165-8776-ee6452bd2cb5",
|
||||
"name": "relay3State",
|
||||
"displayName": "Relay 3",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "111db305-23f5-49e2-8999-ae29cacb13cf",
|
||||
"name": "relay4State",
|
||||
"displayName": "Relay 4",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "83a781a8-c4be-406f-9da3-8c64185a945d",
|
||||
"name": "relay5State",
|
||||
"displayName": "Relay 5",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "526a35bf-9529-40f9-bd50-9865ba7e9776",
|
||||
"name": "relay6State",
|
||||
"displayName": "Relay 6",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "0624aea8-805c-4504-8781-2e64f5d88cfa",
|
||||
"name": "relay7State",
|
||||
"displayName": "Relay 7",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "01c3d958-0de1-4c43-a30c-799fc74244ac",
|
||||
"name": "relay8State",
|
||||
"displayName": "Relay 8",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "d380da7f-00c9-4458-ba4c-ed0d10060a24",
|
||||
"name": "input1State",
|
||||
"displayName": "Input 1",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "1e990bb6-912a-4805-b03a-e41d95ee2494",
|
||||
"name": "input2State",
|
||||
"displayName": "Input 2",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "bb460c57-2690-4ddd-8d0c-efcedc74cc53",
|
||||
"name": "input3State",
|
||||
"displayName": "Input 3",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "0285f664-a46b-478f-b27d-4fd2b171883e",
|
||||
"name": "input4State",
|
||||
"displayName": "Input 4",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "d09da37c-ccb9-4583-a42a-1d5b4e074751",
|
||||
"name": "input5State",
|
||||
"displayName": "Input 5",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "45aca74d-12ed-4fce-a332-22535d91cf87",
|
||||
"name": "input6State",
|
||||
"displayName": "Input 6",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "ef593976-820b-4eb2-9156-8c14e46e9dfe",
|
||||
"name": "input7State",
|
||||
"displayName": "Input 7",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "6c46fb18-2f34-49c0-b22c-0eb561a9c7b0",
|
||||
"name": "input8State",
|
||||
"displayName": "Input 8",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
}
|
||||
],
|
||||
"actionTypes": [
|
||||
{
|
||||
"id": "19526ec5-991d-4b6f-855a-d2b61da05caa",
|
||||
"name": "setRelay",
|
||||
"displayName": "Set relay",
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "f7b2830a-182c-4de5-b689-9ff599add6ac",
|
||||
"name": "channel",
|
||||
"displayName": "Channel (1-8)",
|
||||
"type": "int",
|
||||
"defaultValue": 1,
|
||||
"minValue": 1,
|
||||
"maxValue": 8
|
||||
},
|
||||
{
|
||||
"id": "dee4196d-586a-4735-8c3e-12e01f849787",
|
||||
"name": "state",
|
||||
"displayName": "State",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "0c0e9c8f-bf97-4f34-bd31-3252aade9168",
|
||||
"name": "setAllRelays",
|
||||
"displayName": "Set all relays",
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "791becf8-78aa-4c84-96df-2689d87970c8",
|
||||
"name": "state",
|
||||
"displayName": "State",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"eventTypes": [
|
||||
{
|
||||
"id": "63212751-793d-4147-89d0-47d71669c672",
|
||||
"name": "inputChanged",
|
||||
"displayName": "Input changed",
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "42779413-d416-4211-a1fb-76bcbc90a5cd",
|
||||
"name": "channel",
|
||||
"displayName": "Channel (1-8)",
|
||||
"type": "int",
|
||||
"defaultValue": 1
|
||||
},
|
||||
{
|
||||
"id": "d3f66c2f-ed95-46ae-be06-ce151c1793d3",
|
||||
"name": "state",
|
||||
"displayName": "State",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,317 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright (C) 2025, ETM-Schurig SARL
|
||||
*
|
||||
* This file is part of nymea-plugins-modbus.
|
||||
*
|
||||
* nymea-plugins-modbus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* nymea-plugins-modbus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with nymea-plugins-modbus. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "integrationpluginwavesharerelayed8.h"
|
||||
#include "plugininfo.h"
|
||||
#include "hardwaremanager.h"
|
||||
#include "hardware/modbus/modbusrtuhardwareresource.h"
|
||||
|
||||
IntegrationPluginWaveshareRelayD8::IntegrationPluginWaveshareRelayD8()
|
||||
{
|
||||
}
|
||||
|
||||
void IntegrationPluginWaveshareRelayD8::discoverThings(ThingDiscoveryInfo *info)
|
||||
{
|
||||
foreach (ModbusRtuMaster *modbusMaster, hardwareManager()->modbusRtuResource()->modbusRtuMasters()) {
|
||||
qCDebug(dcWaveshareRelayD8()) << "Found RTU master resource" << modbusMaster;
|
||||
if (modbusMaster->connected()
|
||||
&& modbusMaster->baudrate() == 9600
|
||||
&& modbusMaster->dataBits() == QSerialPort::Data8
|
||||
&& modbusMaster->stopBits() == QSerialPort::OneStop
|
||||
&& modbusMaster->parity() == QSerialPort::NoParity) {
|
||||
ParamList parameters;
|
||||
ThingDescriptor thingDescriptor(waveshareRelayD8ThingClassId,
|
||||
"Waveshare Relay D8",
|
||||
modbusMaster->serialPort());
|
||||
parameters.append(Param(waveshareRelayD8ThingRtuMasterParamTypeId,
|
||||
modbusMaster->modbusUuid().toString()));
|
||||
thingDescriptor.setParams(parameters);
|
||||
info->addThingDescriptor(thingDescriptor);
|
||||
} else {
|
||||
qCDebug(dcWaveshareRelayD8()) << "Skipping RTU master (not connected or wrong settings):" << modbusMaster;
|
||||
}
|
||||
}
|
||||
|
||||
QString displayMessage;
|
||||
if (info->thingDescriptors().isEmpty()) {
|
||||
displayMessage = QT_TR_NOOP("Please configure a Modbus RTU master with 9600 baud, 8 data bits, 1 stop bit and no parity.");
|
||||
}
|
||||
|
||||
info->finish(Thing::ThingErrorNoError, displayMessage);
|
||||
}
|
||||
|
||||
void IntegrationPluginWaveshareRelayD8::setupThing(ThingSetupInfo *info)
|
||||
{
|
||||
Thing *thing = info->thing();
|
||||
qCDebug(dcWaveshareRelayD8()) << "Setup" << thing << thing->params();
|
||||
|
||||
if (m_connections.contains(thing)) {
|
||||
qCDebug(dcWaveshareRelayD8()) << "Reconfiguring existing thing" << thing->name();
|
||||
m_connections.take(thing)->deleteLater();
|
||||
}
|
||||
|
||||
QUuid rtuMasterUuid = thing->paramValue(waveshareRelayD8ThingRtuMasterParamTypeId).toUuid();
|
||||
ModbusRtuMaster *master = hardwareManager()->modbusRtuResource()->getModbusRtuMaster(rtuMasterUuid);
|
||||
if (!master) {
|
||||
info->finish(Thing::ThingErrorHardwareNotAvailable,
|
||||
QT_TR_NOOP("The Modbus RTU master is not available."));
|
||||
return;
|
||||
}
|
||||
|
||||
quint16 slaveAddress = static_cast<quint16>(
|
||||
thing->paramValue(waveshareRelayD8ThingSlaveAddressParamTypeId).toUInt());
|
||||
|
||||
WaveshareRelayD8ModbusRtuConnection *connection =
|
||||
new WaveshareRelayD8ModbusRtuConnection(master, slaveAddress, this);
|
||||
connect(info, &ThingSetupInfo::aborted, connection,
|
||||
&WaveshareRelayD8ModbusRtuConnection::deleteLater);
|
||||
|
||||
// Reachability
|
||||
connect(connection, &WaveshareRelayD8ModbusRtuConnection::reachableChanged,
|
||||
thing, [connection, thing](bool reachable) {
|
||||
qCDebug(dcWaveshareRelayD8()) << thing->name() << "reachable changed:" << reachable;
|
||||
if (reachable) {
|
||||
connection->initialize();
|
||||
} else {
|
||||
thing->setStateValue(waveshareRelayD8ConnectedStateTypeId, false);
|
||||
}
|
||||
});
|
||||
|
||||
// Initialization
|
||||
connect(connection, &WaveshareRelayD8ModbusRtuConnection::initializationFinished,
|
||||
info, [=](bool success) {
|
||||
qCDebug(dcWaveshareRelayD8()) << "Initialization finished:" << success;
|
||||
if (success) {
|
||||
m_connections.insert(thing, connection);
|
||||
info->finish(Thing::ThingErrorNoError);
|
||||
} else {
|
||||
delete connection;
|
||||
info->finish(Thing::ThingErrorHardwareNotAvailable);
|
||||
}
|
||||
});
|
||||
|
||||
connect(connection, &WaveshareRelayD8ModbusRtuConnection::initializationFinished,
|
||||
thing, [=](bool success) {
|
||||
if (success) {
|
||||
thing->setStateValue(waveshareRelayD8ConnectedStateTypeId, true);
|
||||
}
|
||||
});
|
||||
|
||||
// Relay state changes (bulk read FC01 → individual signals)
|
||||
connect(connection, &WaveshareRelayD8ModbusRtuConnection::relay1Changed,
|
||||
thing, [thing](quint16 value) {
|
||||
thing->setStateValue(waveshareRelayD8Relay1StateStateTypeId, value != 0);
|
||||
});
|
||||
connect(connection, &WaveshareRelayD8ModbusRtuConnection::relay2Changed,
|
||||
thing, [thing](quint16 value) {
|
||||
thing->setStateValue(waveshareRelayD8Relay2StateStateTypeId, value != 0);
|
||||
});
|
||||
connect(connection, &WaveshareRelayD8ModbusRtuConnection::relay3Changed,
|
||||
thing, [thing](quint16 value) {
|
||||
thing->setStateValue(waveshareRelayD8Relay3StateStateTypeId, value != 0);
|
||||
});
|
||||
connect(connection, &WaveshareRelayD8ModbusRtuConnection::relay4Changed,
|
||||
thing, [thing](quint16 value) {
|
||||
thing->setStateValue(waveshareRelayD8Relay4StateStateTypeId, value != 0);
|
||||
});
|
||||
connect(connection, &WaveshareRelayD8ModbusRtuConnection::relay5Changed,
|
||||
thing, [thing](quint16 value) {
|
||||
thing->setStateValue(waveshareRelayD8Relay5StateStateTypeId, value != 0);
|
||||
});
|
||||
connect(connection, &WaveshareRelayD8ModbusRtuConnection::relay6Changed,
|
||||
thing, [thing](quint16 value) {
|
||||
thing->setStateValue(waveshareRelayD8Relay6StateStateTypeId, value != 0);
|
||||
});
|
||||
connect(connection, &WaveshareRelayD8ModbusRtuConnection::relay7Changed,
|
||||
thing, [thing](quint16 value) {
|
||||
thing->setStateValue(waveshareRelayD8Relay7StateStateTypeId, value != 0);
|
||||
});
|
||||
connect(connection, &WaveshareRelayD8ModbusRtuConnection::relay8Changed,
|
||||
thing, [thing](quint16 value) {
|
||||
thing->setStateValue(waveshareRelayD8Relay8StateStateTypeId, value != 0);
|
||||
});
|
||||
|
||||
// Opto input state changes (bulk read FC02 → individual signals + event)
|
||||
connect(connection, &WaveshareRelayD8ModbusRtuConnection::input1Changed,
|
||||
thing, [this, thing](quint16 value) {
|
||||
bool state = value != 0;
|
||||
thing->setStateValue(waveshareRelayD8Input1StateStateTypeId, state);
|
||||
emitInputChangedEvent(thing, 1, state);
|
||||
});
|
||||
connect(connection, &WaveshareRelayD8ModbusRtuConnection::input2Changed,
|
||||
thing, [this, thing](quint16 value) {
|
||||
bool state = value != 0;
|
||||
thing->setStateValue(waveshareRelayD8Input2StateStateTypeId, state);
|
||||
emitInputChangedEvent(thing, 2, state);
|
||||
});
|
||||
connect(connection, &WaveshareRelayD8ModbusRtuConnection::input3Changed,
|
||||
thing, [this, thing](quint16 value) {
|
||||
bool state = value != 0;
|
||||
thing->setStateValue(waveshareRelayD8Input3StateStateTypeId, state);
|
||||
emitInputChangedEvent(thing, 3, state);
|
||||
});
|
||||
connect(connection, &WaveshareRelayD8ModbusRtuConnection::input4Changed,
|
||||
thing, [this, thing](quint16 value) {
|
||||
bool state = value != 0;
|
||||
thing->setStateValue(waveshareRelayD8Input4StateStateTypeId, state);
|
||||
emitInputChangedEvent(thing, 4, state);
|
||||
});
|
||||
connect(connection, &WaveshareRelayD8ModbusRtuConnection::input5Changed,
|
||||
thing, [this, thing](quint16 value) {
|
||||
bool state = value != 0;
|
||||
thing->setStateValue(waveshareRelayD8Input5StateStateTypeId, state);
|
||||
emitInputChangedEvent(thing, 5, state);
|
||||
});
|
||||
connect(connection, &WaveshareRelayD8ModbusRtuConnection::input6Changed,
|
||||
thing, [this, thing](quint16 value) {
|
||||
bool state = value != 0;
|
||||
thing->setStateValue(waveshareRelayD8Input6StateStateTypeId, state);
|
||||
emitInputChangedEvent(thing, 6, state);
|
||||
});
|
||||
connect(connection, &WaveshareRelayD8ModbusRtuConnection::input7Changed,
|
||||
thing, [this, thing](quint16 value) {
|
||||
bool state = value != 0;
|
||||
thing->setStateValue(waveshareRelayD8Input7StateStateTypeId, state);
|
||||
emitInputChangedEvent(thing, 7, state);
|
||||
});
|
||||
connect(connection, &WaveshareRelayD8ModbusRtuConnection::input8Changed,
|
||||
thing, [this, thing](quint16 value) {
|
||||
bool state = value != 0;
|
||||
thing->setStateValue(waveshareRelayD8Input8StateStateTypeId, state);
|
||||
emitInputChangedEvent(thing, 8, state);
|
||||
});
|
||||
|
||||
connection->update();
|
||||
}
|
||||
|
||||
void IntegrationPluginWaveshareRelayD8::postSetupThing(Thing *thing)
|
||||
{
|
||||
Q_UNUSED(thing)
|
||||
if (!m_pluginTimer) {
|
||||
qCDebug(dcWaveshareRelayD8()) << "Starting plugin timer (5s)...";
|
||||
m_pluginTimer = hardwareManager()->pluginTimerManager()->registerTimer(5);
|
||||
connect(m_pluginTimer, &PluginTimer::timeout, this, [this] {
|
||||
foreach (WaveshareRelayD8ModbusRtuConnection *connection, m_connections) {
|
||||
if (connection->reachable()) {
|
||||
connection->update();
|
||||
}
|
||||
}
|
||||
});
|
||||
m_pluginTimer->start();
|
||||
}
|
||||
}
|
||||
|
||||
void IntegrationPluginWaveshareRelayD8::thingRemoved(Thing *thing)
|
||||
{
|
||||
WaveshareRelayD8ModbusRtuConnection *connection = m_connections.take(thing);
|
||||
delete connection;
|
||||
|
||||
if (myThings().isEmpty() && m_pluginTimer) {
|
||||
hardwareManager()->pluginTimerManager()->unregisterTimer(m_pluginTimer);
|
||||
m_pluginTimer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void IntegrationPluginWaveshareRelayD8::executeAction(ThingActionInfo *info)
|
||||
{
|
||||
Thing *thing = info->thing();
|
||||
Action action = info->action();
|
||||
WaveshareRelayD8ModbusRtuConnection *connection = m_connections.value(thing);
|
||||
|
||||
if (!connection || !connection->reachable()) {
|
||||
info->finish(Thing::ThingErrorHardwareNotAvailable);
|
||||
return;
|
||||
}
|
||||
|
||||
if (action.actionTypeId() == waveshareRelayD8SetRelayActionTypeId) {
|
||||
int channel = action.paramValue(waveshareRelayD8SetRelayActionChannelParamTypeId).toInt();
|
||||
quint16 value = action.paramValue(waveshareRelayD8SetRelayActionStateParamTypeId).toBool() ? 1 : 0;
|
||||
|
||||
ModbusRtuReply *reply = nullptr;
|
||||
switch (channel) {
|
||||
case 1: reply = connection->setRelay1(value); break;
|
||||
case 2: reply = connection->setRelay2(value); break;
|
||||
case 3: reply = connection->setRelay3(value); break;
|
||||
case 4: reply = connection->setRelay4(value); break;
|
||||
case 5: reply = connection->setRelay5(value); break;
|
||||
case 6: reply = connection->setRelay6(value); break;
|
||||
case 7: reply = connection->setRelay7(value); break;
|
||||
case 8: reply = connection->setRelay8(value); break;
|
||||
default:
|
||||
qCWarning(dcWaveshareRelayD8()) << "Invalid channel:" << channel;
|
||||
info->finish(Thing::ThingErrorInvalidParameter);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!reply) {
|
||||
info->finish(Thing::ThingErrorHardwareFailure);
|
||||
return;
|
||||
}
|
||||
|
||||
connect(reply, &ModbusRtuReply::finished, info, [reply, info]() {
|
||||
if (reply->error() == ModbusRtuReply::NoError) {
|
||||
info->finish(Thing::ThingErrorNoError);
|
||||
} else {
|
||||
qCWarning(dcWaveshareRelayD8()) << "setRelay write error:" << reply->errorString();
|
||||
info->finish(Thing::ThingErrorHardwareFailure);
|
||||
}
|
||||
});
|
||||
|
||||
} else if (action.actionTypeId() == waveshareRelayD8SetAllRelaysActionTypeId) {
|
||||
quint16 value = action.paramValue(waveshareRelayD8SetAllRelaysActionStateParamTypeId).toBool() ? 1 : 0;
|
||||
QVector<quint16> values(8, value);
|
||||
|
||||
// FC0F: write multiple coils at once (addresses 0-7)
|
||||
ModbusRtuReply *reply = connection->modbusRtuMaster()->writeCoils(
|
||||
connection->slaveId(), 0, values);
|
||||
|
||||
if (!reply) {
|
||||
info->finish(Thing::ThingErrorHardwareFailure);
|
||||
return;
|
||||
}
|
||||
|
||||
connect(reply, &ModbusRtuReply::finished, info, [reply, info]() {
|
||||
if (reply->error() == ModbusRtuReply::NoError) {
|
||||
info->finish(Thing::ThingErrorNoError);
|
||||
} else {
|
||||
qCWarning(dcWaveshareRelayD8()) << "setAllRelays write error:" << reply->errorString();
|
||||
info->finish(Thing::ThingErrorHardwareFailure);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
info->finish(Thing::ThingErrorActionTypeNotFound);
|
||||
}
|
||||
}
|
||||
|
||||
void IntegrationPluginWaveshareRelayD8::emitInputChangedEvent(Thing *thing, int channel, bool state)
|
||||
{
|
||||
Event event;
|
||||
event.setEventTypeId(waveshareRelayD8InputChangedEventTypeId);
|
||||
event.setThingId(thing->id());
|
||||
ParamList params;
|
||||
params << Param(waveshareRelayD8InputChangedEventChannelParamTypeId, channel);
|
||||
params << Param(waveshareRelayD8InputChangedEventStateParamTypeId, state);
|
||||
event.setParams(params);
|
||||
emit emitEvent(event);
|
||||
}
|
||||
@ -1,56 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright (C) 2025, ETM-Schurig SARL
|
||||
*
|
||||
* This file is part of nymea-plugins-modbus.
|
||||
*
|
||||
* nymea-plugins-modbus is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* nymea-plugins-modbus is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with nymea-plugins-modbus. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#ifndef INTEGRATIONPLUGINWAVESHARERELAYED8_H
|
||||
#define INTEGRATIONPLUGINWAVESHARERELAYED8_H
|
||||
|
||||
#include <plugintimer.h>
|
||||
#include <integrations/integrationplugin.h>
|
||||
|
||||
#include "extern-plugininfo.h"
|
||||
#include "autogenerated/wavesharerelayd8modbusrtuconnection.h"
|
||||
|
||||
class IntegrationPluginWaveshareRelayD8 : public IntegrationPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PLUGIN_METADATA(IID "io.nymea.IntegrationPlugin" FILE "integrationpluginwaveshare-relay-d8.json")
|
||||
Q_INTERFACES(IntegrationPlugin)
|
||||
|
||||
public:
|
||||
explicit IntegrationPluginWaveshareRelayD8();
|
||||
|
||||
void discoverThings(ThingDiscoveryInfo *info) override;
|
||||
void setupThing(ThingSetupInfo *info) override;
|
||||
void postSetupThing(Thing *thing) override;
|
||||
void thingRemoved(Thing *thing) override;
|
||||
void executeAction(ThingActionInfo *info) override;
|
||||
|
||||
private:
|
||||
PluginTimer *m_pluginTimer = nullptr;
|
||||
QHash<Thing *, WaveshareRelayD8ModbusRtuConnection *> m_connections;
|
||||
|
||||
void emitInputChangedEvent(Thing *thing, int channel, bool state);
|
||||
};
|
||||
|
||||
#endif // INTEGRATIONPLUGINWAVESHARERELAYED8_H
|
||||
@ -1,13 +0,0 @@
|
||||
{
|
||||
"title": "Waveshare Relay D8",
|
||||
"tagline": "8-channel Modbus RTU relay module with opto-isolated inputs",
|
||||
"icon": "waveshare.png",
|
||||
"stability": "experimental",
|
||||
"offline": true,
|
||||
"technologies": [
|
||||
"modbus"
|
||||
],
|
||||
"categories": [
|
||||
"actor"
|
||||
]
|
||||
}
|
||||
@ -1,182 +0,0 @@
|
||||
{
|
||||
"className": "WaveshareRelayD8",
|
||||
"protocol": "RTU",
|
||||
"endianness": "BigEndian",
|
||||
"errorLimitUntilNotReachable": 10,
|
||||
"checkReachableRegister": "relay1",
|
||||
"registers": [],
|
||||
"blocks": [
|
||||
{
|
||||
"id": "relayStates",
|
||||
"readSchedule": "update",
|
||||
"registers": [
|
||||
{
|
||||
"id": "relay1",
|
||||
"address": 0,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "coils",
|
||||
"description": "Relay 1",
|
||||
"defaultValue": "0",
|
||||
"access": "RW"
|
||||
},
|
||||
{
|
||||
"id": "relay2",
|
||||
"address": 1,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "coils",
|
||||
"description": "Relay 2",
|
||||
"defaultValue": "0",
|
||||
"access": "RW"
|
||||
},
|
||||
{
|
||||
"id": "relay3",
|
||||
"address": 2,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "coils",
|
||||
"description": "Relay 3",
|
||||
"defaultValue": "0",
|
||||
"access": "RW"
|
||||
},
|
||||
{
|
||||
"id": "relay4",
|
||||
"address": 3,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "coils",
|
||||
"description": "Relay 4",
|
||||
"defaultValue": "0",
|
||||
"access": "RW"
|
||||
},
|
||||
{
|
||||
"id": "relay5",
|
||||
"address": 4,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "coils",
|
||||
"description": "Relay 5",
|
||||
"defaultValue": "0",
|
||||
"access": "RW"
|
||||
},
|
||||
{
|
||||
"id": "relay6",
|
||||
"address": 5,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "coils",
|
||||
"description": "Relay 6",
|
||||
"defaultValue": "0",
|
||||
"access": "RW"
|
||||
},
|
||||
{
|
||||
"id": "relay7",
|
||||
"address": 6,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "coils",
|
||||
"description": "Relay 7",
|
||||
"defaultValue": "0",
|
||||
"access": "RW"
|
||||
},
|
||||
{
|
||||
"id": "relay8",
|
||||
"address": 7,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "coils",
|
||||
"description": "Relay 8",
|
||||
"defaultValue": "0",
|
||||
"access": "RW"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "inputStates",
|
||||
"readSchedule": "update",
|
||||
"registers": [
|
||||
{
|
||||
"id": "input1",
|
||||
"address": 0,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "discreteInputs",
|
||||
"description": "Opto input 1",
|
||||
"defaultValue": "0",
|
||||
"access": "RO"
|
||||
},
|
||||
{
|
||||
"id": "input2",
|
||||
"address": 1,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "discreteInputs",
|
||||
"description": "Opto input 2",
|
||||
"defaultValue": "0",
|
||||
"access": "RO"
|
||||
},
|
||||
{
|
||||
"id": "input3",
|
||||
"address": 2,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "discreteInputs",
|
||||
"description": "Opto input 3",
|
||||
"defaultValue": "0",
|
||||
"access": "RO"
|
||||
},
|
||||
{
|
||||
"id": "input4",
|
||||
"address": 3,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "discreteInputs",
|
||||
"description": "Opto input 4",
|
||||
"defaultValue": "0",
|
||||
"access": "RO"
|
||||
},
|
||||
{
|
||||
"id": "input5",
|
||||
"address": 4,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "discreteInputs",
|
||||
"description": "Opto input 5",
|
||||
"defaultValue": "0",
|
||||
"access": "RO"
|
||||
},
|
||||
{
|
||||
"id": "input6",
|
||||
"address": 5,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "discreteInputs",
|
||||
"description": "Opto input 6",
|
||||
"defaultValue": "0",
|
||||
"access": "RO"
|
||||
},
|
||||
{
|
||||
"id": "input7",
|
||||
"address": 6,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "discreteInputs",
|
||||
"description": "Opto input 7",
|
||||
"defaultValue": "0",
|
||||
"access": "RO"
|
||||
},
|
||||
{
|
||||
"id": "input8",
|
||||
"address": 7,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "discreteInputs",
|
||||
"description": "Opto input 8",
|
||||
"defaultValue": "0",
|
||||
"access": "RO"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
include(../plugins.pri)
|
||||
|
||||
# Generate modbus connection
|
||||
MODBUS_CONNECTIONS += waveshare-relay-d8-registers.json
|
||||
MODBUS_TOOLS_CONFIG += VERBOSE
|
||||
|
||||
include(../modbus.pri)
|
||||
|
||||
HEADERS += \
|
||||
integrationpluginwavesharerelayed8.h
|
||||
|
||||
SOURCES += \
|
||||
integrationpluginwavesharerelayed8.cpp
|
||||
Loading…
x
Reference in New Issue
Block a user