UI 无法控制飞利浦 Hue Color 灯泡

The UI can't control the Philips Hue Color lightbulb

我正在尝试让 OpenHAB 控制飞利浦 Hue Color 灯泡。我在一些文件中使用了朋友的帮助,但是仍然无法使用 UI 来控制它。这是 pi@raspberrypi:/opt/openhab/configurations/sitemaps $ vim iotpi.sitemap 中存在的内容:

sitemap demo label="Main Menu"
{

        Frame label="Lights" {
                Switch         item=Toggle_1                                label="Garage"
                Colorpicker    item=Color_1    visibility=[Toggle_1==ON]    label="Garage Light Color"
                Slider         item=Dimm_1     visibility=[Toggle_1==ON]    label="Garage Brightness"
                Slider         item=CT_Dimm_1  visibility=[Toggle_1==ON]    label="Garage Color Temperature"
        }  
} 

pi@raspberrypi:/opt/openhab/configurations/rules $ vim iotpi.rules 中存在以下内容:

import org.openhab.core.library.types.*
import org.openhab.model.script.actions.*
import org.openhab.core.persistence.*



//var DecimalType hue = new DecimalType(240) // 0-360; 0=red, 120=green, 240=blue, 360=red(again)
//var PercentType sat = new PercentType(100) // 0-100
//var PercentType bright = new PercentType(100) // 0-100
//var HSBType light = new HSBType(hue,sat,bright)


rule "Garage Light"
when
    Item Toggle_1 received command
then
    if(receivedCommand==ON) {
        sendCommand(Toggle_1, ON)
        //sendHttpGetRequest("http://<ip_address>/cgi-bin/do?cmd=ir_code&ir_code=A05FBF00")
    } else if(receivedCommand==OFF) {
        // turn off Dune HD and AVR
        //sendHttpGetRequest("http://<ip_address>/cgi-bin/do?cmd=ir_code&ir_code=A15EBF00")
        sendCommand(Toggle_1, OFF)
    }
end

这是我的 pi@raspberrypi:/opt/openhab/configurations/items $ vi iotpi.items 中存在的内容:

Switch Toggle_1   "Garage bulb"   (Switching) {hue="3"}
Color Color_1     "Garage bulb"   (Colorize)  {hue="1"}
Dimmer Dimm_1     "Garage bulb"   (WhiteDimmer)   {hue="1;brightness;30"}
Dimmer CT_Dimm_1      "Garage bulb"   (CTDimmer)  {hue="1;colorTemperature;30"}

此外,我在 configuration 文件夹中的 openhab.cfgopenhab_default.cfg 文件中都有以下内容:

hue:ip=192.168.1.105
hue:secret=openHABRuntime
hue:refresh=10000

我不确定缺少哪些部分以及为什么色调无法由 Raspberry Pi 2 模型 B 上 运行 的 OpenHAB UI 控制。

当我浏览 Pi IP 时,以下内容会在我不打扰的情况下切换,我不确定是谁在向 UI 发送 ON/OFF 命令,因为它每隔几秒就会更改一次,而不会受到我的打扰。

这是 openhab log 文件夹中的 events.log 显示的内容:

2016-03-22 23:39:40 - Toggle_1 received command ON
2016-03-22 23:39:40 - Toggle_1 received command ON
2016-03-22 23:39:40 - Toggle_1 received command ON
2016-03-22 23:39:40 - Toggle_1 received command ON
2016-03-22 23:39:40 - Toggle_1 received command ON
2016-03-22 23:39:40 - Toggle_1 received command ON
2016-03-22 23:39:40 - Toggle_1 received command ON
2016-03-22 23:39:40 - Toggle_1 received command ON
2016-03-22 23:39:40 - Toggle_1 received command ON
2016-03-22 23:39:40 - Toggle_1 received command ON
2016-03-22 23:39:41 - Toggle_1 received command ON
2016-03-22 23:39:41 - Toggle_1 received command ON
2016-03-22 23:39:41 - Toggle_1 received command ON
2016-03-22 23:39:41 - Toggle_1 received command ON
2016-03-22 23:39:41 - Toggle_1 received command ON
2016-03-22 23:39:41 - Toggle_1 received command ON
2016-03-22 23:39:41 - Toggle_1 received command ON
2016-03-22 23:39:41 - Toggle_1 received command ON
2016-03-22 23:39:41 - Toggle_1 received command ON
2016-03-22 23:39:41 - Toggle_1 received command OFF
2016-03-22 23:39:41 - Toggle_1 received command ON
2016-03-22 23:39:41 - Toggle_1 received command OFF
2016-03-22 23:39:41 - Toggle_1 received command OFF
2016-03-22 23:39:41 - Toggle_1 received command OFF
2016-03-22 23:39:41 - Toggle_1 received command OFF
2016-03-22 23:39:41 - Toggle_1 received command OFF

这是来自另一个日志文件的几行 2016_03_22.request.log:

