Multiple Actions with on Button

Expand the Channel to see the linked item.

should read
if (StubeThermostatTargetTemperature.state != 17) {StubeThermostatTargetTemperature.sendCommand(17)}

Okay no error now but the temperatur dosent change.

in the events.log

2017-11-17 17:59:10.782 [ItemStateChangedEvent ] - goodnight changed from NULL to ON
2017-11-17 17:59:43.232 [ItemCommandEvent ] - Item ‘goodnight’ received command ON

The term you need to use here is “Items”.

http://docs.openhab.org/concepts/items.html
http://docs.openhab.org/configuration/items.html

No. You need to define Items that link to a Channel on a Thing. Then in your sitemap and in your Rules you use the Item.

http://docs.openhab.org/concepts/index.html

No, once you link the color channel of that Bulb to a Color Item, as documented in the links above, the Color Item will accept ON/OFF commands so you can use sendCommand(OFF).

No, PaperUI is intended to be an Administration Interface. You need to create a sitemap or habpanel and put your Items on that. These are intended to be the Uers Interfaces for your automation.

I think you would benefit from the Beginner’s Tutorial.

http://docs.openhab.org/tutorials/beginner/index.html

rule "good night"
when
  Item goodnight changed from OFF to ON
then
    if (StubeThermostatCurrentTemp != 17) StubeThermostatTargetTemperature.sendCommand(17)
    goodnight.sendCommand(OFF)
end

Take the Linked Items… than it works :slight_smile:

Hmm doesent work :frowning:

i change it to:

rule "good night"
when
  Item goodnight changed from OFF to ON
then
	if (StubeThermostatCurrentTemp != 17) StubeThermostatTargetTemperature.sendCommand(17)
	if (BadThermostatCurrentTemp != 17) BadThermostatTargetTemperature.sendCommand(17)
	if (KuecheThermostatCurrentTemp != 17) KuecheThermostatTargetTemperature.sendCommand(17)
    goodnight.sendCommand(OFF)
end

i get no error in the logs and in event.log is see
2017-11-18 09:43:24.022 [ItemCommandEvent ] - Item ‘goodnight’ received command ON

but nothing happend.

ok. so, please go some steps back and we try again from the start. :wink:

  1. You need to define an item, which is not bound to a binding, it functions just as a means to enable your good-night Actions

in your home.items it should read:

Switch goodnight "Good Night" [ 'Switchable' ]
  1. Then you need to put some rules in place, which will be run, if the switch is triggered

in your goodnight.rules it should read:

rule "good night"
when
	Item goodnight changed from OFF to ON
then
	// log the item change to openhab.log
	logInfo("Good Night", "Good Night switched changed to" + goodnight.state)
	goodnight.sendCommand(OFF)
end
  1. Put your items in a sitemap for a clear view

create or edit your goodnight.sitemap

sitemap goodnight label="Test goodnight"
{
	Frame label="Test for goodnight items" {
		Text item=StubeThermostatCurrentTemp icon="temperature"	// current-Temperature for Stube
		Setpoint item=StubeThermostatTargetTemperature minValue=5 maxValue=28 step=0.1	// set-Temperature for Stube
		Text item=BadThermostatCurrentTemp icon="temperature"	// current-Temperature for Stube
		Setpoint item=BadThermostatTargetTemperature minValue=5 maxValue=28 step=0.1	// set-Temperature for Stube
		Text item=KuecheThermostatCurrentTemp icon="temperature"	// current-Temperature for Stube
		Setpoint item=KuecheThermostatTargetTemperature minValue=5 maxValue=28 step=0.1	// set-Temperature for Stube
		switch item=goodnight label="goodnight switch"	// good-night Switch for all
	}
}

you should now have all your items for goodnight at a glance in BasicUI (come back to us, if you don’t have BasicUI or don’t know, what that is).

  1. you can now test the Switch either via Alexa or via the UI
    it should immediately change the item states in the UI and tells you so in the events.log. in openhab.log there should be the “logInfo” log entry present.

please post the events.log and openhab.log from your Tests (beginning with opening the UI and clicking on the switch).

Thx for your help, i struggle to get the sitemap working.

i created in /etc/openhab2/sitemaps a sitemap called goodnight.sitemap
and ad your code.

In Paper Ui Settings i add the Sitemap

But under Basic UI there are no Sitemaps shown

openhab.log have so errors

2017-11-18 10:29:55.061 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'goodnight.sitemap' has errors, therefore ignoring it: [10,3]: no viable alternative at input 'switch'
[12,2]: missing EOF at 'sitemap'

2017-11-18 10:29:55.130 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'goodnight.sitemap' has errors, therefore ignoring it: [10,3]: no viable alternative at input 'switch'
[12,2]: missing EOF at 'sitemap'

2017-11-18 10:42:51.348 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'goodnight.sitemap' has errors, therefore ignoring it: [1,1]: missing 'sitemap' at 'rule'
[1,6]: mismatched input '"good night"' expecting '{'

2017-11-18 10:43:25.290 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'goodnight.sitemap' has errors, therefore ignoring it: [10,3]: no viable alternative at input 'switch'

2017-11-18 10:43:25.362 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'goodnight.sitemap' has errors, therefore ignoring it: [10,3]: no viable alternative at input 'switch'

It should be be Switch item= with capital “S” in goodnight.sitemap.

And did you save your rule file in sitemaps or vice versa?

1 Like

