changed closing time from param to setting
This commit is contained in:
parent
987df40f06
commit
4bb8710137
@ -40,18 +40,28 @@ IntegrationPluginGenericThings::IntegrationPluginGenericThings()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IntegrationPluginGenericThings::init()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info)
|
void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info)
|
||||||
{
|
{
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
Thing *thing = info->thing();
|
Thing *thing = info->thing();
|
||||||
if (thing->thingClassId() == extendedBlindThingClassId) {
|
if (thing->thingClassId() == extendedBlindThingClassId) {
|
||||||
uint closingTime = thing->paramValue(extendedBlindThingClosingTimeParamTypeId).toUInt();
|
uint closingTime = thing->setting(extendedBlindSettingsClosingTimeParamTypeId).toUInt();
|
||||||
if (closingTime == 0) {
|
if (closingTime == 0) {
|
||||||
return info->finish(Thing::ThingErrorSetupFailed, tr("Invalid closing time"));
|
return info->finish(Thing::ThingErrorSetupFailed, tr("Invalid closing time"));
|
||||||
}
|
}
|
||||||
QTimer* timer = new QTimer(this);
|
QTimer* timer = new QTimer(this);
|
||||||
timer->setInterval(closingTime/100.00); // closing timer / 100 to update on every percent
|
timer->setInterval(closingTime/100.00); // closing timer / 100 to update on every percent
|
||||||
m_extendedBlindPercentageTimer.insert(thing, timer);
|
m_extendedBlindPercentageTimer.insert(thing, timer);
|
||||||
|
connect(thing, &Thing::settingChanged, thing, [timer] (const ParamTypeId ¶mTypeId, const QVariant &value) {
|
||||||
|
if (paramTypeId == extendedBlindSettingsClosingTimeParamTypeId) {
|
||||||
|
timer->setInterval(value.toUInt()/100.00);
|
||||||
|
}
|
||||||
|
});
|
||||||
connect(timer, &QTimer::timeout, this, [thing, this] {
|
connect(timer, &QTimer::timeout, this, [thing, this] {
|
||||||
uint currentPercentage = thing->stateValue(extendedBlindPercentageStateTypeId).toUInt();
|
uint currentPercentage = thing->stateValue(extendedBlindPercentageStateTypeId).toUInt();
|
||||||
|
|
||||||
@ -86,16 +96,16 @@ void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (info->thing()->thingClassId() == venetianBlindThingClassId) {
|
} else if (info->thing()->thingClassId() == venetianBlindThingClassId) {
|
||||||
uint closingTime = thing->paramValue(venetianBlindThingClosingTimeParamTypeId).toUInt();
|
uint closingTime = thing->setting(venetianBlindSettingsClosingTimeParamTypeId).toUInt();
|
||||||
uint angleTime = thing->paramValue(venetianBlindThingAngleTimeParamTypeId).toUInt();
|
uint angleTime = thing->setting(venetianBlindSettingsAngleTimeParamTypeId).toUInt();
|
||||||
if (closingTime <=0 || closingTime < angleTime || angleTime <= 0) {
|
if (closingTime <=0 || closingTime < angleTime || angleTime <= 0) {
|
||||||
return info->finish(Thing::ThingErrorSetupFailed, tr("Invalid closing or angle time"));
|
return info->finish(Thing::ThingErrorSetupFailed, tr("Invalid closing or angle time"));
|
||||||
}
|
}
|
||||||
QTimer* timer = new QTimer(this);
|
QTimer* closingTimer = new QTimer(this);
|
||||||
timer->setInterval(closingTime/100.00); // closing timer / 100 to update on every percent
|
closingTimer->setInterval(closingTime/100.00); // closing timer / 100 to update on every percent
|
||||||
m_extendedBlindPercentageTimer.insert(thing, timer);
|
m_extendedBlindPercentageTimer.insert(thing, closingTimer);
|
||||||
|
|
||||||
connect(timer, &QTimer::timeout, thing, [thing, this] {
|
connect(closingTimer, &QTimer::timeout, thing, [thing, this] {
|
||||||
uint currentPercentage = thing->stateValue(venetianBlindPercentageStateTypeId).toUInt();
|
uint currentPercentage = thing->stateValue(venetianBlindPercentageStateTypeId).toUInt();
|
||||||
|
|
||||||
if (thing->stateValue(venetianBlindStatusStateTypeId).toString() == "Closing") {
|
if (thing->stateValue(venetianBlindStatusStateTypeId).toString() == "Closing") {
|
||||||
@ -136,6 +146,13 @@ void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info)
|
|||||||
QTimer* angleTimer = new QTimer(this);
|
QTimer* angleTimer = new QTimer(this);
|
||||||
angleTimer->setInterval(angleTime/180.00); // -90 to 90 degree -> 180 degree total
|
angleTimer->setInterval(angleTime/180.00); // -90 to 90 degree -> 180 degree total
|
||||||
m_venetianBlindAngleTimer.insert(thing, angleTimer);
|
m_venetianBlindAngleTimer.insert(thing, angleTimer);
|
||||||
|
connect(thing, &Thing::settingChanged, thing, [closingTimer, angleTimer] (const ParamTypeId ¶mTypeId, const QVariant &value) {
|
||||||
|
if (paramTypeId == venetianBlindSettingsClosingTimeParamTypeId) {
|
||||||
|
closingTimer->setInterval(value.toUInt()/100.00);
|
||||||
|
} else if (paramTypeId == venetianBlindSettingsAngleTimeParamTypeId) {
|
||||||
|
angleTimer->setInterval(value.toUInt()/180.00);
|
||||||
|
}
|
||||||
|
});
|
||||||
connect(angleTimer, &QTimer::timeout, thing, [thing, this] {
|
connect(angleTimer, &QTimer::timeout, thing, [thing, this] {
|
||||||
int currentAngle = thing->stateValue(venetianBlindAngleStateTypeId).toInt();
|
int currentAngle = thing->stateValue(venetianBlindAngleStateTypeId).toInt();
|
||||||
if (thing->stateValue(venetianBlindStatusStateTypeId).toString() == "Closing") {
|
if (thing->stateValue(venetianBlindStatusStateTypeId).toString() == "Closing") {
|
||||||
|
|||||||
@ -43,6 +43,7 @@ class IntegrationPluginGenericThings: public IntegrationPlugin
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit IntegrationPluginGenericThings();
|
explicit IntegrationPluginGenericThings();
|
||||||
|
void init() override;
|
||||||
void setupThing(ThingSetupInfo *info) override;
|
void setupThing(ThingSetupInfo *info) override;
|
||||||
void executeAction(ThingActionInfo *info) override;
|
void executeAction(ThingActionInfo *info) override;
|
||||||
void thingRemoved(Thing *thing) override;
|
void thingRemoved(Thing *thing) override;
|
||||||
|
|||||||
@ -136,7 +136,7 @@
|
|||||||
"displayName": "Generic extended blind",
|
"displayName": "Generic extended blind",
|
||||||
"createMethods": ["user"],
|
"createMethods": ["user"],
|
||||||
"interfaces": ["extendedblind"],
|
"interfaces": ["extendedblind"],
|
||||||
"paramTypes": [
|
"settingsTypes": [
|
||||||
{
|
{
|
||||||
"id": "27a95b8d-7f97-441b-a3be-0646c517cb06",
|
"id": "27a95b8d-7f97-441b-a3be-0646c517cb06",
|
||||||
"name": "closingTime",
|
"name": "closingTime",
|
||||||
@ -228,7 +228,7 @@
|
|||||||
"displayName": "Venetian blind",
|
"displayName": "Venetian blind",
|
||||||
"createMethods": ["user"],
|
"createMethods": ["user"],
|
||||||
"interfaces": ["venetianblind"],
|
"interfaces": ["venetianblind"],
|
||||||
"paramTypes": [
|
"settingsTypes": [
|
||||||
{
|
{
|
||||||
"id": "4c0bf07d-aaab-4f67-af65-00ceaefbaa84",
|
"id": "4c0bf07d-aaab-4f67-af65-00ceaefbaa84",
|
||||||
"name": "closingTime",
|
"name": "closingTime",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user