0:0:0:0:0:0:0:1 -  -  [22/Mar/2016:23:40:41 +0000] "GET /openhab.app?sitemap=iotpi&poll=true&__async=true&__source=waHome HTTP/1.1" 200 2310
0:0:0:0:0:0:0:1 -  -  [22/Mar/2016:23:40:42 +0000] "GET /openhab.app?sitemap=iotpi&poll=true&__async=true&__source=waHome HTTP/1.1" 200 1925
0:0:0:0:0:0:0:1 -  -  [22/Mar/2016:23:40:43 +0000] "GET /openhab.app?sitemap=iotpi&poll=true&__async=true&__source=waHome HTTP/1.1" 200 644
0:0:0:0:0:0:0:1 -  -  [22/Mar/2016:23:40:43 +0000] "GET /openhab.app?sitemap=iotpi&poll=true&__async=true&__source=waHome HTTP/1.1" 200 644
0:0:0:0:0:0:0:1 -  -  [22/Mar/2016:23:40:44 +0000] "GET /openhab.app?sitemap=iotpi&poll=true&__async=true&__source=waHome HTTP/1.1" 200 644
0:0:0:0:0:0:0:1 -  -  [22/Mar/2016:23:40:44 +0000] "GET /openhab.app?sitemap=iotpi&poll=true&__async=true&__source=waHome HTTP/1.1" 200 644
0:0:0:0:0:0:0:1 -  -  [22/Mar/2016:23:40:45 +0000] "GET /openhab.app?sitemap=iotpi&poll=true&__async=true&__source=waHome HTTP/1.1" 200 644
0:0:0:0:0:0:0:1 -  -  [22/Mar/2016:23:40:45 +0000] "GET /openhab.app?sitemap=iotpi&poll=true&__async=true&__source=waHome HTTP/1.1" 200 644
0:0:0:0:0:0:0:1 -  -  [22/Mar/2016:23:40:46 +0000] "GET /openhab.app?sitemap=iotpi&poll=true&__async=true&__source=waHome HTTP/1.1" 200 644
0:0:0:0:0:0:0:1 -  -  [22/Mar/2016:23:40:47 +0000] "GET /openhab.app?sitemap=iotpi&poll=true&__async=true&__source=waHome HTTP/1.1" 200 644
0:0:0:0:0:0:0:1 -  -  [22/Mar/2016:23:40:47 +0000] "GET /openhab.app?sitemap=iotpi&poll=true&__async=true&__source=waHome HTTP/1.1" 200 644
0:0:0:0:0:0:0:1 -  -  [22/Mar/2016:23:40:48 +0000] "GET /openhab.app?sitemap=iotpi&poll=true&__async=true&__source=waHome HTTP/1.1" 200 644
0:0:0:0:0:0:0:1 -  -  [22/Mar/2016:23:40:48 +0000] "GET /openhab.app?sitemap=iotpi&poll=true&__async=true&__source=waHome HTTP/1.1" 200 644
0:0:0:0:0:0:0:1 -  -  [22/Mar/2016:23:40:49 +0000] "GET /openhab.app?sitemap=iotpi&poll=true&__async=true&__source=waHome HTTP/1.1" 200 2310

最后:

pi@raspberrypi:/opt/openhab/logs $ vi openhab.log 

2016-03-22 23:35:07.415 [INFO ] [.o.core.internal.CoreActivator] - openHAB runtime has been started (v1.8.1).
2016-03-22 23:35:14.419 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - mDNS service has been started
2016-03-22 23:35:14.606 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - Service Discovery initialization completed.
2016-03-22 23:35:21.676 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'demo.script'
2016-03-22 23:35:23.349 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'rrd4j.persist'
2016-03-22 23:35:23.484 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'logging.persist'
2016-03-22 23:35:23.550 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'db4o.persist'
2016-03-22 23:35:23.586 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'exec.persist'
2016-03-22 23:35:23.736 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'iotpi.items'
2016-03-22 23:35:23.872 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'demo.items'
2016-03-22 23:35:34.028 [INFO ] [penhab.io.rest.RESTApplication] - Started REST API at /rest
2016-03-22 23:35:34.783 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'demo.sitemap'
2016-03-22 23:35:35.405 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'iotpi.sitemap'
2016-03-22 23:35:35.459 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'buiten.sitemap'
2016-03-22 23:35:39.918 [INFO ] [.o.u.w.i.servlet.WebAppServlet] - Started Classic UI at /classicui/openhab.app
2016-03-22 23:35:46.003 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'zwave.rules'
2016-03-22 23:35:46.977 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'demo.rules'
2016-03-22 23:36:04.466 [WARN ] [.o.c.p.e.PersistenceExtensions] - There is no queryable persistence service registered with the name 'rrd4j'
2016-03-22 23:36:04.478 [ERROR] [m.r.internal.engine.RuleEngine] - Error during the execution of startup rule 'Update max and min temperatures': cannot invoke method public abstract org.openhab.core.types.State org.openhab.core.persistence.HistoricItem.getState() on null
2016-03-22 23:36:04.494 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'iotpi.rules'
2016-03-22 23:36:04.610 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'hue.rules'
2016-03-22 23:36:04.869 [INFO ] [.service.AbstractActiveService] - NTP Refresh Service has been started
2016-03-22 23:36:05.021 [INFO ] [.service.AbstractActiveService] - HTTP Refresh Service has been started
2016-03-22 23:36:06.127 [INFO ] [.p.rrd4j.internal.RRD4jService] - Removing invalid defintion component = null heartbeat = 0 min/max = 0.0/0.0 step = 0 0 archives(s) = [] 0 items(s) = []
2016-03-22 23:36:12.314 [INFO ] [.service.AbstractActiveService] - Hue Refresh Service has been started
2016-03-22 23:36:13.497 [INFO ] [g.openhab.model.script.Weather] - Temperature evolved of 0 degrees.
~                                                                                                       

这是这个问题中描述的最新 OpenHAB 的 link 到我的 github: https://github.com/lamiastella/OpenHAB

通过删除规则目录中的 iotpi.rules 解决了问题。它导致了切换。但是我仍然无法使用 UI.

控制 philips hue

更新:我使用了一个 hack,它正在更改密钥并再次 运行 它,然后再次将 hue 与 openhab 配对。不知何故色调配对丢失了!