Dummy Switch without a hardware thing

Hi all,

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.

Looking forward to get your input.

I do dummy switches all the time on 1.7.0 for reasons articulated here:

General format I use is this:

sw_LIGHT_Kitchen_PROXY “Kitchen Light Proxy”

Similar to yours, although I do declare the “light”…try that

Please share your rule and sitemap as well in order to see possible causes.

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 
    Item OutdoorTemp received update or 
    Item lightTemperature changed from OFF to ON
    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 ) 

rule initLightTemperatureSwitch 
    System started
    postUpdate(lightTemperature, OFF)

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.

Okay, thanks. I’ll change that.

This evening, I’ll check the sitemap and if nothing special appears I’ll post it here :smile:

So, now it works. @watou you’re right the problem was the sitemap.

Quotes around the item :unamused:

Don’t try this at home:

Switch item="lightTemperature"

Thanks for your help

I assume you didn’t use the openHAB Designer? This kind of syntax errors are easier to debug with it …

@teichsta can you please have a look at this related question? https://github.com/openhab/openhab/issues/4325