Remove boblight plugin

master
Simon Stürz 2024-04-12 16:15:16 +02:00
parent d4d9ad698d
commit f333d67358
15 changed files with 1 additions and 1204 deletions

View File

@ -1,34 +0,0 @@
# Boblight
This plugin allows to communicate with a [Boblight server](https://code.google.com/p/boblight/)
The boblight server needs to be installed and running. In nymea it is required to setup the Boblight server connection first, during the setup you can configure how many channels you want to add. Each channel will appear auotamtically as an own device insided nymea. Default configuration for the Boblight server is `localhost:19333`, you can change the parameters during device setup.
Once the Boblight devices are added you can control them like any other color light in nymea.
## Supported Things
* Boblight Server
* Gateway device
* Define channel count
* Boblight Channel
* Color light
* Set color
* Set color temperature
* Set brightness
* Set power
**Generall**
* No internet connection required
## Requirements
* Boblight server running on `localhost:19333` or any other reachable IP address.
* Boblight device connected to the Boblight server.
* The package "nymea-plugin-boblight" must be installed.
## More
For more information regarding the project please visit the [project site](https://sites.google.com/site/wikikrautbox/krautbox/hardware/boblight).

View File

@ -1,99 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Copyright 2013 - 2020, nymea GmbH
* Contact: contact@nymea.io
*
* This file is part of nymea.
* This project including source code and documentation is protected by
* copyright law, and remains the property of nymea GmbH. All rights, including
* reproduction, publication, editing and translation, are reserved. The use of
* this project is subject to the terms of a license agreement to be concluded
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
* under https://nymea.io/license
*
* GNU Lesser General Public License Usage
* Alternatively, this project may be redistributed and/or modified under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; version 3. This project is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this project. If not, see <https://www.gnu.org/licenses/>.
*
* For any further details and any questions please contact us under
* contact@nymea.io or see our FAQ/Licensing Information on
* https://nymea.io/license/faq
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "bobchannel.h"
BobChannel::BobChannel(const int &id, QObject *parent) :
QObject(parent),
m_id(id)
{
m_animation = new QPropertyAnimation(this, "finalColor", this);
m_animation->setDuration(500);
}
int BobChannel::id() const
{
return m_id;
}
QColor BobChannel::color() const
{
return m_color;
}
void BobChannel::setColor(const QColor &color)
{
if (m_animation->state() == QPropertyAnimation::Running) {
m_animation->stop();
m_finalColor = m_color;
}
m_color = color;
emit colorChanged();
m_animation->setStartValue(m_finalColor);
m_animation->setEndValue(color);
m_animation->start();
}
bool BobChannel::power() const
{
return m_power;
}
void BobChannel::setPower(bool power)
{
if (power != m_power) {
m_power = power;
emit powerChanged();
if (m_animation->state() == QPropertyAnimation::Running) {
m_animation->stop();
}
QColor target = m_color;
target.setAlpha(target.alpha() * (m_power ? 1 : 0));
m_animation->setStartValue(m_finalColor);
m_animation->setEndValue(target);
m_animation->start();
}
}
QColor BobChannel::finalColor() const
{
return m_finalColor;
}
void BobChannel::setFinalColor(const QColor &color)
{
m_finalColor = color;
emit finalColorChanged();
}

View File

@ -1,76 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Copyright 2013 - 2020, nymea GmbH
* Contact: contact@nymea.io
*
* This file is part of nymea.
* This project including source code and documentation is protected by
* copyright law, and remains the property of nymea GmbH. All rights, including
* reproduction, publication, editing and translation, are reserved. The use of
* this project is subject to the terms of a license agreement to be concluded
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
* under https://nymea.io/license
*
* GNU Lesser General Public License Usage
* Alternatively, this project may be redistributed and/or modified under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; version 3. This project is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this project. If not, see <https://www.gnu.org/licenses/>.
*
* For any further details and any questions please contact us under
* contact@nymea.io or see our FAQ/Licensing Information on
* https://nymea.io/license/faq
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef BOBCHANNEL_H
#define BOBCHANNEL_H
#include <QColor>
#include <QObject>
#include <QPropertyAnimation>
class BobChannel : public QObject
{
Q_OBJECT
Q_PROPERTY(bool power READ power WRITE setPower NOTIFY powerChanged)
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
// don't directly write to this, the propertyAnimation requires a writable property tho...
Q_PROPERTY(QColor finalColor READ finalColor WRITE setFinalColor NOTIFY finalColorChanged)
public:
explicit BobChannel(const int &id, QObject *parent = 0);
int id() const;
QColor color() const;
void setColor(const QColor &color);
bool power() const;
void setPower(bool power);
QColor finalColor() const;
void setFinalColor(const QColor &color);
private:
QPropertyAnimation *m_animation;
int m_id;
bool m_power = false;
QColor m_color = Qt::white;
QColor m_finalColor = Qt::black;
signals:
void colorChanged();
void brightnessChanged();
void finalColorChanged();
void powerChanged();
};
#endif // BOBCHANNEL_H

View File

@ -1,191 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Copyright 2013 - 2020, nymea GmbH
* Contact: contact@nymea.io
*
* This file is part of nymea.
* This project including source code and documentation is protected by
* copyright law, and remains the property of nymea GmbH. All rights, including
* reproduction, publication, editing and translation, are reserved. The use of
* this project is subject to the terms of a license agreement to be concluded
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
* under https://nymea.io/license
*
* GNU Lesser General Public License Usage
* Alternatively, this project may be redistributed and/or modified under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; version 3. This project is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this project. If not, see <https://www.gnu.org/licenses/>.
*
* For any further details and any questions please contact us under
* contact@nymea.io or see our FAQ/Licensing Information on
* https://nymea.io/license/faq
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "bobclient.h"
#include "extern-plugininfo.h"
#include "libboblight/boblight.h"
#include <QDebug>
#include <QtConcurrent>
BobClient::BobClient(const QString &host, const int &port, QObject *parent) :
QObject(parent),
m_host(host),
m_port(port),
m_connected(false)
{
m_syncTimer = new QTimer(this);
m_syncTimer->setSingleShot(false);
m_syncTimer->setInterval(25);
connect(m_syncTimer, SIGNAL(timeout()), this, SLOT(sync()));
}
BobClient::~BobClient()
{
if (m_boblight) {
boblight_destroy(m_boblight);
}
}
bool BobClient::connectToBoblight()
{
if (connected()) {
return true;
}
m_boblight = boblight_init();
//try to connect, if we can't then bitch to stderr and destroy boblight
if (!boblight_connect(m_boblight, m_host.toLatin1().data(), m_port, 1000000)) {
qCWarning(dcBoblight) << "Failed to connect:" << boblight_geterror(m_boblight);
boblight_destroy(m_boblight);
m_boblight = nullptr;
setConnected(false);
return false;
}
qCDebug(dcBoblight) << "Connected to boblightd successfully.";
boblight_setpriority(m_boblight, m_priority);
for (int i = 0; i < lightsCount(); ++i) {
BobChannel *channel = new BobChannel(i, this);
channel->setColor(QColor(255,255,255,0));
connect(channel, SIGNAL(colorChanged()), this, SLOT(sync()));
m_channels.insert(i, channel);
}
setConnected(true);
return true;
}
bool BobClient::connected()
{
return m_connected;
}
void BobClient::setPriority(int priority)
{
m_priority = priority;
if (connected()) {
qCDebug(dcBoblight) << "setting priority to" << priority;
boblight_setpriority(m_boblight, priority);
}
emit priorityChanged(priority);
}
void BobClient::setPower(int channel, bool power)
{
qCDebug(dcBoblight()) << "BobClient: setPower" << channel << power;
m_channels.value(channel)->setPower(power);
emit powerChanged(channel, power);
}
BobChannel *BobClient::getChannel(const int &id)
{
foreach (BobChannel *channel, m_channels) {
if (channel->id() == id)
return channel;
}
return nullptr;
}
void BobClient::setColor(int channel, QColor color)
{
if (channel == -1) {
for (int i = 0; i < lightsCount(); ++i) {
setColor(i, color);
}
} else {
BobChannel *c = getChannel(channel);
if (c) {
c->setColor(color);
qCDebug(dcBoblight) << "set channel" << channel << "to color" << color;
emit colorChanged(channel, color);
}
}
}
void BobClient::setBrightness(int channel, int brightness)
{
QColor color = m_channels.value(channel)->color();
color.setAlpha(qRound(brightness * 255.0 / 100));
m_channels.value(channel)->setColor(color);
emit brightnessChanged(channel, brightness);
if (brightness > 0) {
m_channels.value(channel)->setPower(true);
emit powerChanged(channel, true);
}
}
void BobClient::sync()
{
if (!m_connected)
return;
foreach (BobChannel *channel, m_channels) {
int rgb[3];
rgb[0] = channel->finalColor().red() * channel->finalColor().alphaF();
rgb[1] = channel->finalColor().green() * channel->finalColor().alphaF();
rgb[2] = channel->finalColor().blue() * channel->finalColor().alphaF();
boblight_addpixel(m_boblight, channel->id(), rgb);
}
if (!boblight_sendrgb(m_boblight, 1, nullptr)) {
qCWarning(dcBoblight) << "Boblight connection error:" << boblight_geterror(m_boblight);
boblight_destroy(m_boblight);
qDeleteAll(m_channels);
m_channels.clear();
setConnected(false);
}
}
void BobClient::setConnected(bool connected)
{
m_connected = connected;
emit connectionChanged();
// if disconnected, delete all channels
if (!connected) {
m_syncTimer->stop();
qDeleteAll(m_channels);
} else {
m_syncTimer->start();
}
}
int BobClient::lightsCount()
{
return boblight_getnrlights(m_boblight);
}
QColor BobClient::currentColor(const int &channel)
{
return getChannel(channel)->color();
}

View File

@ -1,88 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Copyright 2013 - 2020, nymea GmbH
* Contact: contact@nymea.io
*
* This file is part of nymea.
* This project including source code and documentation is protected by
* copyright law, and remains the property of nymea GmbH. All rights, including
* reproduction, publication, editing and translation, are reserved. The use of
* this project is subject to the terms of a license agreement to be concluded
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
* under https://nymea.io/license
*
* GNU Lesser General Public License Usage
* Alternatively, this project may be redistributed and/or modified under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; version 3. This project is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this project. If not, see <https://www.gnu.org/licenses/>.
*
* For any further details and any questions please contact us under
* contact@nymea.io or see our FAQ/Licensing Information on
* https://nymea.io/license/faq
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef BOBCLIENT_H
#define BOBCLIENT_H
#include <QObject>
#include <QTimer>
#include <QMap>
#include <QColor>
#include <QTime>
#include <bobchannel.h>
class BobClient : public QObject
{
Q_OBJECT
public:
explicit BobClient(const QString &host = "127.0.0.1", const int &port = 19333, QObject *parent = nullptr);
~BobClient();
bool connectToBoblight();
bool connected();
int lightsCount();
QColor currentColor(const int &channel);
void setPriority(int priority);
void setPower(int channel, bool power);
void setColor(int channel, QColor color);
void setBrightness(int channel, int brightness);
private:
void *m_boblight = nullptr;
QTimer *m_syncTimer;
QString m_host;
int m_port;
bool m_connected;
int m_priority = 128;
QMap<int, QColor> m_colors;
QMap<int, BobChannel *> m_channels;
BobChannel *getChannel(const int &id);
private slots:
void sync();
void setConnected(bool connected);
signals:
void connectionChanged();
void powerChanged(int channel, bool power);
void brightnessChanged(int channel, int brightness);
void colorChanged(int channel, const QColor &color);
void priorityChanged(int priority);
};
#endif // BOBCLIENT_H

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

View File

@ -1,20 +0,0 @@
include(../plugins.pri)
QT += dbus bluetooth concurrent
CONFIG += c++11
TARGET = $$qtLibraryTarget(nymea_integrationpluginboblight)
LIBS += -lboblight
SOURCES += \
integrationpluginboblight.cpp \
bobclient.cpp \
bobchannel.cpp
HEADERS += \
integrationpluginboblight.h \
bobclient.h \
bobchannel.h

View File

@ -1,297 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Copyright 2013 - 2020, nymea GmbH
* Contact: contact@nymea.io
*
* This file is part of nymea.
* This project including source code and documentation is protected by
* copyright law, and remains the property of nymea GmbH. All rights, including
* reproduction, publication, editing and translation, are reserved. The use of
* this project is subject to the terms of a license agreement to be concluded
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
* under https://nymea.io/license
*
* GNU Lesser General Public License Usage
* Alternatively, this project may be redistributed and/or modified under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; version 3. This project is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this project. If not, see <https://www.gnu.org/licenses/>.
*
* For any further details and any questions please contact us under
* contact@nymea.io or see our FAQ/Licensing Information on
* https://nymea.io/license/faq
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "integrationpluginboblight.h"
#include "integrations/thing.h"
#include "bobclient.h"
#include "plugininfo.h"
#include "plugintimer.h"
#include <QDebug>
#include <QStringList>
#include <QtMath>
IntegrationPluginBoblight::IntegrationPluginBoblight()
{
}
void IntegrationPluginBoblight::init()
{
m_pluginTimer = hardwareManager()->pluginTimerManager()->registerTimer(15);
connect(m_pluginTimer, &PluginTimer::timeout, this, &IntegrationPluginBoblight::guhTimer);
}
void IntegrationPluginBoblight::thingRemoved(Thing *thing)
{
BobClient *client = m_bobClients.take(thing->id());
if (thing->thingClassId() == boblightServerThingClassId) {
client->deleteLater();
}
}
void IntegrationPluginBoblight::startMonitoringAutoThings()
{
m_canCreateAutoDevices = true;
qCDebug(dcBoblight()) << "Populating auto devices" << myThings().count();
QHash<ThingId, int> parentDevices;
QHash<ThingId, Thing*> deviceIds;
foreach (Thing *thing, myThings()) {
deviceIds.insert(thing->id(), thing);
if (thing->thingClassId() == boblightServerThingClassId) {
// qWarning() << "Device" << thing->id() << "is bridge";
if (!parentDevices.contains(thing->id())) {
parentDevices[thing->id()] = 0;
}
} else if (thing->thingClassId() == boblightThingClassId) {
// qWarning() << "Device" << thing->id() << "is child to bridge" << thing->parentId();
parentDevices[thing->parentId()] += 1;
}
}
QList<ThingDescriptor> descriptors;
foreach (const ThingId &id, parentDevices.keys()) {
if (parentDevices.value(id) < deviceIds.value(id)->paramValue(boblightServerThingChannelsParamTypeId).toInt()) {
for (int i = parentDevices.value(id); i < deviceIds.value(id)->paramValue(boblightServerThingChannelsParamTypeId).toInt(); i++) {
ThingDescriptor descriptor(boblightThingClassId, deviceIds.value(id)->name() + " " + QString::number(i + 1), QString(), id);
descriptor.setParams(ParamList() << Param(boblightThingChannelParamTypeId, i));
qCDebug(dcBoblight()) << "Adding new boblight channel" << i + 1;
descriptors.append(descriptor);
}
}
}
if (!descriptors.isEmpty()) {
emit autoThingsAppeared(descriptors);
}
}
void IntegrationPluginBoblight::guhTimer()
{
foreach (BobClient *client, m_bobClients) {
if (!client->connected()) {
client->connectToBoblight();
}
}
}
void IntegrationPluginBoblight::onPowerChanged(int channel, bool power)
{
qCDebug(dcBoblight()) << "power changed" << channel << power;
BobClient *sndr = dynamic_cast<BobClient*>(sender());
foreach (Thing* thing, myThings()) {
if (m_bobClients.value(thing->parentId()) == sndr && thing->paramValue(boblightThingChannelParamTypeId).toInt() == channel) {
qCDebug(dcBoblight()) << "setting state power" << power;
thing->setStateValue(boblightPowerStateTypeId, power);
}
}
}
void IntegrationPluginBoblight::onBrightnessChanged(int channel, int brightness)
{
BobClient *sndr = dynamic_cast<BobClient*>(sender());
foreach (Thing* thing, myThings()) {
if (m_bobClients.value(thing->parentId()) == sndr && thing->paramValue(boblightThingChannelParamTypeId).toInt() == channel) {
thing->setStateValue(boblightBrightnessStateTypeId, brightness);
}
}
}
void IntegrationPluginBoblight::onColorChanged(int channel, const QColor &color)
{
BobClient *sndr = dynamic_cast<BobClient*>(sender());
foreach (Thing* thing, myThings()) {
if (m_bobClients.value(thing->parentId()) == sndr && thing->paramValue(boblightThingChannelParamTypeId).toInt() == channel) {
thing->setStateValue(boblightColorStateTypeId, color);
}
}
}
void IntegrationPluginBoblight::onPriorityChanged(int priority)
{
BobClient *sndr = dynamic_cast<BobClient*>(sender());
foreach (Thing* thing, myThings()) {
if (thing->thingClassId() == boblightServerThingClassId && m_bobClients.value(thing->id()) == sndr) {
thing->setStateValue(boblightServerPriorityStateTypeId, priority);
}
}
}
QColor IntegrationPluginBoblight::tempToRgb(int temp)
{
// 153 cold: 0.839216, 1, 0.827451
// 500 warm: 0.870588, 1, 0.266667
// => 0 : 214,255,212
// 100 : 222,255,67
// r => 0 : 214 = 100 : 222
// => temp : (x-214) = 100 : (255 - 214)
// => x = temp * (255-214) / 100
// r = x + 214
int red = temp * 41 / 100 + 214;
int green = 255;
// b => 0 : 212 = 100 : 67
// => temp : (212 - x) = 100 : (212 - 145)
// => x = temp * 145 / 100
// g = 212 - x
int blue = 212 - temp * 145 / 100;
qWarning() << "temp:" << temp << "rgb" << red << green << blue;
return QColor(red, green, blue);
}
void IntegrationPluginBoblight::setupThing(ThingSetupInfo *info)
{
Thing *thing = info->thing();
if (thing->thingClassId() == boblightServerThingClassId) {
BobClient *bobClient = new BobClient(thing->paramValue(boblightServerThingHostAddressParamTypeId).toString(), thing->paramValue(boblightServerThingPortParamTypeId).toInt(), this);
bool connected = bobClient->connectToBoblight();
if (!connected) {
qCWarning(dcBoblight()) << "Error connecting to boblight on" << thing->paramValue(boblightServerThingHostAddressParamTypeId).toString();
} else {
qCDebug(dcBoblight()) << "Connected to boblight";
}
bobClient->setPriority(thing->stateValue(boblightServerPriorityStateTypeId).toInt());
thing->setStateValue(boblightServerConnectedStateTypeId, connected);
m_bobClients.insert(thing->id(), bobClient);
connect(bobClient, &BobClient::connectionChanged, this, &IntegrationPluginBoblight::onConnectionChanged);
connect(bobClient, &BobClient::powerChanged, this, &IntegrationPluginBoblight::onPowerChanged);
connect(bobClient, &BobClient::brightnessChanged, this, &IntegrationPluginBoblight::onBrightnessChanged);
connect(bobClient, &BobClient::colorChanged, this, &IntegrationPluginBoblight::onColorChanged);
connect(bobClient, &BobClient::priorityChanged, this, &IntegrationPluginBoblight::onPriorityChanged);
} else if (thing->thingClassId() == boblightThingClassId) {
BobClient *bobClient = m_bobClients.value(thing->parentId());
thing->setStateValue(boblightConnectedStateTypeId, bobClient->connected());
m_bobClients.insert(thing->id(), bobClient);
}
info->finish(Thing::ThingErrorNoError);
}
void IntegrationPluginBoblight::postSetupThing(Thing *thing)
{
if (thing->thingClassId() == boblightServerThingClassId && m_canCreateAutoDevices) {
startMonitoringAutoThings();
}
if (thing->thingClassId() == boblightThingClassId) {
BobClient *bobClient = m_bobClients.value(thing->parentId());
if (bobClient && bobClient->connected()) {
thing->setStateValue(boblightConnectedStateTypeId, bobClient->connected());
QColor color = thing->stateValue(boblightColorStateTypeId).value<QColor>();
int brightness = thing->stateValue(boblightBrightnessStateTypeId).toInt();
bool power = thing->stateValue(boblightPowerStateTypeId).toBool();
bobClient->setColor(thing->paramValue(boblightThingChannelParamTypeId).toInt(), color);
bobClient->setBrightness(thing->paramValue(boblightThingChannelParamTypeId).toInt(), brightness);
bobClient->setPower(thing->paramValue(boblightThingChannelParamTypeId).toInt(), power);
}
}
}
void IntegrationPluginBoblight::executeAction(ThingActionInfo *info)
{
Thing *thing = info->thing();
Action action = info->action();
qCDebug(dcBoblight()) << "Execute action for boblight" << action.params();
if (thing->thingClassId() == boblightServerThingClassId) {
BobClient *bobClient = m_bobClients.value(thing->id());
if (!bobClient || !bobClient->connected()) {
qCWarning(dcBoblight()) << "Boblight on" << thing->paramValue(boblightServerThingHostAddressParamTypeId).toString() << "not connected";
info->finish(Thing::ThingErrorHardwareNotAvailable);
return;
}
if (action.actionTypeId() == boblightServerPriorityActionTypeId) {
bobClient->setPriority(action.param(boblightServerPriorityActionPriorityParamTypeId).value().toInt());
info->finish(Thing::ThingErrorNoError);
return;
}
qCWarning(dcBoblight()) << "Unhandled action" << action.actionTypeId() << "for BoblightServer" << info;
info->finish(Thing::ThingErrorActionTypeNotFound);
return;
}
if (thing->thingClassId() == boblightThingClassId) {
BobClient *bobClient = m_bobClients.value(thing->parentId());
if (!bobClient || !bobClient->connected()) {
qCWarning(dcBoblight()) << "Boblight not connected";
info->finish(Thing::ThingErrorHardwareNotAvailable);
return;
}
if (action.actionTypeId() == boblightPowerActionTypeId) {
bobClient->setPower(thing->paramValue(boblightThingChannelParamTypeId).toInt(), action.param(boblightPowerActionPowerParamTypeId).value().toBool());
info->finish(Thing::ThingErrorNoError);
return;
}
if (action.actionTypeId() == boblightColorActionTypeId) {
bobClient->setColor(thing->paramValue(boblightThingChannelParamTypeId).toInt(), action.param(boblightColorActionColorParamTypeId).value().value<QColor>());
info->finish(Thing::ThingErrorNoError);
return;
}
if (action.actionTypeId() == boblightBrightnessActionTypeId) {
bobClient->setBrightness(thing->paramValue(boblightThingChannelParamTypeId).toInt(), action.param(boblightBrightnessActionBrightnessParamTypeId).value().toInt());
info->finish(Thing::ThingErrorNoError);
return;
}
if (action.actionTypeId() == boblightColorTemperatureActionTypeId) {
bobClient->setColor(thing->paramValue(boblightThingChannelParamTypeId).toInt(), tempToRgb(action.param(boblightColorTemperatureActionColorTemperatureParamTypeId).value().toInt()));
info->finish(Thing::ThingErrorNoError);
return;
}
info->finish(Thing::ThingErrorActionTypeNotFound);
return;
}
info->finish(Thing::ThingErrorThingClassNotFound);
}
void IntegrationPluginBoblight::onConnectionChanged()
{
BobClient *bobClient = static_cast<BobClient *>(sender());
qCDebug(dcBoblight()) << "Connection changed. BobClient:" << bobClient << bobClient->connected() << m_bobClients.keys(bobClient);
foreach (const ThingId &thingId, m_bobClients.keys(bobClient)) {
foreach (Thing *thing, myThings()) {
if (thing->id() == thingId || thing->parentId() == thingId) {
thing->setStateValue(boblightConnectedStateTypeId, bobClient->connected());
break;
}
}
}
}

View File

@ -1,78 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Copyright 2013 - 2020, nymea GmbH
* Contact: contact@nymea.io
*
* This file is part of nymea.
* This project including source code and documentation is protected by
* copyright law, and remains the property of nymea GmbH. All rights, including
* reproduction, publication, editing and translation, are reserved. The use of
* this project is subject to the terms of a license agreement to be concluded
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
* under https://nymea.io/license
*
* GNU Lesser General Public License Usage
* Alternatively, this project may be redistributed and/or modified under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; version 3. This project is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this project. If not, see <https://www.gnu.org/licenses/>.
*
* For any further details and any questions please contact us under
* contact@nymea.io or see our FAQ/Licensing Information on
* https://nymea.io/license/faq
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef INTEGRATIONPLUGINBOBLIGHT_H
#define INTEGRATIONPLUGINBOBLIGHT_H
#include "integrations/integrationplugin.h"
#include "bobclient.h"
class BobClient;
class PluginTimer;
class IntegrationPluginBoblight : public IntegrationPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "io.nymea.IntegrationPlugin" FILE "integrationpluginboblight.json")
Q_INTERFACES(IntegrationPlugin)
public:
explicit IntegrationPluginBoblight();
void init() override;
void setupThing(ThingSetupInfo *info) override;
void postSetupThing(Thing *thing) override;
void thingRemoved(Thing *thing) override;
void startMonitoringAutoThings() override;
void executeAction(ThingActionInfo *info) override;
private slots:
void onConnectionChanged();
void guhTimer();
void onPowerChanged(int channel, bool power);
void onBrightnessChanged(int channel, int brightness);
void onColorChanged(int channel, const QColor &color);
void onPriorityChanged(int priority);
private:
QColor tempToRgb(int temp);
private:
PluginTimer *m_pluginTimer = nullptr;
QHash<ThingId, BobClient*> m_bobClients;
bool m_canCreateAutoDevices = false;
};
#endif // INTEGRATIONPLUGINBOBLIGHT_H

