I’ve read and test in the last time so many ideas about a small and readably Szene manger. Actually I’m not happy and it exists a better Approach.
In an other prorgamming language I would create a class with the logic and the needed properties.
I’ve some items in the item file, some variable and the rule in the rules file.
the items file Looks like this
// ------------------------------------------------------------------------------------------------------------------------------------
// S22: Wohnen & Essen
// ------------------------------------------------------------------------------------------------------------------------------------
Switch S22_Automatic "Wohnen & Essen" (Scene_Automatic)
Number S22_Number "Wohnen & Essen [%.0f]" (Scene_Number)
Number S22_Timer "Wohnen & Essen [%.0f]" (Scene_Timer)
// ------------------------------------------------------------------------------------------------------------------------------------
// S23: Küche
// ------------------------------------------------------------------------------------------------------------------------------------
Switch S23_Automatic "Korridor EG" (Scene_Automatic)
Number S23_Number "Korridor EG [%.0f]" (Scene_Number)
Number S23_Timer "Korridor EG [%.0f]" (Scene_Timer)
Switch Motion_S21 "Bad EG" <motion> (scene_motions,Motions_InnenEG) { channel="loxone:miniserver:EEE0009400FE:0D743B76-01CB-7855-FFFFEEE000B8003B" }
Switch Motion_S22_Essen "Essen" <motion> (scene_motions,Motions_Wohnzimmer) { channel="loxone:miniserver:EEE0009400FE:094CCC90-0340-8DAE-FFFFEEE000B8003B" }
Switch Motion_S22_Wohnen "Wohnen" <motion> (scene_motions,Motions_Wohnzimmer) { channel="loxone:miniserver:EEE0009400FE:094CCC90-0340-8DAB-FFFFEEE000B8003B" }
Switch Motion_S23_Eingang "Korridor EG Eingang" <motion> (scene_motions,Motions_KorridorEG) { channel="loxone:miniserver:EEE0009400FE:094CCC90-0341-8DC3-FFFFEEE000B8003B" }
and so on
the rule files has a first part with the definitions and afterward the rules …
// ------------------------------------------------------------------------------------------------------------------------------------
// S31: Korridor UG
// ------------------------------------------------------------------------------------------------------------------------------------
val Number S31_Delay1 = 3 // Nachlauf in Munuten bei Bewegung
val Number S31_Delay2 = 15 // Wenn Scene gewählt
val Boolean S31_Ignore = false // Mückennetz vorhanden, dann berücksichtigen
var Number S31_NumberSave // Scene gespeicher, wenn Fenster geöffnet wird
var Number S31_NumberLast // Letzte gesetzte Szene
var Boolean S31_Enabled // wenn true, so darf die Szene aktiviert werden
// ------------------------------------------------------------------------------------------------------------------------------------
// S32: Gäste
// ------------------------------------------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------------------------------------------
// scene motions received update
// ------------------------------------------------------------------------------------------------------------------------------------
rule "scene motions received update"
when
Item scene_motions received update
then
if (triggeringItem.state == NULL) return; // we don't care about NULL
// if (previousState == NULL) return; // we don't run on changes from the NULL state
logInfo ("Bewegung","Item = {}", Motions.allMembers.sortBy[lastUpdate].last.name + ": " + Motions.allMembers.sortBy[lastUpdate].last.label )
val _room = Motions.allMembers.sortBy[lastUpdate].last.name.split("_").get(1)
val _automatic = Scene_Automatic.allMembers.filter(s|s.name == _room+"_Automatic").head
val _timer = Scene_Timer.allMembers.filter(s|s.name == _room+"_Timer").head
//val _delay1 = Scene_Delay1.allMembers.filter(s|s.name == _room+"_Delay1").head
if (_automatic!==null &&_timer!==null) { //&& _delay1!=NULL
if (_automatic.state==ON) {
logInfo ("Test","Automatik ein = {}", Motions.allMembers.sortBy[lastUpdate].last.name + ": " + Motions.allMembers.sortBy[lastUpdate].last.label )
......
}
}
end
What is best Praxis? How can I handle the variable in the same way, because they arn’t in any Groups. Make it sence to work wotjh hashmaps?
many thanks for any good idea.