add connectable interface to philipshue
This commit is contained in:
parent
1b60940223
commit
31b061826e
@ -98,7 +98,7 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *dev
|
|||||||
device->setParamValue(hueBridgeBridgeIdParamTypeId, b->id());
|
device->setParamValue(hueBridgeBridgeIdParamTypeId, b->id());
|
||||||
device->setParamValue(hueBridgeBridgeMacParamTypeId, b->macAddress());
|
device->setParamValue(hueBridgeBridgeMacParamTypeId, b->macAddress());
|
||||||
m_bridges.insert(b, device);
|
m_bridges.insert(b, device);
|
||||||
device->setStateValue(hueBridgeBridgeReachableStateTypeId, true);
|
device->setStateValue(hueBridgeConnectedStateTypeId, true);
|
||||||
discoverBridgeDevices(b);
|
discoverBridgeDevices(b);
|
||||||
return DeviceManager::DeviceSetupStatusSuccess;
|
return DeviceManager::DeviceSetupStatusSuccess;
|
||||||
}
|
}
|
||||||
@ -326,7 +326,7 @@ void DevicePluginPhilipsHue::networkManagerReplyReady()
|
|||||||
|
|
||||||
// check HTTP status code
|
// check HTTP status code
|
||||||
if (status != 200 || reply->error() != QNetworkReply::NoError) {
|
if (status != 200 || reply->error() != QNetworkReply::NoError) {
|
||||||
if (device->stateValue(hueBridgeBridgeReachableStateTypeId).toBool()) {
|
if (device->stateValue(hueBridgeConnectedStateTypeId).toBool()) {
|
||||||
qCWarning(dcPhilipsHue) << "Refresh Hue Bridge request error:" << status << reply->errorString();
|
qCWarning(dcPhilipsHue) << "Refresh Hue Bridge request error:" << status << reply->errorString();
|
||||||
bridgeReachableChanged(device, false);
|
bridgeReachableChanged(device, false);
|
||||||
}
|
}
|
||||||
@ -352,7 +352,7 @@ void DevicePluginPhilipsHue::networkManagerReplyReady()
|
|||||||
|
|
||||||
// check HTTP status code
|
// check HTTP status code
|
||||||
if (status != 200 || reply->error() != QNetworkReply::NoError) {
|
if (status != 200 || reply->error() != QNetworkReply::NoError) {
|
||||||
if (device->stateValue(hueLightReachableStateTypeId).toBool()) {
|
if (device->stateValue(hueLightConnectedStateTypeId).toBool()) {
|
||||||
qCWarning(dcPhilipsHue) << "Refresh Hue lights request error:" << status << reply->errorString();
|
qCWarning(dcPhilipsHue) << "Refresh Hue lights request error:" << status << reply->errorString();
|
||||||
bridgeReachableChanged(device, false);
|
bridgeReachableChanged(device, false);
|
||||||
}
|
}
|
||||||
@ -366,7 +366,7 @@ void DevicePluginPhilipsHue::networkManagerReplyReady()
|
|||||||
|
|
||||||
// check HTTP status code
|
// check HTTP status code
|
||||||
if (status != 200 || reply->error() != QNetworkReply::NoError) {
|
if (status != 200 || reply->error() != QNetworkReply::NoError) {
|
||||||
if (device->stateValue(hueRemoteHueReachableStateTypeId).toBool()) {
|
if (device->stateValue(hueRemoteConnectedStateTypeId).toBool()) {
|
||||||
qCWarning(dcPhilipsHue) << "Refresh Hue sensors request error:" << status << reply->errorString();
|
qCWarning(dcPhilipsHue) << "Refresh Hue sensors request error:" << status << reply->errorString();
|
||||||
bridgeReachableChanged(device, false);
|
bridgeReachableChanged(device, false);
|
||||||
}
|
}
|
||||||
@ -489,7 +489,7 @@ DeviceManager::DeviceError DevicePluginPhilipsHue::executeAction(Device *device,
|
|||||||
|
|
||||||
if (device->deviceClassId() == hueBridgeDeviceClassId) {
|
if (device->deviceClassId() == hueBridgeDeviceClassId) {
|
||||||
HueBridge *bridge = m_bridges.key(device);
|
HueBridge *bridge = m_bridges.key(device);
|
||||||
if (!device->stateValue(hueBridgeBridgeReachableStateTypeId).toBool()) {
|
if (!device->stateValue(hueBridgeConnectedStateTypeId).toBool()) {
|
||||||
qCWarning(dcPhilipsHue) << "Bridge" << bridge->hostAddress().toString() << "not reachable";
|
qCWarning(dcPhilipsHue) << "Bridge" << bridge->hostAddress().toString() << "not reachable";
|
||||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||||
}
|
}
|
||||||
@ -526,14 +526,14 @@ void DevicePluginPhilipsHue::lightStateChanged()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (device->deviceClassId() == hueLightDeviceClassId) {
|
if (device->deviceClassId() == hueLightDeviceClassId) {
|
||||||
device->setStateValue(hueLightReachableStateTypeId, light->reachable());
|
device->setStateValue(hueLightConnectedStateTypeId, light->reachable());
|
||||||
device->setStateValue(hueLightColorStateTypeId, QVariant::fromValue(light->color()));
|
device->setStateValue(hueLightColorStateTypeId, QVariant::fromValue(light->color()));
|
||||||
device->setStateValue(hueLightPowerStateTypeId, light->power());
|
device->setStateValue(hueLightPowerStateTypeId, light->power());
|
||||||
device->setStateValue(hueLightBrightnessStateTypeId, brightnessToPercentage(light->brightness()));
|
device->setStateValue(hueLightBrightnessStateTypeId, brightnessToPercentage(light->brightness()));
|
||||||
device->setStateValue(hueLightColorTemperatureStateTypeId, light->ct());
|
device->setStateValue(hueLightColorTemperatureStateTypeId, light->ct());
|
||||||
device->setStateValue(hueLightHueEffectStateTypeId, light->effect());
|
device->setStateValue(hueLightHueEffectStateTypeId, light->effect());
|
||||||
} else if (device->deviceClassId() == hueWhiteLightDeviceClassId) {
|
} else if (device->deviceClassId() == hueWhiteLightDeviceClassId) {
|
||||||
device->setStateValue(hueWhiteLightHueReachableStateTypeId, light->reachable());
|
device->setStateValue(hueWhiteLightConnectedStateTypeId, light->reachable());
|
||||||
device->setStateValue(hueWhiteLightPowerStateTypeId, light->power());
|
device->setStateValue(hueWhiteLightPowerStateTypeId, light->power());
|
||||||
device->setStateValue(hueWhiteLightBrightnessStateTypeId, brightnessToPercentage(light->brightness()));
|
device->setStateValue(hueWhiteLightBrightnessStateTypeId, brightnessToPercentage(light->brightness()));
|
||||||
}
|
}
|
||||||
@ -549,7 +549,7 @@ void DevicePluginPhilipsHue::remoteStateChanged()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
device->setStateValue(hueRemoteHueReachableStateTypeId, remote->reachable());
|
device->setStateValue(hueRemoteConnectedStateTypeId, remote->reachable());
|
||||||
device->setStateValue(hueRemoteBatteryStateTypeId, remote->battery());
|
device->setStateValue(hueRemoteBatteryStateTypeId, remote->battery());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1204,19 +1204,19 @@ void DevicePluginPhilipsHue::processActionResponse(Device *device, const ActionI
|
|||||||
void DevicePluginPhilipsHue::bridgeReachableChanged(Device *device, const bool &reachable)
|
void DevicePluginPhilipsHue::bridgeReachableChanged(Device *device, const bool &reachable)
|
||||||
{
|
{
|
||||||
if (reachable) {
|
if (reachable) {
|
||||||
device->setStateValue(hueBridgeBridgeReachableStateTypeId, true);
|
device->setStateValue(hueBridgeConnectedStateTypeId, true);
|
||||||
} else {
|
} else {
|
||||||
// mark bridge and corresponding hue devices unreachable
|
// mark bridge and corresponding hue devices unreachable
|
||||||
if (device->deviceClassId() == hueBridgeDeviceClassId) {
|
if (device->deviceClassId() == hueBridgeDeviceClassId) {
|
||||||
device->setStateValue(hueBridgeBridgeReachableStateTypeId, false);
|
device->setStateValue(hueBridgeConnectedStateTypeId, false);
|
||||||
|
|
||||||
foreach (HueLight *light, m_lights.keys()) {
|
foreach (HueLight *light, m_lights.keys()) {
|
||||||
if (light->bridgeId() == device->id()) {
|
if (light->bridgeId() == device->id()) {
|
||||||
light->setReachable(false);
|
light->setReachable(false);
|
||||||
if (m_lights.value(light)->deviceClassId() == hueLightDeviceClassId) {
|
if (m_lights.value(light)->deviceClassId() == hueLightDeviceClassId) {
|
||||||
m_lights.value(light)->setStateValue(hueLightReachableStateTypeId, false);
|
m_lights.value(light)->setStateValue(hueLightConnectedStateTypeId, false);
|
||||||
} else if (m_lights.value(light)->deviceClassId() == hueWhiteLightDeviceClassId) {
|
} else if (m_lights.value(light)->deviceClassId() == hueWhiteLightDeviceClassId) {
|
||||||
m_lights.value(light)->setStateValue(hueWhiteLightHueReachableStateTypeId, false);
|
m_lights.value(light)->setStateValue(hueWhiteLightConnectedStateTypeId, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1224,7 +1224,7 @@ void DevicePluginPhilipsHue::bridgeReachableChanged(Device *device, const bool &
|
|||||||
foreach (HueRemote *remote, m_remotes.keys()) {
|
foreach (HueRemote *remote, m_remotes.keys()) {
|
||||||
if (remote->bridgeId() == device->id()) {
|
if (remote->bridgeId() == device->id()) {
|
||||||
remote->setReachable(false);
|
remote->setReachable(false);
|
||||||
m_remotes.value(remote)->setStateValue(hueRemoteHueReachableStateTypeId, false);
|
m_remotes.value(remote)->setStateValue(hueRemoteConnectedStateTypeId, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
"name": "hueBridge",
|
"name": "hueBridge",
|
||||||
"displayName": "Hue gateway",
|
"displayName": "Hue gateway",
|
||||||
"deviceIcon": "Gateway",
|
"deviceIcon": "Gateway",
|
||||||
"interfaces": ["gateway"],
|
"interfaces": ["gateway", "connectable"],
|
||||||
"basicTags": [
|
"basicTags": [
|
||||||
"Device",
|
"Device",
|
||||||
"Gateway",
|
"Gateway",
|
||||||
@ -80,7 +80,7 @@
|
|||||||
"stateTypes": [
|
"stateTypes": [
|
||||||
{
|
{
|
||||||
"id": "15794d26-fde8-4a61-8f83-d7830534975f",
|
"id": "15794d26-fde8-4a61-8f83-d7830534975f",
|
||||||
"name": "bridgeReachable",
|
"name": "connected",
|
||||||
"displayName": "reachable",
|
"displayName": "reachable",
|
||||||
"displayNameEvent": "reachable changed",
|
"displayNameEvent": "reachable changed",
|
||||||
"defaultValue": false,
|
"defaultValue": false,
|
||||||
@ -145,7 +145,7 @@
|
|||||||
"name": "hueLight",
|
"name": "hueLight",
|
||||||
"displayName": "Hue Light",
|
"displayName": "Hue Light",
|
||||||
"deviceIcon": "LightBulb",
|
"deviceIcon": "LightBulb",
|
||||||
"interfaces": ["colorlight"],
|
"interfaces": ["colorlight", "connectable"],
|
||||||
"basicTags": [
|
"basicTags": [
|
||||||
"Device",
|
"Device",
|
||||||
"Lighting",
|
"Lighting",
|
||||||
@ -217,7 +217,7 @@
|
|||||||
"stateTypes": [
|
"stateTypes": [
|
||||||
{
|
{
|
||||||
"id": "19bb8d10-1b28-4ba3-99b7-a634138dcfde",
|
"id": "19bb8d10-1b28-4ba3-99b7-a634138dcfde",
|
||||||
"name": "reachable",
|
"name": "connected",
|
||||||
"displayName": "reachable",
|
"displayName": "reachable",
|
||||||
"displayNameEvent": "reachable changed",
|
"displayNameEvent": "reachable changed",
|
||||||
"defaultValue": false,
|
"defaultValue": false,
|
||||||
@ -319,7 +319,7 @@
|
|||||||
"name": "hueWhiteLight",
|
"name": "hueWhiteLight",
|
||||||
"displayName": "Hue White Light",
|
"displayName": "Hue White Light",
|
||||||
"deviceIcon": "LightBulb",
|
"deviceIcon": "LightBulb",
|
||||||
"interfaces": ["dimmablelight"],
|
"interfaces": ["dimmablelight", "connectable"],
|
||||||
"basicTags": [
|
"basicTags": [
|
||||||
"Device",
|
"Device",
|
||||||
"Actuator",
|
"Actuator",
|
||||||
@ -391,7 +391,7 @@
|
|||||||
"stateTypes": [
|
"stateTypes": [
|
||||||
{
|
{
|
||||||
"id": "19bb8d10-1b28-4ba3-99b7-a634138dcfde",
|
"id": "19bb8d10-1b28-4ba3-99b7-a634138dcfde",
|
||||||
"name": "hueReachable",
|
"name": "connected",
|
||||||
"displayName": "reachable",
|
"displayName": "reachable",
|
||||||
"displayNameEvent": "reachable changed",
|
"displayNameEvent": "reachable changed",
|
||||||
"defaultValue": false,
|
"defaultValue": false,
|
||||||
@ -449,7 +449,7 @@
|
|||||||
"name": "hueRemote",
|
"name": "hueRemote",
|
||||||
"displayName": "Hue Remote",
|
"displayName": "Hue Remote",
|
||||||
"deviceIcon": "Switch",
|
"deviceIcon": "Switch",
|
||||||
"interfaces": ["longpressmultibutton"],
|
"interfaces": ["longpressmultibutton", "battery", "connectable"],
|
||||||
"basicTags": [
|
"basicTags": [
|
||||||
"Device",
|
"Device",
|
||||||
"Sensor"
|
"Sensor"
|
||||||
@ -519,7 +519,7 @@
|
|||||||
"stateTypes": [
|
"stateTypes": [
|
||||||
{
|
{
|
||||||
"id": "19bb8d10-1b28-4ba3-99b7-a634138dcfde",
|
"id": "19bb8d10-1b28-4ba3-99b7-a634138dcfde",
|
||||||
"name": "hueReachable",
|
"name": "connected",
|
||||||
"displayName": "reachable",
|
"displayName": "reachable",
|
||||||
"displayNameEvent": "reachable changed",
|
"displayNameEvent": "reachable changed",
|
||||||
"defaultValue": false,
|
"defaultValue": false,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user