View File

@ -1,138 +0,0 @@
{
"id": "d5271bea-1362-4cc6-888f-2ebe80bad46a",
"name": "Boblight",
"displayName": "Boblight",
"vendors": [
{
"id": "f0c9dd91-c2b0-4cd0-b161-a17fee9d2303",
"name": "boblight",
"displayName": "Boblight",
"thingClasses": [
{
"id": "f267a7f4-ed75-4026-9b97-98884d7f4399",
"name": "boblightServer",
"displayName": "Boblight server",
"createMethods": ["user"],
"interfaces": ["gateway", "connectable"],
"paramTypes": [
{
"id": "de82ea8c-2f1e-4b93-b85a-f6a0b7f87e4a",
"name": "hostAddress",
"displayName": "Host Address",
"type" : "QString",
"inputType": "IPv4Address",
"defaultValue": "127.0.0.1"
},
{
"id": "8cbe5ef8-6b45-441e-9051-08d48f3948da",
"name": "port",
"displayName": "Port",
"type" : "int",
"defaultValue": 19333
},
{
"id": "277f2458-d932-4a6e-a7bb-58814ab99663",
"name": "channels",
"displayName": "Channels",
"type": "int",
"defaultValue": 1
}
],
"stateTypes": [
{
"id": "638fb9ec-4797-4ef6-a9b6-d935f1c49e17",
"name": "connected",
"displayName": "connected",
"displayNameEvent": "Connected changed",
"defaultValue": false,
"type": "bool"
},
{
"id": "60d345e8-757c-4bc2-a96b-31121fc84356",
"name": "priority",
"displayName": "Priority",
"displayNameEvent": "Priority changed",
"displayNameAction": "Set priority",
"type": "int",
"defaultValue": 128,
"minValue": 0,
"maxValue": 256,
"writable": true
}
]
},
{
"id": "05347200-416e-4b75-b4e3-6f913a2a7e76",
"name": "boblight",
"displayName": "Boblight",
"createMethods": ["auto"],
"interfaces": ["colorlight", "connectable"],
"paramTypes": [
{
"id": "7b5b784d-d623-4a2e-b081-9be84b1ce1a8",
"name": "channel",
"displayName": "Channel",
"type": "int",
"defaultValue": -1
}
],
"stateTypes": [
{
"id": "bb40f1bd-62b9-485e-86a1-b0c820a93b8a",
"name": "connected",
"displayName": "connected",
"defaultValue": false,
"displayNameEvent": "Connected changed",
"type": "bool"
},
{
"id": "95aec7b5-247a-42a2-8748-273b034b988c",
"name": "power",
"displayName": "Power",
"defaultValue": false,
"type": "bool",
"displayNameEvent": "Power changed",
"displayNameAction": "Set power",
"writable": true
},
{
"id": "0a92eab5-233c-4081-840b-15578091365c",
"name": "brightness",
"displayName": "Brightness",
"defaultValue": 100,
"type": "int",
"displayNameEvent": "Brightness changed",
"displayNameAction": "Set brightness",
"writable": true,
"minValue": 0,
"maxValue": 100
},
{
"id": "b6f24e6f-d2a8-4f22-b40f-3a0e38bdabe0",
"name": "colorTemperature",
"displayName": "Color Temperature",
"defaultValue": 0,
"type": "int",
"displayNameEvent": "Color Temperature changed",
"displayNameAction": "Set color temperature",
"writable": true,
"minValue": 0,
"maxValue": 100
},
{
"id": "a213d2d1-bd29-4a16-8459-520aa919ae67",
"name": "color",
"displayName": "Color",
"defaultValue": "#ffffff",
"type": "QColor",
"displayNameEvent": "Color changed",
"displayNameAction": "Set color",
"writable": true
}
]
}
]
}
]
}

