Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix StateChange write with invalid values on boot #7626

Merged
merged 1 commit into from Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion device_ddf_init.cpp
Expand Up @@ -279,8 +279,14 @@ bool DEV_InitDeviceFromDescription(Device *device, const DeviceDescription &ddf)
{
bool ok;

QVariant value = item->toVariant();
if (!value.isValid())
{
value = ddfItem.defaultValue;
}

StateChange stateChange(StateChange::StateWaitSync, SC_WriteZclAttribute, sub.uniqueId.at(1).toUInt());
stateChange.addTargetValue(item->descriptor().suffix, item->toVariant());
stateChange.addTargetValue(item->descriptor().suffix, value);
stateChange.setChangeTimeoutMs(1000 * 60 * 60);

if (writeParam.contains(QLatin1String("state.timeout")))
Expand Down
9 changes: 8 additions & 1 deletion state_change.cpp
Expand Up @@ -188,7 +188,14 @@ void StateChange::verifyItemChange(const ResourceItem *item)
/*! Adds a target value. */
void StateChange::addTargetValue(const char *suffix, const QVariant &value)
{
m_items.push_back({suffix, value});
if (value.isValid())
{
m_items.push_back({suffix, value});
}
else
{
DBG_Printf(DBG_ERROR, "SC add invalid traget value for: %s\n", suffix);
}
}

/*! Adds a parameter. If the parameter already exsits it will be replaced. */
Expand Down