[DOIF]: Neuen Modus in Rollosteuerung eingebaut

Begonnen von maxritti, 03 April 2015, 11:10:43

Vorheriges Thema - Nächstes Thema

flurin

Eine Möglichkeit, solche Logik-Bedingungen zu definieren und zu testen, ist das DOIF aufzuteilen.

Z.B.:


define di_central_heating DOIF (([[tc_begin_am]-[tc_end_am]] and [office_heating] eq "on") or
([[tc_begin_pm]-[tc_end_pm]] and [local_weather:temperature] < 15))
({if (Value("central_heating") ne "on") {fhem("set central_heating on")}})
DOELSE ({if (Value("central_heating") ne "off") {fhem("set central_heating off")}})
attr di_central_heating do always


lässt sich wie folgt aufteilen:


define di_central_heating_cond1 DOIF ([[tc_begin_am]-[tc_end_am]] and [office_heating] eq "on")
attr di_central_heating_cond1 cmdState on|off



define di_central_heating_cond2 DOIF ([[tc_begin_pm]-[tc_end_pm]] and [local_weather:temperature] < 15)
attr di_central_heating_cond2 cmdState on|off



define di_central_heating DOIF ([di_central_heating_cond1] eq "on" or [di_central_heating_cond2] eq "on")
({if (Value("central_heating") ne "on") {fhem("set central_heating on")}})
DOELSE ({if (Value("central_heating") ne "off") {fhem("set central_heating off")}})
attr di_central_heating do always


Damit kann man den Zustand von di_central_heating_cond1 und di_central_heating_cond2 anzeigen und prüfen.
Die Bedingung if (Value("central_heating") ne "on") integriere ich in diesem Fall lieber in perl, das ist klar und verständlich.

Gruss
flurin

maxritti

Zitat von: flurin am 04 April 2015, 12:46:46
Eine Möglichkeit, solche Logik-Bedingungen zu definieren und zu testen, ist das DOIF aufzuteilen.

Z.B.:


define di_central_heating DOIF (([[tc_begin_am]-[tc_end_am]] and [office_heating] eq "on") or
([[tc_begin_pm]-[tc_end_pm]] and [local_weather:temperature] < 15))
({if (Value("central_heating") ne "on") {fhem("set central_heating on")}})
DOELSE ({if (Value("central_heating") ne "off") {fhem("set central_heating off")}})
attr di_central_heating do always


lässt sich wie folgt aufteilen:


define di_central_heating_cond1 DOIF ([[tc_begin_am]-[tc_end_am]] and [office_heating] eq "on")
attr di_central_heating_cond1 cmdState on|off



define di_central_heating_cond2 DOIF ([[tc_begin_pm]-[tc_end_pm]] and [local_weather:temperature] < 15)
attr di_central_heating_cond2 cmdState on|off



define di_central_heating DOIF ([di_central_heating_cond1] eq "on" or [di_central_heating_cond2] eq "on")
({if (Value("central_heating") ne "on") {fhem("set central_heating on")}})
DOELSE ({if (Value("central_heating") ne "off") {fhem("set central_heating off")}})
attr di_central_heating do always


Damit kann man den Zustand von di_central_heating_cond1 und di_central_heating_cond2 anzeigen und prüfen.

Danke Dir für den Tip mit cmdState.
Das habe ich schon ein paar mal gelesen, aber wohl nicht den Nutzen zuordnen können.
Macht jetzt aber Sinn.  ;)

Zitat von: flurin am 04 April 2015, 12:46:46
Die Bedingung if (Value("central_heating") ne "on") integriere ich in diesem Fall lieber in perl, das ist klar und verständlich.

Gruss
flurin

Ich denke auch, dass ich zu dem if wieder übergehen werde.
Ansonsten landet das meist in Fällen, die ich nicht so recht nachvollzogen bekomme.

flurin

#17
Zitat von: maxritti am 04 April 2015, 13:51:24
Ich denke auch, dass ich zu dem if wieder übergehen werde.
Ansonsten landet das meist in Fällen, die ich nicht so recht nachvollzogen bekomme.

Wenn die Logik stimmt und getestet wurde, dann kann man immer noch optimieren. Vermutlich ist mit der Aufteilung-Variante die if-Bedingung überflüssig.