powersync-plugins/philipshue/huedevice.cpp

137 lines
3.3 KiB
C++

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright (C) 2015 - 2019 Simon Stürz <simon.stuerz@guh.io> *
* *
* This file is part of nymea. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library 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 library; If not, see *
* <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "huedevice.h"
HueDevice::HueDevice(QObject *parent) :
QObject(parent)
{
}
int HueDevice::id() const
{
return m_id;
}
void HueDevice::setId(const int &id)
{
m_id = id;
}
QString HueDevice::name() const
{
return m_name;
}
void HueDevice::setName(const QString &name)
{
m_name = name;
}
QHostAddress HueDevice::hostAddress() const
{
return m_hostAddress;
}
void HueDevice::setHostAddress(const QHostAddress hostAddress)
{
m_hostAddress = hostAddress;
}
QString HueDevice::uuid()
{
return m_uuid;
}
void HueDevice::setUuid(const QString &uuid)
{
m_uuid = uuid;
}
QString HueDevice::apiKey() const
{
return m_apiKey;
}
void HueDevice::setApiKey(const QString &apiKey)
{
m_apiKey = apiKey;
}
QString HueDevice::modelId() const
{
return m_modelId;
}
void HueDevice::setModelId(const QString &modelId)
{
m_modelId = modelId;
}
QString HueDevice::type() const
{
return m_type;
}
void HueDevice::setType(const QString &type)
{
m_type = type;
}
QString HueDevice::softwareVersion() const
{
return m_softwareVersion;
}
void HueDevice::setSoftwareVersion(const QString &softwareVersion)
{
m_softwareVersion = softwareVersion;
}
bool HueDevice::reachable() const
{
return m_reachable;
}
void HueDevice::setReachable(const bool &reachable)
{
if (m_reachable == reachable)
return;
m_reachable = reachable;
emit reachableChanged(m_reachable);
}
QString HueDevice::getBaseUuid(const QString &uuid)
{
// Example: the hue gives uuid's starting with a mac address, followd by an id
// "00:17:88:01:06:44:36:86-02-0406" -> "00:17:88:01:06:44:36:86"
int dashIndex = uuid.indexOf("-");
if (dashIndex < 0) {
return uuid;
}
return uuid.left(dashIndex);
}