-
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Home Assistant lights (#1014)
* Add mDNS scan for HomeAssistant * Add template for HomeAssistant led driver * Define structures for Home Assistant integration * Add web Wizard for HA integration * Add lamps discovery & setup construction for the wizard * Load HA driver config * Implement HA light control driver * Add more configuration options * Final implementation inc. saving state * Update schema-skydimo.json * Support for Home Assistant lights
- Loading branch information
Showing
18 changed files
with
759 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#pragma once | ||
|
||
#ifndef PCH_ENABLED | ||
#include <QJsonObject> | ||
#include <QJsonArray> | ||
#include <memory> | ||
#include <list> | ||
#endif | ||
|
||
#include <led-drivers/LedDevice.h> | ||
#include <led-drivers/net/ProviderRestApi.h> | ||
#include <linalg.h> | ||
|
||
class DriverNetHomeAssistant : public LedDevice | ||
{ | ||
Q_OBJECT | ||
|
||
struct HomeAssistantLamp; | ||
|
||
struct HomeAssistantInstance | ||
{ | ||
QString homeAssistantHost; | ||
QString longLivedAccessToken; | ||
int transition; | ||
int constantBrightness; | ||
bool restoreOriginalState; | ||
|
||
std::list<HomeAssistantLamp> lamps; | ||
}; | ||
|
||
struct HomeAssistantLamp | ||
{ | ||
enum Mode { RGB = 0, HSV }; | ||
|
||
QString name; | ||
Mode colorModel; | ||
|
||
struct | ||
{ | ||
int isPoweredOn = -1; | ||
int brightness = -1; | ||
QJsonArray color; | ||
} orgState; | ||
}; | ||
|
||
public: | ||
explicit DriverNetHomeAssistant(const QJsonObject& deviceConfig); | ||
static LedDevice* construct(const QJsonObject& deviceConfig); | ||
|
||
QJsonObject discover(const QJsonObject& params) override; | ||
|
||
protected: | ||
bool powerOn() override; | ||
bool powerOff() override; | ||
|
||
private: | ||
bool init(const QJsonObject& deviceConfig) override; | ||
int write(const std::vector<ColorRgb>& ledValues) override; | ||
bool powerOnOff(bool isOn); | ||
bool saveStates(); | ||
void restoreStates(); | ||
|
||
HomeAssistantInstance _haInstance; | ||
|
||
std::unique_ptr<ProviderRestApi> _restApi; | ||
|
||
static bool isRegistered; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.