Hi all,
I want to show my current solution that I have implemented to have some kind of scenes implemented.
Therefore I use a OperationMode item for each room.
I can set the OperationMode by user input or automatically by another rule.
In this example the light of the guest bathroom is switched on if someone enters the room. Based on the operation mode the light is choosen, for ChillOut and Guest Mode, the cupboard light is switched on. On all other modes, the main light is used. If the no one is in the room anymore, all lights are switched off.
In another room I want to have the motion sensor to not switch the light off on some operation modes,
therefore the Do on leave statement has the operation mode check, too. The ambient light is switched on in another rule that is triggered if the operationmode is set.
uid: blocklibrary_japhias
tags: []
props:
parameters: []
parameterGroups: []
timestamp: Apr 15, 2024, 8:07:44 AM
component: BlockLibrary
config:
name: japhias Block Library
slots:
blocks:
- component: BlockType
config:
type: presenceRule
message0: Presence with brightness limit of %1 in Room %2 Do on entry %3 Do on
leave %4
nextStatement: ""
previousStatement: ""
args0:
- type: input_value
name: brightness
check: Number
- type: input_value
name: presenceItem
- type: input_statement
name: executeOn
- type: input_statement
name: executeOff
inputsInline: true
colour: 90
tooltip: ""
helpUrl: ""
slots:
code:
- component: BlockCodeTemplate
config:
template: if(items.getItem(items.getItem({{input:presenceItem}}).name +
"_Praesenz").state === "ON") {
if(items.getItem(items.getItem({{input:presenceItem}}).name +
"_Helligkeit").state >= {{input:brightness}}) {
{{statements:executeOn}} } } else { {{statements:executeOff}} }
toolbox:
- component: PresetInput
config:
name: presenceItem
shadow: true
type: oh_item
- component: BlockType
config:
type: checkSendCommand
message0: Check and send Command %1 for Item %2
nextStatement: ""
previousStatement: ""
args0:
- type: input_value
name: commandValue
- type: input_value
name: targetItem
inputsInline: true
colour: 90
tooltip: ""
helpUrl: ""
slots:
code:
- component: BlockCodeTemplate
config:
template: log('sendInfo').info("TEST");
if(items.getItem({{input:targetItem}}).state.toString() !=
{{input:commandValue}}) {
items.getItem({{input:targetItem}}).sendCommand({{input:commandValue}})}
toolbox:
- component: PresetInput
config:
name: targetItem
shadow: true
type: oh_item
- component: PresetInput
config:
name: commandValue
shadow: true
type: text
- component: BlockType
config:
type: operationMode
message0: Check Operation Mode of Room %1 contains %2 Do if true %3 Do if false
%4
nextStatement: ""
previousStatement: ""
args0:
- type: input_value
name: room
- type: input_value
name: modeList
- type: input_statement
name: executeTrue
- type: input_statement
name: executeFalse
inputsInline: true
colour: 90
tooltip: ""
helpUrl: ""
slots:
code:
- component: BlockCodeTemplate
config:
template: if({{input:modeList}}.includes(items.getItem(items.getItem({{input:room}}).name
+ "_OperationMode").state)) { {{statements:executeTrue}} } else
{ {{statements:executeFalse}} }
toolbox:
- component: PresetInput
config:
name: room
shadow: true
type: oh_item
utilities:
- component: UtilityJavaType
config:
javaClass: org.openhab.io.openhabcloud.NotificationAction
name: notifications
- component: UtilityJavaType
config:
javaClass: org.openhab.core.model.script.actions.ScriptExecution
name: scriptExecution