S in switch wars the Problem :wink:

When i trigger the Switch in get in

events.log

2017-11-18 12:20:16.833 [ItemCommandEvent ] - Item ‘goodnight’ received command ON
2017-11-18 12:20:16.846 [ItemStateChangedEvent ] - goodnight changed from NULL to ON

openhab.log

2017-11-18 12:18:48.010 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘goodnight.sitemap’

the Rules File is in

/etc/openhab2/rules

Ok - sorry for the typo! :wink:
please try multiple times - your rule should fire the next round.

you could also change the rule

rule "good night"
when
	Item goodnight changed to ON
then
	// log the item change to openhab.log
	logInfo("Good Night", "Good Night switched changed to" + goodnight.state)
	goodnight.sendCommand(OFF)
end

now it should fire everytime.
Explanation: at first run of either OH2 (re)starting or item reloading (everytime an .items file is changed, the whole items get initialized again by design) the state of “goodnight” is not OFF, but NULL (or UNDEF).

Now if your rule file is loaded and working, after triggering “goodnight” switch there should be a line saying something like

blaablaablaa [INFO] Good Night switched changed to ON

and the switch should change straight back to OFF

Are you seeing anything like this?

Thx so much for your Help guys :slight_smile:

So now it works (after the second “switch” :wink: )

event.log

2017-11-18 12:34:40.453 [ItemCommandEvent ] - Item ‘goodnight’ received command OFF
2017-11-18 12:34:40.467 [ItemStateChangedEvent ] - goodnight changed from ON to OFF
2017-11-18 12:34:41.686 [ItemCommandEvent ] - Item ‘goodnight’ received command ON
2017-11-18 12:34:41.712 [ItemStateChangedEvent ] - goodnight changed from OFF to ON
2017-11-18 12:34:42.145 [ItemCommandEvent ] - Item ‘goodnight’ received command OFF
2017-11-18 12:34:42.160 [ItemStateChangedEvent ] - goodnight changed from ON to OFF
2017-11-18 12:34:43.306 [ItemCommandEvent ] - Item ‘goodnight’ received command ON
2017-11-18 12:34:43.319 [ItemStateChangedEvent ] - goodnight changed from OFF to ON
2017-11-18 12:34:43.356 [ItemCommandEvent ] - Item ‘goodnight’ received command OFF
2017-11-18 12:34:43.368 [ItemStateChangedEvent ] - goodnight changed from ON to OFF

So now i need the syntax for the Thermostate and later for my lights :slight_smile:

PS: I think you have a bit of a potential bug in here.

  • StubeThermostatCurrentTemp = the actual Temperature returned from the thermometer within your device.
  • StubeThermostatTargetTemperature = the set Temperature, your Thermostat is set to reach

if for some reason, the room is heated (e.g. cooking in the kitchen or sun in the living room) and the current temperature is above 17°C, your rule won’t change the set temperature. So judging from your use case, I would either compare the set temperature (if your device and the binding are capable of showing it), or nevertheless change the set temperature to 17, regardless of the actual room temperature?

Yeah, I don’t want to be dependentcies in this case.

The thermostats should be set to 17 degrees Celsius and all lamps should be switched off and the lamp in the bedroom turned on.

glad, it worked out now!
the syntax for your thermostat should work as you configured this in PaperUI (see screenshot). The lights (if they’re Hue lights) work the same way and you can adress your lights in rules as we did just with your set temperature.
Your linked item in PaperUI is exactly the item syntax you can use in rules. If you want your lights off in the goodnight rule, just use “sendcommand” with OFF as you did with the goodnight state.
so, if you like, the rule could read:

rule "good night"
when
	Item goodnight changed to ON
then
	// log the item change to openhab.log
	logInfo("Good Night", "Good Night switched changed to" + goodnight.state)

	// turning lights off
	StubeHuelight.sendCommand(OFF)
	KuecheHuelight.sendCommand(OFF)

	// bathroom light on
	BadHuelight.sendCommand(ON)

	// heating set temp to 17
	StubeThermostatTargetTemperature.sendCommand(17)
	BadThermostatTargetTemperature.sendCommand(17)
	KuecheThermostatTargetTemperature.sendCommand(17)

	// sending goodnight to OFF again
	goodnight.sendCommand(OFF)
end

So, this is of course, if you link your Hue lights items in the three rooms to the respective names.

Just one more thing: What do you want to do with the “goodnight” item afterwards? right now the state will immediately Change to OFF again after the rule is finished. If you’d like to have some logic later on, I recommend having a “goodnight” item with OFF until either you set it to ON again (e.g. also via alexa) in the morning or you have a Little cron-based rule, which turns goodnight on at 6am or whatever time you like.

Now it works fine thx again for all your help.

This command is simple my “go to bed setup”.
In the Morning i have a Alexa Routine “she” switch the Light on in Bedroom and read the news, the Heating have an Automatic program.

Maybe i have more Ideas in the future.

At next i wanne buy some sockets for my tv, add my Kodi and but i think thats not possible i wanne start my Andorid tv and start the kodi app.

If you have Sony android tv like i do then i suggest to take a look in here: Sony Devices Binding

I think it’s not good to switch your tv on and off by controlling power outlets. With newer tvs there’s a possibility to control them through http binding or maybe exec binding using scripts. You can find lots of information on this forum. Search is your friend :wink:

I have a Philips Android TV and it seems ther ist no “easy way” to controll it.