View File

@ -1,13 +0,0 @@
{
"title": "Boblight",
"tagline": "Connect to LED strips driven by Boblight.",
"icon": "boblight.png",
"stability": "community",
"offline": true,
"technologies": [
"network"
],
"categories": [
"light"
]
}

View File

@ -1,154 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>Boblight</name>
<message>
<source>Boblight</source>
<extracomment>The name of the ThingClass ({05347200-416e-4b75-b4e3-6f913a2a7e76})
----------
The name of the vendor ({f0c9dd91-c2b0-4cd0-b161-a17fee9d2303})
----------
The name of the plugin Boblight ({d5271bea-1362-4cc6-888f-2ebe80bad46a})</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Boblight server</source>
<extracomment>The name of the ThingClass ({f267a7f4-ed75-4026-9b97-98884d7f4399})</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Host Address</source>
<extracomment>The name of the ParamType (ThingClass: boblightServer, Type: thing, ID: {de82ea8c-2f1e-4b93-b85a-f6a0b7f87e4a})</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Port</source>
<extracomment>The name of the ParamType (ThingClass: boblightServer, Type: thing, ID: {8cbe5ef8-6b45-441e-9051-08d48f3948da})</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Channels</source>
<extracomment>The name of the ParamType (ThingClass: boblightServer, Type: thing, ID: {277f2458-d932-4a6e-a7bb-58814ab99663})</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Connected changed</source>
<extracomment>The name of the EventType ({bb40f1bd-62b9-485e-86a1-b0c820a93b8a}) of ThingClass boblight
----------
The name of the EventType ({638fb9ec-4797-4ef6-a9b6-d935f1c49e17}) of ThingClass boblightServer</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>connected</source>
<extracomment>The name of the ParamType (ThingClass: boblight, EventType: connected, ID: {bb40f1bd-62b9-485e-86a1-b0c820a93b8a})
----------
The name of the StateType ({bb40f1bd-62b9-485e-86a1-b0c820a93b8a}) of ThingClass boblight
----------
The name of the ParamType (ThingClass: boblightServer, EventType: connected, ID: {638fb9ec-4797-4ef6-a9b6-d935f1c49e17})
----------
The name of the StateType ({638fb9ec-4797-4ef6-a9b6-d935f1c49e17}) of ThingClass boblightServer</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Priority changed</source>
<extracomment>The name of the EventType ({60d345e8-757c-4bc2-a96b-31121fc84356}) of ThingClass boblightServer</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Priority</source>
<extracomment>The name of the ParamType (ThingClass: boblightServer, ActionType: priority, ID: {60d345e8-757c-4bc2-a96b-31121fc84356})
----------
The name of the ParamType (ThingClass: boblightServer, EventType: priority, ID: {60d345e8-757c-4bc2-a96b-31121fc84356})
----------
The name of the StateType ({60d345e8-757c-4bc2-a96b-31121fc84356}) of ThingClass boblightServer</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Set priority</source>
<extracomment>The name of the ActionType ({60d345e8-757c-4bc2-a96b-31121fc84356}) of ThingClass boblightServer</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Channel</source>
<extracomment>The name of the ParamType (ThingClass: boblight, Type: thing, ID: {7b5b784d-d623-4a2e-b081-9be84b1ce1a8})</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Power changed</source>
<extracomment>The name of the EventType ({95aec7b5-247a-42a2-8748-273b034b988c}) of ThingClass boblight</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Power</source>
<extracomment>The name of the ParamType (ThingClass: boblight, ActionType: power, ID: {95aec7b5-247a-42a2-8748-273b034b988c})
----------
The name of the ParamType (ThingClass: boblight, EventType: power, ID: {95aec7b5-247a-42a2-8748-273b034b988c})
----------
The name of the StateType ({95aec7b5-247a-42a2-8748-273b034b988c}) of ThingClass boblight</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Set power</source>
<extracomment>The name of the ActionType ({95aec7b5-247a-42a2-8748-273b034b988c}) of ThingClass boblight</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Brightness changed</source>
<extracomment>The name of the EventType ({0a92eab5-233c-4081-840b-15578091365c}) of ThingClass boblight</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Brightness</source>
<extracomment>The name of the ParamType (ThingClass: boblight, ActionType: brightness, ID: {0a92eab5-233c-4081-840b-15578091365c})
----------
The name of the ParamType (ThingClass: boblight, EventType: brightness, ID: {0a92eab5-233c-4081-840b-15578091365c})
----------
The name of the StateType ({0a92eab5-233c-4081-840b-15578091365c}) of ThingClass boblight</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Set brightness</source>
<extracomment>The name of the ActionType ({0a92eab5-233c-4081-840b-15578091365c}) of ThingClass boblight</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Color Temperature changed</source>
<extracomment>The name of the EventType ({b6f24e6f-d2a8-4f22-b40f-3a0e38bdabe0}) of ThingClass boblight</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Color Temperature</source>
<extracomment>The name of the ParamType (ThingClass: boblight, ActionType: colorTemperature, ID: {b6f24e6f-d2a8-4f22-b40f-3a0e38bdabe0})
----------
The name of the ParamType (ThingClass: boblight, EventType: colorTemperature, ID: {b6f24e6f-d2a8-4f22-b40f-3a0e38bdabe0})
----------
The name of the StateType ({b6f24e6f-d2a8-4f22-b40f-3a0e38bdabe0}) of ThingClass boblight</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Set color temperature</source>
<extracomment>The name of the ActionType ({b6f24e6f-d2a8-4f22-b40f-3a0e38bdabe0}) of ThingClass boblight</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Color changed</source>
<extracomment>The name of the EventType ({a213d2d1-bd29-4a16-8459-520aa919ae67}) of ThingClass boblight</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Color</source>
<extracomment>The name of the ParamType (ThingClass: boblight, ActionType: color, ID: {a213d2d1-bd29-4a16-8459-520aa919ae67})
----------
The name of the ParamType (ThingClass: boblight, EventType: color, ID: {a213d2d1-bd29-4a16-8459-520aa919ae67})
----------
The name of the StateType ({a213d2d1-bd29-4a16-8459-520aa919ae67}) of ThingClass boblight</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Set color</source>
<extracomment>The name of the ActionType ({a213d2d1-bd29-4a16-8459-520aa919ae67}) of ThingClass boblight</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

