fix actions cleanup

This commit is contained in:
Michael Zanetti 2020-07-10 23:02:06 +02:00
parent b0b480a539
commit 746f3e4121
3 changed files with 61 additions and 3 deletions

View File

@ -536,7 +536,10 @@ void PythonIntegrationPlugin::executeAction(ThingActionInfo *info)
PyGILState_Release(s);
});
callPluginFunction("executeAction", reinterpret_cast<PyObject*>(pyInfo));
bool success = callPluginFunction("executeAction", reinterpret_cast<PyObject*>(pyInfo));
if (!success) {
info->finish(Thing::ThingErrorUnsupportedFeature);
}
}
void PythonIntegrationPlugin::thingRemoved(Thing *thing)

View File

@ -49,6 +49,21 @@
"displayName": "Python mock thing",
"createMethods": ["user"],
"setupMethod": "justAdd",
"eventTypes": [
{
"id": "de6c2425-0dee-413f-8f4c-bb0929e83c0d",
"name": "event1",
"displayName": "Event 1",
"paramTypes": [
{
"id": "9f6aef52-dcde-4ee1-8ae3-4823594bf153",
"name": "param1",
"displayName": "Event param 1",
"type": "QString"
}
]
}
],
"stateTypes": [
{
"id": "24714828-93ec-41a7-875e-6a0b5b57d25c",
@ -59,6 +74,22 @@
"type": "int",
"defaultValue": 0
}
],
"actionTypes": [
{
"id": "a504933a-2b86-41c1-b188-8998d445adf8",
"name": "action1",
"displayName": "Action 1",
"paramTypes": [
{
"id": "5a824a21-3e97-49a5-8b4d-2a5bc3ea99ef",
"name": "param1",
"displayName": "Action param 1",
"type": "QString",
"defaultValue": "hello"
}
]
}
]
},
{
@ -121,6 +152,22 @@
"type": "int",
"defaultValue": 0
}
],
"actionTypes": [
{
"id": "9bcc17ee-52a4-48ef-9a76-b2df4433dac5",
"name": "action1",
"displayName": "Action 1",
"paramTypes": [
{
"id": "2e86cb76-e1a9-4afd-8fd3-e900cbb738f5",
"name": "param1",
"displayName": "Action param 1",
"type": "QString",
"defaultValue": "hello"
}
]
}
]
}
]

View File

@ -10,9 +10,14 @@ async def init():
await asyncio.sleep(2);
logger.log("Updating stuff")
for thing in myThings():
if thing.thingClassId == pyMockThingClassId:
logger.log("Emitting event 1 for", thing.name, "eventTypeId", pyMockEvent1EventTypeId)
thing.emitEvent(pyMockEvent1EventTypeId, [nymea.Param(pyMockEvent1EventParam1ParamTypeId, "Im an event")])
logger.log("Setting state 1 for", thing.name, "to", thing.stateValue(pyMockState1StateTypeId) + 1)
thing.setStateValue(pyMockState1StateTypeId, thing.stateValue(pyMockState1StateTypeId) + 1)
if thing.thingClassId == pyMockDiscoveryPairingThingClassId:
logger.log("Emitting event 1 for", thing.name)
# thing.emitEvent(pyMockDiscoveryPairingEvent1EventTypeId, [nymea.Param(pyMockDiscoveryPairingEvent1EventParam1ParamTypeId, "Im an event")])
thing.emitEvent(pyMockDiscoveryPairingEvent1EventTypeId, [nymea.Param(pyMockDiscoveryPairingEvent1EventParam1ParamTypeId, "Im an event")])
logger.log("Setting state 1 for", thing.name, "Old value is:", thing.stateValue(pyMockDiscoveryPairingState1StateTypeId))
thing.setStateValue(pyMockDiscoveryPairingState1StateTypeId, thing.stateValue(pyMockDiscoveryPairingState1StateTypeId) + 1)
@ -79,7 +84,6 @@ async def confirmPairing(info, username, secret):
async def setupThing(info):
# logger.log("setupThing for", info.thing.name, info.thing.params)
logger.log("setupThing for", info.thing.name)
info.finish(nymea.ThingErrorNoError)
@ -96,6 +100,10 @@ async def postSetupThing(thing):
logger.log("Setting 1 value:", thing.setting(pyMockDiscoveryPairingSettingsSetting1ParamTypeId))
async def executeAction(info):
logger.log("executeAction for", info.thing.name, info.actionTypeId, "with params", info.params[0].value)
info.finish(nymea.ThingErrorNoError)
def autoThings():
autoThings = []