I’m still new to openhab and I want to perform several actions with one button.
I got my Max! Heater system and my Hue installed, after an instruction I managed to integrate Amazon Alexa.
Now I would like to have a switch with the following functions:
all heaters on 17 degrees and 2 lights off and 1 light on, I would like to connect this with Alexa to switch it on.
Is that even possible and if so, how do I do it best as a beginner?
You could define a switch item that is bound to the button. Then create a rule that is triggered on that switch. IIn the rule You can do whatever needs to be done.
You can work with rules … or if you only want turn on 2 Bulbs with one Switch you can link the item to both bulbs.
I do it with Ikea Tradfri so … 3 GU10 Bulbs with 1 OH2 Item …
Edit: I read your Posting now completely … you need a rule
rule "Actions with One Switch"
when
Item SWITCH_FOR_ACTIONS changed from OFF to ON
then
if (heater.state != 17) heater.sendCommand(17)
if (firstBulb.state != ON) firstBulb.sendCommand(ON)
if (secondBulb.state != OFF) secondBulb.sendCommand(OFF)
SWITCH_FOR_ACTIONS.sendCommand(OFF)
end
Sorry again for my noob questions, am really new to this stuff.
I added in my home.items a switch
$
Switch goodnight "Good Night" [ "Switchable" ]
so in your sample
rule "good night"
when
Item goodnight changed from OFF to ON
then
if (heater.state != 17) heater.sendCommand(17)
if (firstBulb.state != ON) firstBulb.sendCommand(ON)
if (secondBulb.state != OFF) secondBulb.sendCommand(OFF)
goodnight.sendCommand(OFF)
end
So what is the syntax with the “elements”?
I have in paper ui the my Max system for example this is the temperatur for the living room : max:thermostat:KMD1055827:KMD3066852:set_temp
is this right?
if (max:thermostat:KMD1055827:KMD3066852:set_temp != 17) max:thermostat:KMD1055827:KMD3066852:set_temp(17)
and for the Bulbs (Philips Hue) i have no on/off thing only hue:0210:001788606091:3:color
so i have set the Brightness to 0 ?
filename is: goodnight.rules
path: /etc/openhab2/rules
rule "good night"
when
Item goodnight changed from OFF to ON
then
if (max:thermostat:KMD1055827:KMD3066852:set_temp != 17) max:thermostat:KMD1055827:KMD3066852:set_temp(17)
if (max:thermostat:KMD1055827:KMD3069582:set_temp != 17) max:thermostat:KMD1055827:KMD3069582:set_temp(17)
if (max:thermostat:KMD1055827:LEQ1149210:set_temp != 17) max:thermostat:KMD1055827:LEQ1149210:set_temp(17)
goodnight.sendCommand(OFF)
end
I found this Switch in my Amazon Alexa but when i set this to on nothing changes.
Is there a way to add this Switch in Paper UI?
There needs to be { } after the if statement.
if (max:thermostat:KMD1055827:KMD3066852:set_temp != 17) {max:thermostat:KMD1055827:KMD3066852:set_temp(17)}
For Color bulbs:
This section differentiates between command type and state type. For ease of reading, it is possible to simply add “type” to the end of a command type thereby obtaining the state type. For example, a Color Item can receive an OnOffType, IncreaseDecreaseType, PercentType, or HSBType. Therefore the following are all valid commands one can send to a Color Item:
MyColorItem.sendCommand(ON)
MyColorItem.sendCommand(INCREASE)
MyColorItem.sendCommand(new PercentType(50))
MyColorItem.sendCommand(new HSBType(new DecimalType(123), new PercentType(45), new PercentType(67)))
rule "good night"
when
Item goodnight changed from OFF to ON
then
if (max:thermostat:KMD1055827:KMD3066852:set_temp != 17) {max:thermostat:KMD1055827:KMD3066852:set_temp(17)}
if (max:thermostat:KMD1055827:KMD3069582:set_temp != 17) {max:thermostat:KMD1055827:KMD3069582:set_temp(17)}
if (max:thermostat:KMD1055827:LEQ1149210:set_temp != 17) {max:thermostat:KMD1055827:LEQ1149210:set_temp(17)}
goodnight.sendCommand(OFF)
end
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
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.
rule "good night"
when
Item goodnight changed from OFF to ON
then
if (StubeThermostatCurrentTemp != 17) StubeThermostatTargetTemperature.sendCommand(17)
goodnight.sendCommand(OFF)
end
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
ok. so, please go some steps back and we try again from the start.
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' ]
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
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).
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).
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'