Skip to content

Commit

Permalink
Support for Home Assistant lights
Browse files Browse the repository at this point in the history
  • Loading branch information
awawa-dev committed Dec 14, 2024
1 parent b1cfbfe commit bf3d2d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions sources/led-drivers/net/DriverNetHomeAssistant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ bool DriverNetHomeAssistant::powerOnOff(bool isOn)
if (response.error())
{
this->setInError(response.error() ? response.getErrorReason() : "Unknown");
setupRetry(1500);
setupRetry(5000);
return false;
}

Expand Down Expand Up @@ -152,7 +152,14 @@ int DriverNetHomeAssistant::write(const std::vector<ColorRgb>& ledValues)
doc.setObject(row);
QString message(doc.toJson(QJsonDocument::Compact));
_restApi->setBasePath("/api/services/light/turn_on");
_restApi->post(message);
auto response = _restApi->post(message);

if (response.error())
{
this->setInError(response.error() ? response.getErrorReason() : "Unknown");
setupRetry(5000);
return false;
}
}

return 0;
Expand All @@ -167,7 +174,7 @@ bool DriverNetHomeAssistant::saveStates()
if (response.error())
{
this->setInError(response.error() ? response.getErrorReason() : "Unknown");
setupRetry(1500);
setupRetry(5000);
return false;
}
auto body = response.getBody();
Expand Down
2 changes: 1 addition & 1 deletion sources/led-drivers/schemas/schema-home_assistant.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"lamps": {
"type": "array",
"title":"edt_dev_spec_lights_title",
"propertyOrder" : 6,
"propertyOrder" : 7,
"uniqueItems" : true,
"items" : {
"type" : "object",
Expand Down

0 comments on commit bf3d2d5

Please sign in to comment.