用户界面无法控制飞利浦Hue Color灯泡

时间:2016-03-22 23:43:58

标签: java rest http post openhab

我正在努力让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"}

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

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

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

当我浏览Pi IP时,如果没有我中断,以下切换,我不确定是谁向UI发送ON / OFF命令,因为它每隔几秒就会更改而不会中断。 enter image description here

enter image description here

这是events.log openhab文件夹中的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的github的链接: https://github.com/lamiastella/OpenHAB

1 个答案:

答案 0 :(得分:0)

通过删除rules目录中的iotpi.rules解决了该问题。这导致了切换。但是我仍然无法使用UI控制飞利浦色调。

更新:我使用了一个黑客,它正在更改密钥并再次运行它,然后再次与openhab配对。不知怎的,色调配对丢失了!