I playing with openhab and connected some color bulbs to it and I’m able to change the color as expected.
Now I want to connect the color with the temperature outside. But of course this should only be activated on demand. So I added a Item without a hardware component like.
Switch lightTemperature "Activate temperature ambient light"
I initialize (or at least I think so) this item with OFF with a rule on system started event.
Now I click the switch in the sitemap and get an exception.
org.openhab.core.items.ItemNotFoundException: Item 'null' could not be found in the item registry
at org.openhab.core.internal.items.ItemRegistryImpl.getItem(ItemRegistryImpl.java:80) ~[na:na]
at org.openhab.ui.internal.items.ItemUIRegistryImpl.getItem(ItemUIRegistryImpl.java:554) ~[na:na]
at org.openhab.ui.webapp.internal.render.SwitchRenderer.renderWidget(SwitchRenderer.java:57) ~[org.openhab.ui.webapp_1.7.1.jar:na]
at org.openhab.ui.webapp.internal.render.PageRenderer.renderWidget(PageRenderer.java:158) [org.openhab.ui.webapp_1.7.1.jar:na]
at org.openhab.ui.webapp.internal.render.PageRenderer.processChildren(PageRenderer.java:121) [org.openhab.ui.webapp_1.7.1.jar:na]
at org.openhab.ui.webapp.internal.render.PageRenderer.processChildren(PageRenderer.java:138) [org.openhab.ui.webapp_1.7.1.jar:na]
at org.openhab.ui.webapp.internal.render.PageRenderer.processPage(PageRenderer.java:86) [org.openhab.ui.webapp_1.7.1.jar:na]
...
What’s wrong? How can I add a dummy switch correctly.
okay, so here’s the rules file. The sitemap is really boring at that point. To not spam the conversation, I add it later if the rules are not sufficient.
import org.openhab.core.library.types.*
import org.openhab.model.script.actions.*
rule licht_anpassen
when
Item OutdoorTemp received update or
Item lightTemperature changed from OFF to ON
then
if ( lightTemperature.state == ON ) {
logInfo("lightTemperature", "active")
var DecimalType hueNum = OutdoorTemp.state as DecimalType
var DecimalType hue = new DecimalType(hueNum * 10 + 50)
var PercentType sat = new PercentType ( 70 ) // 0-100
var PercentType bright = new PercentType ( 50 ) // 0-100
var HSBType light = new HSBType ( hue , sat , bright )
sendCommand ( HueColor_1 ,light )
sendCommand ( HueColor_2 ,light )
sendCommand ( HueColor_3 ,light )
}
end
rule initLightTemperatureSwitch
when
System started
then
postUpdate(lightTemperature, OFF)
end
I don’t think this is the cause of the stack trace, but you should trigger on “received command ON” instead of “changed from OFF to ON”, and then use the provided receivedCommand variable in the body.
I do wonder if there is a typo on or near the Switch item=lightTemperature line in the sitemap.