Skip to content

Commit cbdf225

Browse files
committed
combine from/to battery/grid
-combine from/to battery/grid -removed invert Battery as it is no longer needed -improve toHouse calculation -option to include/exclude Battery in toHouse calculation
1 parent c1c322c commit cbdf225

1 file changed

Lines changed: 55 additions & 53 deletions

File tree

Fritzfon-solar.json

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"y": 140,
1212
"wires": [
1313
{
14-
"id": "96c080c3c196de2a"
14+
"id": "63fc5dfacf242fc0"
1515
}
1616
]
1717
}
@@ -115,15 +115,15 @@
115115
},
116116
{
117117
"l": {
118-
"en-US": "ToBattery",
119-
"de": "Zu Batterie"
118+
"en-US": "ToBattery (To/From combined)",
119+
"de": "Zu Batterie (Zu/Von kombiniert)"
120120
},
121121
"v": "ToBattery"
122122
},
123123
{
124124
"l": {
125-
"en-US": "Battery%+ToBattery",
126-
"de": "Battery% + Zu Batterie"
125+
"en-US": "Battery%+ToBattery (To/From combined)",
126+
"de": "Battery% + Zu Batterie (Zu/Von kombiniert)"
127127
},
128128
"v": "B%+ToBattery"
129129
},
@@ -196,6 +196,37 @@
196196
}
197197
}
198198
},
199+
{
200+
"name": "ToHouseIncludeBattery",
201+
"type": "str",
202+
"value": "Yes",
203+
"ui": {
204+
"icon": "font-awesome/fa-battery",
205+
"label": {
206+
"de": "Zu Haus",
207+
"en-US": "To house"
208+
},
209+
"type": "select",
210+
"opts": {
211+
"opts": [
212+
{
213+
"l": {
214+
"de": "Mit Batterie",
215+
"en-US": "include Battery"
216+
},
217+
"v": "Yes"
218+
},
219+
{
220+
"l": {
221+
"de": "Ohne Batterie",
222+
"en-US": "exclude Battery"
223+
},
224+
"v": "No"
225+
}
226+
]
227+
}
228+
}
229+
},
199230
{
200231
"name": "3. multi icon",
201232
"type": "str",
@@ -207,8 +238,8 @@
207238
"opts": [
208239
{
209240
"l": {
210-
"en-US": "FromGrid",
211-
"de": "Von Netz"
241+
"en-US": "FromGrid (From/To combined)",
242+
"de": "Von Netz (Von/Zu kombiniert)"
212243
},
213244
"v": "FromGrid"
214245
},
@@ -396,35 +427,6 @@
396427
}
397428
}
398429
},
399-
{
400-
"name": "To battery input",
401-
"type": "str",
402-
"value": "NotInverted",
403-
"ui": {
404-
"label": {
405-
"de": "Zu Batterie eingang"
406-
},
407-
"type": "select",
408-
"opts": {
409-
"opts": [
410-
{
411-
"l": {
412-
"de": "Nicht invertiert",
413-
"en-US": "Not Inverted"
414-
},
415-
"v": "NotInverted"
416-
},
417-
{
418-
"l": {
419-
"de": "Invertiert",
420-
"en-US": "Inverted"
421-
},
422-
"v": "Inverted"
423-
}
424-
]
425-
}
426-
}
427-
},
428430
{
429431
"name": "Grid cost €/kWh",
430432
"type": "num",
@@ -718,7 +720,7 @@
718720
],
719721
"meta": {
720722
"module": "@gitmacer/node-red-fritzsolardisplay",
721-
"version": "2.1.4",
723+
"version": "2.2.2",
722724
"author": "Tim Oberle",
723725
"desc": "Show your current (solar) power information on your Fritzfon",
724726
"keywords": "energy,live,image,bild,solar,display,monitor,avm,fritzbox,fritzfon,power,meter,usage,phone,webcam,c5,c6,anzeige,photovoltaik,solaranzeige,gitmacer"
@@ -740,7 +742,7 @@
740742
"initialize": "",
741743
"finalize": "",
742744
"libs": [],
743-
"x": 1810,
745+
"x": 1770,
744746
"y": 140,
745747
"wires": [
746748
[
@@ -759,7 +761,7 @@
759761
"initialize": "",
760762
"finalize": "",
761763
"libs": [],
762-
"x": 1560,
764+
"x": 1520,
763765
"y": 140,
764766
"wires": [
765767
[
@@ -829,7 +831,7 @@
829831
"initialize": "",
830832
"finalize": "",
831833
"libs": [],
832-
"x": 1220,
834+
"x": 1180,
833835
"y": 140,
834836
"wires": [
835837
[
@@ -848,7 +850,7 @@
848850
"initialize": "",
849851
"finalize": "",
850852
"libs": [],
851-
"x": 860,
853+
"x": 820,
852854
"y": 140,
853855
"wires": [
854856
[
@@ -861,13 +863,13 @@
861863
"type": "function",
862864
"z": "774cc0ad6b18a8e3",
863865
"name": "calculate toHouse",
864-
"func": "if (msg.solarUnit == \"W\" && msg.fromGridUnit == \"W\" && msg.toHouse === undefined && Number.isFinite(msg.solar) && Number.isFinite(msg.fromGrid)) {\n if (msg.fromGrid < 0){\n msg.toHouse = msg.solar + msg.fromGrid;\n }\n else{\n msg.toHouse = msg.solar\n }\n \n if (msg.toBattery > 0 && Number.isFinite(msg.toBattery)) {\n msg.toHouse = msg.toHouse - msg.toBattery;\n }\n msg.toHouseUnit = \"W\";\n}\nelse if (msg.solarUnit == \"kWh\" && msg.toGridUnit == \"kWh\" && msg.toHouse === undefined && Number.isFinite(msg.solar) && Number.isFinite(msg.toGrid))\n{\n msg.toHouse = msg.solar - msg.toGrid;\n msg.toHouseUnit = \"kWh\";\n}\nelse if (msg.solarUnit == \"€\" && msg.toGridUnit == \"€\" && msg.toHouse === undefined && Number.isFinite(msg.solar) && Number.isFinite(msg.toGrid)) {\n msg.toHouse = msg.solar - msg.toGrid;\n msg.toHouseUnit = \"€\";\n}\nreturn msg;",
866+
"func": "let includeBattery = env.get(\"ToHouseIncludeBattery\") == \"Yes\";\n\nif (msg.solarUnit == \"W\" && msg.fromGridUnit == \"W\" && msg.toHouse === undefined && Number.isFinite(msg.solar) && Number.isFinite(msg.fromGrid)) {\n msg.toHouse = msg.solar\n\n if (msg.toHouse < 0) {\n msg.toHouse = 0;\n }\n\n if (includeBattery && msg.toHouse > msg.house + msg.combinedToBattery) {\n msg.toHouse = msg.house + msg.combinedToBattery;\n }\n else if (!includeBattery && msg.toHouse > msg.house){\n msg.toHouse = msg.house;\n }\n\n msg.toHouseUnit = \"W\";\n}\nelse if (msg.solarUnit == \"kWh\" && msg.toGridUnit == \"kWh\" && msg.toHouse === undefined && Number.isFinite(msg.solar) && Number.isFinite(msg.toGrid))\n{\n msg.toHouse = msg.solar - msg.toGrid;\n\n if (!includeBattery && msg.toHouse > msg.house){\n msg.toHouse = msg.house;\n }\n\n msg.toHouseUnit = \"kWh\";\n}\nelse if (msg.solarUnit == \"€\" && msg.toGridUnit == \"€\" && msg.toHouse === undefined && Number.isFinite(msg.solar) && Number.isFinite(msg.toGrid)) {\n msg.toHouse = msg.solar - msg.toGrid;\n msg.toHouseUnit = \"€\";\n}\nreturn msg;",
865867
"outputs": 1,
866868
"noerr": 0,
867869
"initialize": "",
868870
"finalize": "",
869871
"libs": [],
870-
"x": 1050,
872+
"x": 1010,
871873
"y": 140,
872874
"wires": [
873875
[
@@ -886,7 +888,7 @@
886888
"initialize": "",
887889
"finalize": "",
888890
"libs": [],
889-
"x": 300,
891+
"x": 120,
890892
"y": 140,
891893
"wires": [
892894
[
@@ -27112,7 +27114,7 @@
2711227114
"initialize": "",
2711327115
"finalize": "",
2711427116
"libs": [],
27115-
"x": 650,
27117+
"x": 610,
2711627118
"y": 140,
2711727119
"wires": [
2711827120
[
@@ -36758,11 +36760,11 @@
3675836760
"initialize": "",
3675936761
"finalize": "",
3676036762
"libs": [],
36761-
"x": 450,
36763+
"x": 270,
3676236764
"y": 140,
3676336765
"wires": [
3676436766
[
36765-
"57978a63f95fc33c"
36767+
"81b698f1cb92cd95"
3676636768
]
3676736769
]
3676836770
},
@@ -36777,7 +36779,7 @@
3677736779
"initialize": "",
3677836780
"finalize": "",
3677936781
"libs": [],
36780-
"x": 1350,
36782+
"x": 1310,
3678136783
"y": 140,
3678236784
"wires": [
3678336785
[
@@ -50921,21 +50923,21 @@
5092150923
]
5092250924
},
5092350925
{
50924-
"id": "96c080c3c196de2a",
50926+
"id": "81b698f1cb92cd95",
5092550927
"type": "function",
5092650928
"z": "774cc0ad6b18a8e3",
50927-
"name": "Invert toBattery",
50928-
"func": "if (Number.isFinite(msg.toBattery) && env.get(\"To battery input\") == \"Inverted\"){\n msg.toBattery *= -1;\n}\n\nreturn msg;",
50929+
"name": "combine",
50930+
"func": "msg.combinedToBattery = msg.toBattery;\nif ((Number.isFinite(msg.toBattery) || Number.isFinite(msg.fromBattery)) //atleast one is a number\n && typeof msg.toBattery != \"string\" && typeof msg.fromBattery != \"string\" //none is a string\n && msg.toBatteryUnit == msg.fromBatteryUnit) //same unit\n{\n msg.combinedToBattery = (msg.toBattery ?? 0) - (msg.fromBattery ?? 0);\n}\nmsg.combinedToBattery = msg.combinedToBattery ?? 0;\n\nlet combineBattery = env.get(\"1. multi icon\") != \"FromToBattery\";\nif (combineBattery //combined selected\n && (Number.isFinite(msg.toBattery) || Number.isFinite(msg.fromBattery)) //atleast one is a number\n && typeof msg.toBattery != \"string\" && typeof msg.fromBattery != \"string\" //none is a string\n && msg.toBatteryUnit == msg.fromBatteryUnit) //same unit\n{\n msg.toBattery = (msg.toBattery ?? 0) - (msg.fromBattery ?? 0);\n delete msg.fromBattery;\n}\n\nlet combineGrid = env.get(\"3. multi icon\") == \"FromGrid\";\nif (combineGrid //combined selected\n && (Number.isFinite(msg.fromGrid) || Number.isFinite(msg.toGrid)) //atleast one is a number\n && typeof msg.fromGrid != \"string\" && typeof msg.toGrid != \"string\" //none is a string\n && msg.fromGridUnit == msg.toGridUnit) //same unit\n{\n msg.fromGrid = (msg.fromGrid ?? 0) - (msg.toGrid ?? 0);\n delete msg.toGrid;\n}\n\nreturn msg;",
5092950931
"outputs": 1,
5093050932
"noerr": 0,
5093150933
"initialize": "",
5093250934
"finalize": "",
5093350935
"libs": [],
50934-
"x": 140,
50936+
"x": 420,
5093550937
"y": 140,
5093650938
"wires": [
5093750939
[
50938-
"63fc5dfacf242fc0"
50940+
"57978a63f95fc33c"
5093950941
]
5094050942
]
5094150943
}

0 commit comments

Comments
 (0)