add 2 missing data type conversions

This commit is contained in:
Michael Zanetti 2020-07-16 23:48:29 +02:00
parent 78e37f0d87
commit 1018083052
3 changed files with 11 additions and 4 deletions

View File

@ -56,7 +56,16 @@ QVariant PyObjectToQVariant(PyObject *pyObject)
if (qstrcmp(pyObject->ob_type->tp_name, "double") == 0) { if (qstrcmp(pyObject->ob_type->tp_name, "double") == 0) {
return QVariant(PyFloat_AsDouble(pyObject)); return QVariant(PyFloat_AsDouble(pyObject));
} }
Q_ASSERT_X(false, "pyutils.h", "Unhandled data type in conversion from Param to PyParam!");
if (qstrcmp(pyObject->ob_type->tp_name, "float") == 0) {
return QVariant(PyFloat_AsDouble(pyObject));
}
if (qstrcmp(pyObject->ob_type->tp_name, "bool") == 0) {
return QVariant(PyObject_IsTrue(pyObject));
}
Q_ASSERT_X(false, "pyutils.h", "Unhandled data type in conversion PyObject to QVariant!");
return QVariant(); return QVariant();
} }

View File

@ -1966,7 +1966,6 @@ void ThingManagerImplementation::loadThingStates(Thing *thing)
} }
value.convert(stateType.type()); value.convert(stateType.type());
thing->setStateValue(stateType.id(), value); thing->setStateValue(stateType.id(), value);
qWarning() << "**** loaded state" << stateType.name() << value;
} else { } else {
thing->setStateValue(stateType.id(), stateType.defaultValue()); thing->setStateValue(stateType.id(), stateType.defaultValue());
} }

View File

@ -7,8 +7,7 @@ async def init():
logger.log("Python mock plugin init") logger.log("Python mock plugin init")
while True: while True:
await asyncio.sleep(2); await asyncio.sleep(5);
logger.log("Updating stuff")
for thing in myThings(): for thing in myThings():
if thing.thingClassId == pyMockThingClassId: if thing.thingClassId == pyMockThingClassId:
logger.log("Emitting event 1 for", thing.name, "eventTypeId", pyMockEvent1EventTypeId) logger.log("Emitting event 1 for", thing.name, "eventTypeId", pyMockEvent1EventTypeId)