- lights, windows, online, heater
The most interesting part are the lights. Windows are basically the same, just simpler. Online devices and heater are not very special. So I focus on highlighting the lights. (YAML-code is everything, though).
- a repeater is used again, so it’s easy to add new lights
- when clicking on a lightbulb, it’s brightess is set to 80
- the number of running lights is derived from an item whose value is calculated with a rule (see below YMAL code)
- similar with the button for switching off all lights.
For some reason, this doesn’t always work like it should. Sometimes I need to press the buttons twice.
YAML-code:
component: oh-list-card
config:
noChevron: true
style:
background: linear-gradient(to bottom,#e6e6e6 0%,#8c8c8c 100%)
slots:
default:
- component: f7-list-item
config:
accordionItem: true
slots:
content:
- component: f7-row
config:
class:
- align-items-center
style:
width: 100%
height: 25px
flex-wrap: nowrap
slots:
default:
- component: f7-col
config:
class:
- display-flex
- flex-direction-row
- align-items-center
- margin-top
- margin-bottom
style:
height: 100%
width: fit-content
min-width: 100px
slots:
default:
- component: oh-button
config:
icon-f7: lightbulb_fill
iconColor: '=(items.AnzahlLampenAn.state === "0") ? "gray" : "yellow"'
style:
--f7-button-bg-color: transparent
--f7-button-hover-bg-color: transparent
--f7-button-pressed-bg-color: transparent
- component: oh-label-item
config:
item: AnzahlLampenAn
- component: f7-col
config:
class:
- display-flex
- align-items-center
- justify-content-flex-end
style:
height: 100%
width: 100%
slots:
default:
- component: oh-list-item
config:
title: Alle aus
action: command
listButton: true
actionItem: AlleLichterAus
actionCommand: ON
color: black
default:
- component: f7-accordion-content
slots:
default:
- component: oh-repeater
config:
sourceType: array
for: devices
in:
- actionitem: LeuchteHuegross_Farbe
label: AZ-H
- actionitem: LeuchteHueklein_Farbe
label: AZ-E
- actionitem: LeuchteMobil_Farbe
label: SZ-M
- actionitem: LeuchteWohnzimmer_Farbe
label: WZ
- actionitem: EsszimmerTisch_Farbe
label: EZ-T
- actionitem: EsszimmerWein_Farbe
label: EZ-W
- actionitem: EsszimmerKlavier_Farbe
label: EZ-K
- actionitem: Frosch_Farbe
label: EZ-F
slots:
default:
- component: f7-list-item
slots:
content:
- component: f7-row
config:
class:
- align-items-center
style:
width: 100%
height: 25px
flex-wrap: nowrap
slots:
default:
- component: f7-col
config:
class:
- display-flex
- flex-direction-row
- align-items-center
- margin-top
- margin-bottom
style:
height: 100%
width: fit-content
min-width: 100px
slots:
default:
- component: oh-button
config:
action: command
actionItem: =loop.devices.actionitem
actionCommand: '=(items[loop.devices.actionitem].state.split(",")[2] === "0") ?
items[loop.devices.actionitem].state.split(",")[0]+
"," +
items[loop.devices.actionitem].state.split(",")[1]
+ ",80" :
items[loop.devices.actionitem].state.split(",")[0]
+ "," +
items[loop.devices.actionitem].state.split(",")[1]
+ ",0"'
icon-f7: lightbulb_fill
iconColor: '=(items[loop.devices.actionitem].state.split(",")[2] === "0") ?
"gray" : "yellow"'
style:
--f7-button-bg-color: transparent
--f7-button-hover-bg-color: transparent
--f7-button-pressed-bg-color: transparent
- component: oh-button
config:
action: popup
actionModal: widget:Widget_farben
actionModalConfig:
leuchte: =loop.devices.actionitem
text: =loop.devices.label
color: blue
style:
--f7-button-bg-color: transparent
--f7-button-hover-bg-color: transparent
--f7-button-pressed-bg-color: transparent
- component: f7-col
config:
class:
- display-flex
- align-items-center
style:
height: 100%
width: 100%
slots:
default:
- component: oh-colorpicker
config:
sliderLabel: true
sliderValue: true
item: =loop.devices.actionitem
modules:
- brightness-slider
- component: f7-list-item
config:
accordionItem: true
slots:
content:
- component: f7-row
config:
class:
- align-items-center
style:
width: 100%
height: 25px
flex-wrap: nowrap
slots:
default:
- component: f7-col
config:
class:
- display-flex
- flex-direction-row
- align-items-center
- margin-top
- margin-bottom
style:
height: 100%
width: fit-content
min-width: 100px
slots:
default:
- component: oh-button
config:
icon-f7: logo_windows
iconColor: '=(items.AnzahlFensterAuf.state === "0") ? "gray" : "red"'
style:
--f7-button-bg-color: transparent
--f7-button-hover-bg-color: transparent
--f7-button-pressed-bg-color: transparent
- component: oh-label-item
config:
item: AnzahlFensterAuf
title: offen
default:
- component: f7-accordion-content
slots:
default:
- component: oh-repeater
config:
sourceType: array
for: devices
in:
- actionitem: WC_Fensterstatus
label: WC
- actionitem: WC_Fensterstatus
label: Weitere XXX
slots:
default:
- component: f7-list-item
slots:
content:
- component: f7-row
config:
class:
- align-items-center
style:
width: 100%
height: 25px
flex-wrap: nowrap
slots:
default:
- component: f7-col
config:
class:
- display-flex
- flex-direction-row
- align-items-center
- margin-top
- margin-bottom
style:
height: 100%
width: fit-content
min-width: 100px
slots:
default:
- component: oh-button
config:
icon-f7: logo_windows
iconColor: '=(items[loop.devices.actionitem].state === "CLOSED") ? "gray" :
"red"'
style:
--f7-button-bg-color: transparent
--f7-button-hover-bg-color: transparent
--f7-button-pressed-bg-color: transparent
- component: oh-button
config:
text: =loop.devices.label
color: blue
style:
--f7-button-bg-color: transparent
--f7-button-hover-bg-color: transparent
--f7-button-pressed-bg-color: transparent
- component: f7-list-item
config:
accordionItem: true
slots:
content:
- component: oh-list-item
config:
title: Geräte Online?
icon: oh:network
height: 25px
default:
- component: f7-accordion-content
slots:
default:
- component: oh-repeater
config:
sourceType: array
for: devices
in:
- icon: network
iconState: HolgerGalaxyNote8_Online
title: Holger-Smartphone
action: page:z_Holger_Smartphone
afterState: HolgerGalaxyNote8_Zuletztgesehen
- icon: network
iconState: HolgerGamingPC_Online
title: Holger-PC
action: page:z_HolgerGamingPC
afterState: HolgerGamingPC_Zuletztgesehen
- icon: network
iconState: HolgerMacBookPro_Online
title: Holger-Mac
action: page:z_HolgerMacBookPro
afterState: HolgerMacBookPro_Zuletztgesehen
- icon: network
iconState: BennetSmartphone_Online
title: Bennet-Phone
action: page:z_BennetSmartphone_Online
afterState: BennetSmartphone_Zuletztgesehen
- icon: network
iconState: BennetPC_Online
title: Bennet-PC
action: page:z_BennetPC_Online
afterState: BennetPC_Zuletztgesehen
- icon: network
iconState: EvaSmartphoneHonor_Online
title: Eva-Phone
action: page:z_EvaSmartphoneHonor_Online
afterState: EvaSmartphoneHonor_Zuletztgesehen
- icon: network
iconState: EvaMariasMacBookPro_Online
title: Eva-Mac
action: page:z_EvaMariasMacBookPro_Online
afterState: EvaMariasMacBookPro_Zuletztgesehen
- icon: network
iconState: FelixSmartphone_Online
title: Felix-Phone
action: page:z_FelixSmartphone_Online
afterState: FelixSmartphone_Zuletztgesehen
- icon: network
iconState: EvasaltesNotebookFELIX_Online
title: FelixEvaPC
action: page:z_EvasaltesNotebookFELIX_Online
afterState: EvasaltesNotebookFELIX_Zuletztgesehen
- icon: network
iconState: FireTV_Online
title: FireTV-Wohn
action: page:z_FireTV_Online
afterState: FireTV_Zuletztgesehen
- icon: network
iconState: XBox1_Online
title: XBox1
action: page:z_XBox1_Online
afterState: XBox1_Zuletztgesehen
- icon: network
iconState: NASArndt_Online
title: NAS
action: page:z_NASArndt_Online
afterState: NASArndt_Zuletztgesehen
fragment: true
slots:
default:
- component: f7-list-item
config:
accordionItem: true
slots:
content:
- component: oh-button
config:
color: gray
class:
- no-padding
- display-flex
- justify-content-flex-start
style:
overflow: hidden
color: var(--f7-block-text-color)
slots:
default:
- component: oh-icon
config:
icon: =loop.devices.icon
state: =items[loop.devices.iconState].state
style:
width: 25px
class:
- margin-right-half
- component: oh-list-item
config:
title: =loop.devices.title
listButton: true
action: popup
actionModal: =loop.devices.action
style:
font-weight: normal
text-overflow: ellipsis
overflow: hidden
after:
- component: oh-button
config:
text: =items[loop.devices.afterState].displayState
color: gray
class:
- no-padding
style:
font-weight: normal
color: var(--f7-block-text-color)
- component: f7-list-item
config:
accordionItem: true
slots:
content:
- component: oh-list-item
config:
accordionItem: true
title: Heizkörper
icon: oh:heating
default:
- component: f7-accordion-content
slots:
default:
- component: oh-repeater
config:
sourceType: array
for: devices
in:
- temp_ist: HeizkorperSchlafzimmer_AktuelleTemperatur
temp_soll: HeizkorperSchlafzimme_Solltemperatur
label: Schlaf
- temp_ist: HeizkorperSchlafzimmer_AktuelleTemperatur
temp_soll: HeizkorperSchlafzimme_Solltemperatur
label: Schlaf XXX
slots:
default:
- component: oh-slider-item
config:
title: =loop.devices.label
subtitle: =items[loop.devices.temp_ist].state
item: =loop.devices.temp_soll
label: true
min: 15
max: 25
scaleSteps: 10
scaleSubSteps: 1
step: 0.5
scale: true
unit: " °C"
rule for calulation of running lights:
triggers:
- id: "2"
configuration:
groupName: Fenster_Alle
type: core.GroupStateChangeTrigger
conditions: []
actions:
- inputs: {}
id: "1"
configuration:
type: application/javascript
script: >-
var logger =
Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' +
ctx.ruleUID);
var Collectors = Java.type("java.util.stream.Collectors");
logger.info("Collectors imported, about to filter the Group members");
var numOnList = ir.getItem("Fenster_Alle")
.members
.stream()
.filter(function(i){
logger.info("Processing Item " + i.name + " whose current state is " + i.state);
var currState = i.getStateAs(OpenClosedType.class);
logger.info(i.name +"'s state is " + currState);
return currState == OPEN;
})
.collect(Collectors.toList());
logger.info("The filter returned the following Items: " + numOnList.toString());
logger.info("There are " + numOnList.size() + " windows that are ON");
events.sendCommand("AnzahlFensterAuf", numOnList.size());
/*
anzahl = 0;
if (items["WC_Fensterstatus"] =="OPEN" ) {anzahl=anzahl+1;}
type: script.ScriptAction
rule to switch lights off (all lights a members of the same group which is addressed here)
triggers:
- id: "2"
configuration:
itemName: AlleLichterAus
state: ON
type: core.ItemStateChangeTrigger
conditions: []
actions:
- inputs: {}
id: "1"
configuration:
type: application/javascript
script: >+
var logger =
Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' +
ctx.ruleUID);
events.sendCommand("Leuchten_Alle",OFF);
type: script.ScriptAction
- Alexa-speach commands
nothing special:
component: oh-list-card
config:
noChevron: true
accordionList: true
style:
background: linear-gradient(to bottom,#e6e6e6 0%,#8c8c8c 100%)
slots:
default:
- component: oh-list-item
config:
title: Alle zum Essen
listButton: true
color: black
action: rule
actionRule: Alexa_Alle_Essen
- component: oh-list-item
config:
title: Bennet zum Essen
listButton: true
color: black
action: rule
actionRule: Alexa_Bennet_Essen
- component: oh-list-item
config:
title: Felix - letztes Spiel
listButton: true
color: black
action: rule
actionRule: Alexa_Felix_Spielende
The buttons call rules which make Alexa devices say something. E.g. call for lunch on all devices (there are different, Alexa groups: All devices, just those on ground floor, …)
triggers: []
conditions: []
actions:
- inputs: {}
id: "1"
configuration:
type: application/javascript
script: |+
ausgabe = "Essen ist gleich fertig, kommt bitte in die Küche!";
events.sendCommand("AlexaAlle_SprichLautstarke","100");
events.sendCommand("AlexaAlle_Sprich",ausgabe);
type: script.ScriptAction
So, that’s basically it. I hope this is of use for some of you. If you have suggestions for improvement (as this is by far not perfect, just good enough in my opinion), feel free to post.