14
debian/control vendored
View File

@ -2,8 +2,7 @@ Source: nymea-plugins
Section: utils
Priority: optional
Maintainer: Nymea GmbH <developer@nymea.io>
Build-depends: libboblight-dev,
debhelper (>= 0.0.0),
Build-depends: debhelper (>= 0.0.0),
libnymea-dev (>= 0.26~),
libnymea-mqtt-dev,
libnymea-gpio-dev (>= 1.0.0~),
@ -80,17 +79,6 @@ Description: nymea integration plugin for bluos
This package contains the nymea integration plugin for bluos based media devices
Package: nymea-plugin-boblight
Architecture: any
Depends: ${shlibs:Depends},
${misc:Depends},
Conflicts: nymea-plugins-translations (< 1.0.1)
Description: nymea integration plugin for boblight
This package contains the nymea integration plugin for boblight. Boblight allows
controlling LEDs via home-brew controllers. See https://github.com/arvydas/boblight
for informations on boblight.
Package: nymea-plugin-bose
Architecture: any
Depends: ${shlibs:Depends},

View File

@ -1,2 +0,0 @@
usr/lib/@DEB_HOST_MULTIARCH@/nymea/plugins/libnymea_integrationpluginboblight.so
boblight/translations/*qm usr/share/nymea/translations/

View File

@ -7,7 +7,6 @@ PLUGIN_DIRS = \
awattar \
bimmerconnected \
bluos \
boblight \
bose \
bosswerk \
coinmarketcap \