fixed interfaces for shutter and light

master
Bernhard Trinnes 2018-06-12 10:52:18 +02:00 committed by Michael Zanetti
parent c02c10938a
commit 49e905d5fa
2 changed files with 77 additions and 80 deletions

View File

@ -88,10 +88,10 @@ DeviceManager::DeviceSetupStatus DevicePluginUniPi::setupDevice(Device *device)
return DeviceManager::DeviceSetupStatusSuccess;
}
if (device->deviceClassId() == shadingDeviceClassId) {
if (device->deviceClassId() == shutterDeviceClassId) {
m_usedGpios.insert(device->paramValue(shadingOutputUpParamTypeId).toString(), device);
m_usedGpios.insert(device->paramValue(shadingOutputDownParamTypeId).toString(), device);
m_usedGpios.insert(device->paramValue(shutterOutputOpenParamTypeId).toString(), device);
m_usedGpios.insert(device->paramValue(shutterOutputCloseParamTypeId).toString(), device);
return DeviceManager::DeviceSetupStatusSuccess;
}
@ -151,7 +151,7 @@ DeviceManager::DeviceError DevicePluginUniPi::discoverDevices(const DeviceClassI
return DeviceManager::DeviceErrorAsync;
}
if (deviceClassId == shadingDeviceClassId) {
if (deviceClassId == shutterDeviceClassId) {
// Create the list of available gpios
QList<DeviceDescriptor> deviceDescriptors;
@ -165,10 +165,10 @@ DeviceManager::DeviceError DevicePluginUniPi::discoverDevices(const DeviceClassI
DeviceDescriptor descriptor(deviceClassId, QString("Up Relay %1 + Down Relay %2").arg(circuit, m_relais.at(i+1)), circuit);
ParamList parameters;
parameters.append(Param(shadingOutputUpParamTypeId, circuit));
parameters.append(Param(shadingOutputDownParamTypeId, m_relais.at(i+1)));
parameters.append(Param(shadingOutputTypeUpParamTypeId, GPIOType::relay));
parameters.append(Param(shadingOutputTypeDownParamTypeId, GPIOType::relay));
parameters.append(Param(shutterOutputOpenParamTypeId, circuit));
parameters.append(Param(shutterOutputCloseParamTypeId, m_relais.at(i+1)));
parameters.append(Param(shutterOutputTypeOpenParamTypeId, GPIOType::relay));
parameters.append(Param(shutterOutputTypeCloseParamTypeId, GPIOType::relay));
descriptor.setParams(parameters);
deviceDescriptors.append(descriptor);
}
@ -276,29 +276,28 @@ DeviceManager::DeviceError DevicePluginUniPi::executeAction(Device *device, cons
return DeviceManager::DeviceErrorActionTypeNotFound;
}
if (device->deviceClassId() == shadingDeviceClassId) {
if (device->deviceClassId() == shutterDeviceClassId) {
QString circuitOpen = device->paramValue(shutterOutputOpenParamTypeId).toString();
QString typeOpen = device->paramValue(shutterOutputTypeOpenParamTypeId).toString();
if (action.actionTypeId() == shadingDownActionTypeId) {
QString circuit = device->paramValue(shadingOutputDownParamTypeId).toString();
QString type = device->paramValue(shadingOutputTypeDownParamTypeId).toString();
setOutput(circuit, type, false);
QString circuitClose = device->paramValue(shutterOutputCloseParamTypeId).toString();
QString typeClose = device->paramValue(shutterOutputTypeCloseParamTypeId).toString();
if (action.actionTypeId() == shutterCloseActionTypeId) {
setOutput(circuitOpen, typeOpen, false);
setOutput(circuitClose, typeClose, true);
return DeviceManager::DeviceErrorNoError;
}
if (action.actionTypeId() == shadingUpActionTypeId) {
QString circuit = device->paramValue(shadingOutputDownParamTypeId).toString();
QString type = device->paramValue(shadingOutputTypeDownParamTypeId).toString();
setOutput(circuit, type, false);
if (action.actionTypeId() == shutterOpenActionTypeId) {
setOutput(circuitClose, typeClose, false);
setOutput(circuitOpen, typeOpen, true);
return DeviceManager::DeviceErrorNoError;
}
if (action.actionTypeId() == shadingStopActionTypeId) {
QString circuitUp = device->paramValue(shadingOutputDownParamTypeId).toString();
QString typeUp = device->paramValue(shadingOutputTypeDownParamTypeId).toString();
setOutput(circuitUp, typeUp, false);
QString circuitDown = device->paramValue(shadingOutputDownParamTypeId).toString();
QString typeDown = device->paramValue(shadingOutputTypeDownParamTypeId).toString();
setOutput(circuitDown, typeDown, false);
if (action.actionTypeId() == shutterStopActionTypeId) {
setOutput(circuitOpen, typeOpen, false);
setOutput(circuitClose, typeClose, false);
return DeviceManager::DeviceErrorNoError;
}
@ -375,32 +374,32 @@ void DevicePluginUniPi::onWebSocketTextMessageReceived(QString message)
device->setStateValue(relayOutputRelayStatusStateTypeId, value);
break;
}
} else if (device->deviceClassId() == shadingDeviceClassId) {
if (circuit == device->paramValue(shadingOutputUpParamTypeId).toString()) {
if (value && device->stateValue(shadingStatusStateTypeId).toString().contains("stop")) {
device->setStateValue(shadingStatusStateTypeId, "up");
} else if (!value && device->stateValue(shadingStatusStateTypeId).toString().contains("up")) {
device->setStateValue(shadingStatusStateTypeId, "stop");
} else if (device->deviceClassId() == shutterDeviceClassId) {
if (circuit == device->paramValue(shutterOutputOpenParamTypeId).toString()) {
if (value && device->stateValue(shutterStatusStateTypeId).toString().contains("stop")) {
device->setStateValue(shutterStatusStateTypeId, "open");
} else if (!value && device->stateValue(shutterStatusStateTypeId).toString().contains("open")) {
device->setStateValue(shutterStatusStateTypeId, "stop");
} else {
qWarning(dcUniPi()) << "Shading" << device << "Output Up:" << value << "Status: " << device->stateValue(shadingStatusStateTypeId).toString();
qWarning(dcUniPi()) << "shutter" << device << "Output open:" << value << "Status: " << device->stateValue(shutterStatusStateTypeId).toString();
}
break;
}
if (circuit == device->paramValue(shadingOutputDownParamTypeId).toString()) {
if (value && device->stateValue(shadingStatusStateTypeId).toString().contains("stop")) {
device->setStateValue(shadingStatusStateTypeId, "down");
} else if (!value && device->stateValue(shadingStatusStateTypeId).toString().contains("down")) {
device->setStateValue(shadingStatusStateTypeId, "stop");
if (circuit == device->paramValue(shutterOutputCloseParamTypeId).toString()) {
if (value && device->stateValue(shutterStatusStateTypeId).toString().contains("stop")) {
device->setStateValue(shutterStatusStateTypeId, "close");
} else if (!value && device->stateValue(shutterStatusStateTypeId).toString().contains("close")) {
device->setStateValue(shutterStatusStateTypeId, "stop");
} else {
qWarning(dcUniPi()) << "Shading" << device << "Output Down:" << value << "Status: " << device->stateValue(shadingStatusStateTypeId).toString();
qWarning(dcUniPi()) << "shutter" << device << "Output close:" << value << "Status: " << device->stateValue(shutterStatusStateTypeId).toString();
}
break;
}
} else if (device->deviceClassId() == lightDeviceClassId) {
if (circuit == device->paramValue(lightOutputParamTypeId).toString()) {
device->setStateValue(lightStatusStateTypeId, value);
device->setStateValue(lightPowerStateTypeId, value);
break;
}
}

View File

@ -22,8 +22,8 @@
"name": "relayOutput",
"displayName": "Relay output",
"deviceIcon": "Power",
"createMethods": ["discover"],
"interface": [ ],
"createMethods": ["discovery"],
"interfaces": [ ],
"basicTags": ["Device"],
"paramTypes": [
{
@ -51,8 +51,8 @@
"name": "digitalInput",
"displayName": "Digital input",
"deviceIcon": "Switch",
"createMethods": ["discover"],
"interface": [ ],
"createMethods": ["discovery"],
"interfaces": [ ],
"basicTags": ["Sensor"],
"paramTypes": [
{
@ -78,8 +78,8 @@
"name": "digitalOutput",
"displayName": "Digital output",
"deviceIcon": "Power",
"createMethods": ["discover"],
"interface": [ ],
"createMethods": ["discovery"],
"interfaces": [ ],
"basicTags": ["Device"],
"paramTypes": [
{
@ -107,8 +107,8 @@
"name": "analogOutput",
"displayName": "Analog output",
"deviceIcon": "Power",
"createMethods": ["discover"],
"interface": [ ],
"createMethods": ["discovery"],
"interfaces": [ ],
"basicTags": ["Device"],
"paramTypes": [
{
@ -139,8 +139,8 @@
"name": "analogInput",
"displayName": "Analog Input",
"deviceIcon": "Power",
"createMethods": ["discover"],
"interface": [ ],
"createMethods": ["discovery"],
"interfaces": [ ],
"basicTags": ["Sensor"],
"paramTypes": [
{
@ -164,36 +164,36 @@
},
{
"id": "eadddc99-ce7d-4169-a2f9-a829fa105ad2",
"name": "shading",
"displayName": "Shading",
"deviceIcon": "Blinds",
"createMethods": ["discover"],
"interface": [ ],
"name": "shutter",
"displayName": "Shutter",
"deviceIcon": "RollerShutter",
"createMethods": ["discovery"],
"interfaces": ["shutter"],
"basicTags": ["Actuator"],
"paramTypes": [
{
"id": "7878ef4b-2395-4995-b17d-b69cb7d280e1",
"name": "outputUp",
"displayName": "Output Up",
"name": "outputOpen",
"displayName": "Output open",
"type": "QString"
},
{
"id": "4aa113d0-294b-403d-9dd1-ad0abe833176",
"name": "outputDown",
"displayName": "Output Down",
"name": "outputClose",
"displayName": "Output close",
"type": "QString"
},
{
"id": "a030f030-4f26-4f33-aadf-ec3c3a5141a7",
"name": "outputTypeUp",
"displayName": "Output Type Up",
"name": "outputTypeOpen",
"displayName": "Output type open",
"type": "QString",
"readOnly": true
},
{
"id": "fde509c5-8db1-411b-9e71-36997c39ee6b",
"name": "outputTypeDown",
"displayName": "Output Type Down",
"name": "outputTypeClose",
"displayName": "Output type close",
"type": "QString",
"readOnly": true
}
@ -203,11 +203,12 @@
"id": "b8955f33-780a-48a5-9c50-c1bccf09918f",
"name": "status",
"displayName": "Status",
"displayNameEvent": "Status changed",
"type": "QString",
"possibleValues":[
"up",
"open",
"stop",
"down"
"close"
],
"defaultValue": "stop"
}
@ -215,21 +216,18 @@
"actionTypes":[
{
"id": "cc8a13ae-2a3d-440a-a127-962fb912e511",
"name": "up",
"displayName": "Up",
"type": "bool"
"name": "open",
"displayName": "Open"
},
{
"id": "19bda8bb-1a78-4f2f-9927-ff543012462e",
"name": "stop",
"displayName": "Stop",
"type": "bool"
"displayName": "Stop"
},
{
"id": "7dc32e36-6a5c-46e1-8507-d9283067ac21",
"name": "down",
"displayName": "Down",
"type": "bool"
"name": "close",
"displayName": "Close"
}
]
},
@ -237,9 +235,9 @@
"id": "34fc941e-3465-4618-acf6-dda9c7242e27",
"name": "light",
"displayName": "Light",
"deviceIcon": "Light",
"createMethods": ["discover"],
"interface": [""],
"deviceIcon": "LightBulb",
"createMethods": ["discovery"],
"interfaces": ["light"],
"basicTags": ["Actuator"],
"paramTypes": [
{
@ -259,10 +257,10 @@
"stateTypes":[
{
"id": "3d0d6abc-87b9-42af-820e-e3bc7bde1743",
"name": "status",
"displayName": "Light",
"displayNameEvent": "Light power changed",
"displayNameAction": "Set light power",
"name": "power",
"displayName": "Power",
"displayNameEvent": "Power changed",
"displayNameAction": "Set power",
"type": "bool",
"defaultValue": false,
"writable": true