Integration of a Fronius Symo Gen 24 plus Inverter via Modbus TCP

Good to get some confirmation! :+1:t3:

It ran now last night, and battery is currently at 82% HOLDING. Prices today are still low and now I’m waiting for the time span to occur for it to DISCHARGE.

I already have a few improvements in mind, but that would mean more writes to the NVRAM - like CHARGE everytime the battery is X and price is X, and do the same for DISCHARGE, and NORMAL.

One thing also, if sun would be shining now (it doesn’t), and the battery wasn’t min 90%, HOLDING the battery would mean I would export excessive energy instead of pushing to battery… Preferably I’d like for the battery to be CHARGED instead of HOLDING. I guess that would mean a setting of 3, and DISCHARGE to minus 100 and CHARGE to 0?

And yes, I also have the BYD 11.0 HVM. :slight_smile:

Will be interesting to exchange ideas in the future. I’m curious about your switch @heyitsal… It seemed smart. :slight_smile:

Some updated battery modes:

[{"id":"62fbd666c7c7b20d","type":"group","z":"effce8e2e8a9f43c","name":"BATTERY INSTRUCTIONS","style":{"label":true},"nodes":["7b45bdf5d2c774a4","d93cd01b0135c571","7a2e734eead34d16","b9ef723c9e5d6e8c"],"x":1428,"y":233,"w":544,"h":554},{"id":"7b45bdf5d2c774a4","type":"group","z":"effce8e2e8a9f43c","g":"62fbd666c7c7b20d","name":"NORMAL","style":{"label":true},"nodes":["7a60a2b45d28626d","8c9613cac1965ae9"],"x":1454,"y":259,"w":492,"h":82},{"id":"7a60a2b45d28626d","type":"function","z":"effce8e2e8a9f43c","g":"7b45bdf5d2c774a4","name":"NORMAL","func":"\nmsg.StorCtl_Mod = \"0\"\nmsg.OutWRte = \"10000\"\nmsg.InWRte = \"10000\"\n\nmsg.newstate = \"normal\"\n\nreturn msg","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1860,"y":300,"wires":[["fad803646bcd93ee"]],"info":"This puts the battery in normal operation.\nMeaningn that it will both charge and discharge to\nits set limits at 100%,\n"},{"id":"8c9613cac1965ae9","type":"api-current-state","z":"effce8e2e8a9f43c","g":"7b45bdf5d2c774a4","name":"OutWRt already 100?","server":"afa7e6c.89d5e18","version":3,"outputs":2,"halt_if":"100","halt_if_type":"num","halt_if_compare":"is","entity_id":"sensor.gen24_storage_outwrte","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1580,"y":300,"wires":[[],["7a60a2b45d28626d"]]},{"id":"afa7e6c.89d5e18","type":"server","name":"Home Assistant","addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":true,"heartbeatInterval":"30","statusSeparator":"","enableGlobalContextStore":false},{"id":"d93cd01b0135c571","type":"group","z":"effce8e2e8a9f43c","g":"62fbd666c7c7b20d","name":"FORCED CHARGE","style":{"label":true},"nodes":["66d147c4d9a586f8","62364dcb3387db2b","96365e785c02b8ce","21da80d2a0e2aa42"],"x":1454,"y":359,"w":492,"h":142},{"id":"66d147c4d9a586f8","type":"function","z":"effce8e2e8a9f43c","g":"d93cd01b0135c571","name":"4500W CHARGE","func":"msg.StorCtl_Mod = \"2\"\n// 4500W (65536-4500)\nmsg.OutWRte = \"61036\"\n\nmsg.newstate = \"forcecharge4500w\"\n\nreturn msg","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1830,"y":400,"wires":[["fad803646bcd93ee"]],"info":"Example 1: Only permit energy storage charging\nThis behavior can be achieved by limiting the maximum discharge capacity to 0%\n=> results in window [-3300 W, 0 W]\n- OutWRte = 0% (set discharge limit of WchaMax to 0%)\n- StorCtl_Mod = 2 (activates discharge limit, bit pattern: 10)\n- InWRte is not relevant in this case"},{"id":"62364dcb3387db2b","type":"function","z":"effce8e2e8a9f43c","g":"d93cd01b0135c571","name":"1500W CHARGE","func":"msg.StorCtl_Mod = \"2\"\n// 4500W (65536-1500)\nmsg.OutWRte = \"64036\"\n\nmsg.newstate = \"forcecharge1500w\"\n\nreturn msg","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1830,"y":460,"wires":[["fad803646bcd93ee"]],"info":"Example 5: Charging in the range of 50% to 75% of the nominal power\nThis behavior can be achieved by limiting the maximum charge capacity to 75%\nand the maximum discharge capacity to -50%\n=> results in window [1650 W, 2475 W]\n- InWRte = 75% (set charge limit of WchaMax to 75%)\n- OutWRte = -50% (set discharge limit of WchaMax to -50%)\n- StorCtl_Mod = 3 (activate both limit values, bit pattern: 11)\n- Battery status in Fronius Solar.web will change to Forced Recharge"},{"id":"96365e785c02b8ce","type":"api-current-state","z":"effce8e2e8a9f43c","g":"d93cd01b0135c571","name":"OutWRt already -15?","server":"afa7e6c.89d5e18","version":3,"outputs":2,"halt_if":"-15","halt_if_type":"num","halt_if_compare":"is","entity_id":"sensor.gen24_storage_outwrte","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1580,"y":460,"wires":[[],["62364dcb3387db2b"]]},{"id":"21da80d2a0e2aa42","type":"api-current-state","z":"effce8e2e8a9f43c","g":"d93cd01b0135c571","name":"OutWRt already -45?","server":"afa7e6c.89d5e18","version":3,"outputs":2,"halt_if":"-45","halt_if_type":"num","halt_if_compare":"is","entity_id":"sensor.gen24_storage_outwrte","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1580,"y":400,"wires":[[],["66d147c4d9a586f8"]]},{"id":"7a2e734eead34d16","type":"group","z":"effce8e2e8a9f43c","g":"62fbd666c7c7b20d","name":"HOLD (No charge or discharge)","style":{"label":true},"nodes":["5d370aec7b2aa1ce","f888ef1ef01b3e83"],"x":1454,"y":519,"w":492,"h":82},{"id":"5d370aec7b2aa1ce","type":"function","z":"effce8e2e8a9f43c","g":"7a2e734eead34d16","name":"HOLD","func":"msg.StorCtl_Mod = \"3\"\nmsg.OutWRte = \"0\"\nmsg.InWRte = \"0\"\n\nmsg.newstate = \"hold_state\"\n\nreturn msg","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1870,"y":560,"wires":[["fad803646bcd93ee"]],"info":"Example 3: Do not permit charging or discharging\nThis behavior can be achieved by limiting the maximum charge capacity to 0%\nand the maximum discharge capacity to 0%\n=> results in window [0 W, 0 W]\n- InWRte = 0% (set charge limit of WchaMax to 0%)\n- OutWRte = 0% (set discharge limit of WchaMax to 0%)\n- StorCtl_Mod = 3 (activate both limit values, bit pattern: 11)"},{"id":"f888ef1ef01b3e83","type":"api-current-state","z":"effce8e2e8a9f43c","g":"7a2e734eead34d16","name":"ChaSt already HOLDING?","server":"afa7e6c.89d5e18","version":3,"outputs":2,"halt_if":"HOLDING","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.gen24_storage_chast","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1600,"y":560,"wires":[[],["5d370aec7b2aa1ce"]]},{"id":"b9ef723c9e5d6e8c","type":"group","z":"effce8e2e8a9f43c","g":"62fbd666c7c7b20d","name":"FORCED DISCHARGE","style":{"label":true},"nodes":["f52c691bee1e0932","3fccdd784ca45eca","bc399a85c5ad3281","7b05462e688a5afd"],"x":1454,"y":619,"w":492,"h":142},{"id":"f52c691bee1e0932","type":"function","z":"effce8e2e8a9f43c","g":"b9ef723c9e5d6e8c","name":"1500W DISCHARGE","func":"\nmsg.StorCtl_Mod = \"3\"\nmsg.OutWRte = 1000\n// 65536 - 1500\nmsg.InWRte = \"64536\"\n\nmsg.newstate = \"1kWdischarge\"\n\nreturn msg","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1820,"y":660,"wires":[["fad803646bcd93ee"]]},{"id":"3fccdd784ca45eca","type":"api-current-state","z":"effce8e2e8a9f43c","g":"b9ef723c9e5d6e8c","name":"OutWRt already 10?","server":"afa7e6c.89d5e18","version":3,"outputs":2,"halt_if":"10","halt_if_type":"num","halt_if_compare":"is","entity_id":"sensor.gen24_storage_outwrte","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1580,"y":660,"wires":[[],["f52c691bee1e0932"]]},{"id":"bc399a85c5ad3281","type":"function","z":"effce8e2e8a9f43c","g":"b9ef723c9e5d6e8c","name":"3000W DISCHARGE","func":"\nmsg.StorCtl_Mod = \"3\"\nmsg.OutWRte = 1000\n// 65536 - 3000\nmsg.InWRte = \"64536\"\n\nmsg.newstate = \"3kWdischarge\"\n\nreturn msg","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1820,"y":720,"wires":[["fad803646bcd93ee"]]},{"id":"7b05462e688a5afd","type":"api-current-state","z":"effce8e2e8a9f43c","g":"b9ef723c9e5d6e8c","name":"OutWRt already 30?","server":"afa7e6c.89d5e18","version":3,"outputs":2,"halt_if":"30","halt_if_type":"num","halt_if_compare":"is","entity_id":"sensor.gen24_storage_outwrte","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1580,"y":720,"wires":[[],["bc399a85c5ad3281"]]}]

image

The solutions for the cars became like this:

If they should start at the same time I’ve set an offset on either one or the other state, since it takes a few seconds for the Modbus to write and update.

I’ve also optimized the DISCHARGE a bit. Depending on the price, it now discharges at different power. The loading cost for CHARGING is always below 40 öre (cent), that means either 1 or 2 SEK profit / kwh.

EDIT:
Btw @steffanlm Just implemented your “Rate limit” before writing to Modbus, nice addition!

I’m a bit more cautious and decided to go with 1 message every 5 seconds. NVRAM wear… :slight_smile:

If you meant Discharge to -100% :

StorCTL_Mod = 3
Discharge = 55536
InWRte = 0

Then you would be force charging at 100%.

If you want
No Discharge - Only Charge with Excess Solar
Either:

StorCtl_MOD = 2
OutWRte = 0

Same thing can be done with this (but redundant in this case)

StorCtl_Mod = 3 (enables both OutWRte and InWRte registers)
OutWRte = 0
InWRte = 10000 (allow charging up to max rate)

The solutions for the cars became like this:

Wow you’ve done so much already! Keep it up!!

Will definitely post my battery/inverter control up soon - trying to efficientise it further… maybe it’s a never ending goal??

Haha, true dat!

I think this is just what I needed, thanks! Will set that as the normal throughout the day.

This one is also very interesting, I can now extract the time of the day when the price is at it’s highest, and if that price is above a hard limit set, then go bananas on the export (discharge):

image

[{"id":"d3317acef2826bb6","type":"ha-time","z":"effce8e2e8a9f43c","g":"e209b9134d0bb2d2","name":"MAX DISCHARGE @ PEAK","server":"afa7e6c.89d5e18","version":3,"exposeAsEntityConfig":"","entityId":"sensor.peak_48_hours_time","property":"","offset":"2","offsetType":"num","offsetUnits":"minutes","randomOffset":false,"repeatDaily":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"sunday":true,"monday":true,"tuesday":true,"wednesday":true,"thursday":true,"friday":true,"saturday":true,"x":920,"y":920,"wires":[["f8111ebed4317fd9"]]},{"id":"f8111ebed4317fd9","type":"api-current-state","z":"effce8e2e8a9f43c","g":"e209b9134d0bb2d2","name":"PEAK PRICE","server":"afa7e6c.89d5e18","version":3,"outputs":2,"halt_if":"150","halt_if_type":"num","halt_if_compare":"gt","entity_id":"sensor.peak_48_hours_price","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1160,"y":920,"wires":[["7b05462e688a5afd"],[]]},{"id":"afa7e6c.89d5e18","type":"server","name":"Home Assistant","addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":true,"heartbeatInterval":"30","statusSeparator":"","enableGlobalContextStore":false}]

Still experimenting, but after today’s run I’ve learned a few things:

  1. HOLD is only good if you actually know a big peak is coming, it’s better to set StorCtl 3 and let it charge from sun.
  2. Always try to diff at least 1 SEK (0.1 EUR) between charge and discharge. I sold pretty cheap today, and bought it expensive.
  3. There’s always room for improvement. The hardest parts are the hard limit - where should it be set? It can differ from day to day. But I think I settled on selling from battery storage if the price differs more than 1 SEK for now.
1 Like

OK, so I think this is close to the final result:

[{"id":"effce8e2e8a9f43c","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"62fbd666c7c7b20d","type":"group","z":"effce8e2e8a9f43c","name":"BATTERY INSTRUCTIONS","style":{"label":true},"nodes":["7b45bdf5d2c774a4","d93cd01b0135c571","7a2e734eead34d16","b9ef723c9e5d6e8c","f1579354c1921264"],"x":1728,"y":233,"w":564,"h":714},{"id":"f155037011aa0d79","type":"group","z":"effce8e2e8a9f43c","name":"Write changes!","style":{"label":true},"nodes":["0cc39af6d8b8dc0f","9f84293f8db8abd4","e0414ba507e24b27","3bffd91c351286ee"],"x":2734,"y":459,"w":672,"h":122},{"id":"fbe0abfb3ee0e088","type":"group","z":"effce8e2e8a9f43c","name":"Payload","style":{"label":true},"nodes":["fad803646bcd93ee"],"x":2414,"y":479,"w":292,"h":82},{"id":"7a697ccd23e6b3cb","type":"group","z":"effce8e2e8a9f43c","name":"START CHARGE 1H BEFORE CAR START BASED ON SPOT PRICE - CHEAP HOURS","style":{"label":true,"stroke":"#92d04f","color":"#000000"},"nodes":["1bdbeec9beec4666","7ba45c1373d6db9c","ec6756e96722cebb","ee12a627340871cc"],"x":14,"y":53,"w":1092,"h":148},{"id":"e209b9134d0bb2d2","type":"group","z":"effce8e2e8a9f43c","name":"DISCHARGE ON THE MOST EXPENSIVE HOURS","style":{"label":true,"color":"#000000","stroke":"#ff0000"},"nodes":["adbc3aa9cf52d50f","02b26ef1b0a8b08d","7f4903812faedc8c","d02c29a8f72609bd","c8e0d9aa9ca9caeb","34990cd67c990907","d3317acef2826bb6","1af0741d36ec6e93","f8111ebed4317fd9","fee34c327c9cea95","1aab75cc0f069305","2b9f4c9abc1148dd","de05bf4c517ce32a","7f55b776f0b34a54"],"x":14,"y":639,"w":1092,"h":382},{"id":"0bd67f9e3d7f071c","type":"group","z":"effce8e2e8a9f43c","name":"SCHELUDED CAR CHARGING","style":{"label":true,"color":"#000000","stroke":"#ffC000"},"nodes":["1c8a755bac3130a0","f049899799f7f431","19a007dca869d5ac","2f6678d42b0de023","906228c962c8c1e3","e47b6a6830c96cef"],"x":14,"y":239,"w":852,"h":282},{"id":"72b918efda5f705f","type":"group","z":"effce8e2e8a9f43c","name":"DO SOMETHING WHEN BATTERY IS FULL","style":{"stroke":"#000000","label":true,"color":"#000000"},"nodes":["213549e7b854d62a","b6852c6123b496b0","f27f1ab3f8eb58bf"],"x":1214,"y":19,"w":432,"h":162},{"id":"7ba45c1373d6db9c","type":"group","z":"effce8e2e8a9f43c","g":"7a697ccd23e6b3cb","name":"Check current price/kWh","style":{"label":true},"nodes":["d5351cdc453ee22e","3b6d2b1103a7ee5c"],"x":334,"y":79,"w":472,"h":82},{"id":"7b45bdf5d2c774a4","type":"group","z":"effce8e2e8a9f43c","g":"62fbd666c7c7b20d","name":"NORMAL","style":{"label":true},"nodes":["7a60a2b45d28626d","8c9613cac1965ae9"],"x":1774,"y":419,"w":492,"h":82},{"id":"d93cd01b0135c571","type":"group","z":"effce8e2e8a9f43c","g":"62fbd666c7c7b20d","name":"FORCED CHARGE","style":{"label":true},"nodes":["66d147c4d9a586f8","62364dcb3387db2b","96365e785c02b8ce","21da80d2a0e2aa42"],"x":1774,"y":519,"w":492,"h":142},{"id":"7a2e734eead34d16","type":"group","z":"effce8e2e8a9f43c","g":"62fbd666c7c7b20d","name":"HOLD (No charge or discharge)","style":{"label":true},"nodes":["5d370aec7b2aa1ce","f888ef1ef01b3e83"],"x":1774,"y":679,"w":492,"h":82},{"id":"02b26ef1b0a8b08d","type":"group","z":"effce8e2e8a9f43c","g":"e209b9134d0bb2d2","name":"Check current price/kWh","style":{"label":true},"nodes":["0cc692ab6f439fdf","f032a97315254445"],"x":234,"y":724,"w":432,"h":112},{"id":"b9ef723c9e5d6e8c","type":"group","z":"effce8e2e8a9f43c","g":"62fbd666c7c7b20d","name":"FORCED DISCHARGE","style":{"label":true},"nodes":["f52c691bee1e0932","3fccdd784ca45eca","bc399a85c5ad3281","7b05462e688a5afd"],"x":1774,"y":779,"w":492,"h":142},{"id":"f1579354c1921264","type":"group","z":"effce8e2e8a9f43c","g":"62fbd666c7c7b20d","name":"POWER FROM SUN","style":{"label":true},"nodes":["79428347ba72398e","b77df5e20a3eff97","b30d06bcfe2e62de"],"x":1754,"y":259,"w":512,"h":142},{"id":"fee34c327c9cea95","type":"junction","z":"effce8e2e8a9f43c","g":"e209b9134d0bb2d2","x":1080,"y":720,"wires":[["3fccdd784ca45eca"]]},{"id":"1af0741d36ec6e93","type":"junction","z":"effce8e2e8a9f43c","g":"e209b9134d0bb2d2","x":1080,"y":680,"wires":[["7b05462e688a5afd"]]},{"id":"e47b6a6830c96cef","type":"junction","z":"effce8e2e8a9f43c","g":"0bd67f9e3d7f071c","x":580,"y":440,"wires":[["f888ef1ef01b3e83"]]},{"id":"de05bf4c517ce32a","type":"junction","z":"effce8e2e8a9f43c","g":"e209b9134d0bb2d2","x":1080,"y":800,"wires":[["b77df5e20a3eff97"]]},{"id":"7f55b776f0b34a54","type":"junction","z":"effce8e2e8a9f43c","g":"e209b9134d0bb2d2","x":1080,"y":740,"wires":[["8c9613cac1965ae9"]]},{"id":"d5351cdc453ee22e","type":"api-current-state","z":"effce8e2e8a9f43c","g":"7ba45c1373d6db9c","name":"Spotpris","server":"afa7e6c.89d5e18","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.energi_data_service","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":420,"y":120,"wires":[["3b6d2b1103a7ee5c"]]},{"id":"3b6d2b1103a7ee5c","type":"switch","z":"effce8e2e8a9f43c","g":"7ba45c1373d6db9c","name":"LESS than $LOWPEAKPRICE","property":"payload","propertyType":"msg","rules":[{"t":"lte","v":"LOWPEAKPRICE","vt":"env"}],"checkall":"true","repair":false,"outputs":1,"x":650,"y":120,"wires":[["ec6756e96722cebb"]]},{"id":"1bdbeec9beec4666","type":"ha-time","z":"effce8e2e8a9f43c","g":"7a697ccd23e6b3cb","name":"TESLA START OFFSET -1H","server":"afa7e6c.89d5e18","version":3,"exposeAsEntityConfig":"","entityId":"sensor.tesla_start_charging_time","property":"","offset":"-3580","offsetType":"num","offsetUnits":"seconds","randomOffset":false,"repeatDaily":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"sunday":true,"monday":true,"tuesday":true,"wednesday":true,"thursday":true,"friday":true,"saturday":true,"x":160,"y":100,"wires":[["d5351cdc453ee22e"]]},{"id":"1c8a755bac3130a0","type":"ha-time","z":"effce8e2e8a9f43c","g":"0bd67f9e3d7f071c","name":"TESLA STOP (NOW)","server":"afa7e6c.89d5e18","version":3,"exposeAsEntityConfig":"","entityId":"sensor.tesla_stop_charging_time","property":"","offset":"0","offsetType":"num","offsetUnits":"hours","randomOffset":false,"repeatDaily":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"sunday":true,"monday":true,"tuesday":true,"wednesday":true,"thursday":true,"friday":true,"saturday":true,"x":140,"y":420,"wires":[["e47b6a6830c96cef"]]},{"id":"7a60a2b45d28626d","type":"function","z":"effce8e2e8a9f43c","g":"7b45bdf5d2c774a4","name":"NORMAL","func":"\nmsg.StorCtl_Mod = \"0\"\nmsg.OutWRte = \"10000\"\nmsg.InWRte = \"10000\"\n\nmsg.newstate = \"normal\"\n\nreturn msg","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":2180,"y":460,"wires":[["fad803646bcd93ee"]],"info":"This puts the battery in normal operation.\nMeaningn that it will both charge and discharge to\nits set limits at 100%,\n"},{"id":"66d147c4d9a586f8","type":"function","z":"effce8e2e8a9f43c","g":"d93cd01b0135c571","name":"4500W CHARGE","func":"msg.StorCtl_Mod = \"2\"\n// 4500W (65536-4500)\nmsg.OutWRte = \"61036\"\n\nmsg.newstate = \"forcecharge4500w\"\n\nreturn msg","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":2150,"y":560,"wires":[["fad803646bcd93ee"]],"info":"Example 1: Only permit energy storage charging\nThis behavior can be achieved by limiting the maximum discharge capacity to 0%\n=> results in window [-3300 W, 0 W]\n- OutWRte = 0% (set discharge limit of WchaMax to 0%)\n- StorCtl_Mod = 2 (activates discharge limit, bit pattern: 10)\n- InWRte is not relevant in this case"},{"id":"5d370aec7b2aa1ce","type":"function","z":"effce8e2e8a9f43c","g":"7a2e734eead34d16","name":"HOLD","func":"msg.StorCtl_Mod = \"3\"\nmsg.OutWRte = \"0\"\nmsg.InWRte = \"0\"\n\nmsg.newstate = \"hold_state\"\n\nreturn msg","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":2190,"y":720,"wires":[["fad803646bcd93ee"]],"info":"Example 3: Do not permit charging or discharging\nThis behavior can be achieved by limiting the maximum charge capacity to 0%\nand the maximum discharge capacity to 0%\n=> results in window [0 W, 0 W]\n- InWRte = 0% (set charge limit of WchaMax to 0%)\n- OutWRte = 0% (set discharge limit of WchaMax to 0%)\n- StorCtl_Mod = 3 (activate both limit values, bit pattern: 11)"},{"id":"0cc39af6d8b8dc0f","type":"modbus-response","z":"effce8e2e8a9f43c","g":"f155037011aa0d79","name":"","registerShowMax":20,"x":3190,"y":540,"wires":[]},{"id":"9f84293f8db8abd4","type":"modbus-flex-write","z":"effce8e2e8a9f43c","g":"f155037011aa0d79","name":"Fronius Storage","showStatusActivities":true,"showErrors":true,"showWarnings":true,"server":"ecd41b68db8d4254","emptyMsgOnFail":true,"keepMsgProperties":true,"delayOnStart":false,"startDelayTime":"10","x":3000,"y":520,"wires":[["0cc39af6d8b8dc0f","e0414ba507e24b27"],[]]},{"id":"e0414ba507e24b27","type":"debug","z":"effce8e2e8a9f43c","g":"f155037011aa0d79","name":"Inverter MODBUS Response","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":3230,"y":500,"wires":[]},{"id":"fad803646bcd93ee","type":"function","z":"effce8e2e8a9f43c","g":"fbe0abfb3ee0e088","name":"Modbus Payload Template","func":"var values = [msg.StorCtl_Mod, (65535), (500), (10000), (65535), (65535), (5), (msg.OutWRte), (msg.InWRte)]\n\nmsg.payload = {\n    'value': values,\n    'fc': 16,\n    'unitid': 1,\n    // INT+SF = -10\n    'address': 40348,\n    'quantity': 9\n}\n\nreturn msg","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":2560,"y":520,"wires":[["3bffd91c351286ee"]]},{"id":"f049899799f7f431","type":"ha-time","z":"effce8e2e8a9f43c","g":"0bd67f9e3d7f071c","name":"TESLA START (NOW)","server":"afa7e6c.89d5e18","version":3,"exposeAsEntityConfig":"","entityId":"sensor.tesla_start_charging_time","property":"","offset":"","offsetType":"num","offsetUnits":"hours","randomOffset":false,"repeatDaily":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"sunday":true,"monday":true,"tuesday":true,"wednesday":true,"thursday":true,"friday":true,"saturday":true,"x":140,"y":280,"wires":[["19a007dca869d5ac"]]},{"id":"adbc3aa9cf52d50f","type":"debug","z":"effce8e2e8a9f43c","g":"e209b9134d0bb2d2","name":"MORE THAN 240","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":700,"y":680,"wires":[]},{"id":"0cc692ab6f439fdf","type":"api-current-state","z":"effce8e2e8a9f43c","g":"02b26ef1b0a8b08d","name":"Spotpris","server":"afa7e6c.89d5e18","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.energi_data_service","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":320,"y":780,"wires":[["f032a97315254445"]]},{"id":"f032a97315254445","type":"switch","z":"effce8e2e8a9f43c","g":"02b26ef1b0a8b08d","name":"Price switch","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"240","vt":"num"},{"t":"gte","v":"MAXPEAKPRICE","vt":"env"},{"t":"lte","v":"MAXPEAKPRICE","vt":"env"},{"t":"lte","v":"100","vt":"env"}],"checkall":"false","repair":false,"outputs":4,"x":570,"y":780,"wires":[["1af0741d36ec6e93","adbc3aa9cf52d50f"],["fee34c327c9cea95","c8e0d9aa9ca9caeb"],["34990cd67c990907","7f55b776f0b34a54"],["2b9f4c9abc1148dd","de05bf4c517ce32a"]]},{"id":"7f4903812faedc8c","type":"time-of-day","z":"effce8e2e8a9f43c","g":"e209b9134d0bb2d2","name":"","startTime":"16:00:00","endTime":"20:01:00","outputs":1,"x":130,"y":800,"wires":[["0cc692ab6f439fdf"]]},{"id":"d02c29a8f72609bd","type":"time-of-day","z":"effce8e2e8a9f43c","g":"e209b9134d0bb2d2","name":"","startTime":"06:00:00","endTime":"09:01:00","outputs":1,"x":130,"y":740,"wires":[["0cc692ab6f439fdf"]]},{"id":"19a007dca869d5ac","type":"api-current-state","z":"effce8e2e8a9f43c","g":"0bd67f9e3d7f071c","name":"GRID LOAD less than 5500W?","server":"afa7e6c.89d5e18","version":3,"outputs":2,"halt_if":"5500","halt_if_type":"num","halt_if_compare":"lte","entity_id":"sensor.gen24_ac_meter_watts","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":710,"y":340,"wires":[["21da80d2a0e2aa42"],["96365e785c02b8ce"]]},{"id":"62364dcb3387db2b","type":"function","z":"effce8e2e8a9f43c","g":"d93cd01b0135c571","name":"1500W CHARGE","func":"msg.StorCtl_Mod = \"2\"\n// 4500W (65536-1500)\nmsg.OutWRte = \"64036\"\n\nmsg.newstate = \"forcecharge1500w\"\n\nreturn msg","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":2150,"y":620,"wires":[["fad803646bcd93ee"]],"info":"Example 5: Charging in the range of 50% to 75% of the nominal power\nThis behavior can be achieved by limiting the maximum charge capacity to 75%\nand the maximum discharge capacity to -50%\n=> results in window [1650 W, 2475 W]\n- InWRte = 75% (set charge limit of WchaMax to 75%)\n- OutWRte = -50% (set discharge limit of WchaMax to -50%)\n- StorCtl_Mod = 3 (activate both limit values, bit pattern: 11)\n- Battery status in Fronius Solar.web will change to Forced Recharge"},{"id":"213549e7b854d62a","type":"server-state-changed","z":"effce8e2e8a9f43c","g":"72b918efda5f705f","name":"State Check Battery MORE THAN 60%","server":"afa7e6c.89d5e18","version":5,"outputs":2,"exposeAsEntityConfig":"","entityId":"sensor.gen24_storage_chastate","entityIdType":"exact","outputInitially":true,"stateType":"num","ifState":"60","ifStateType":"num","ifStateOperator":"gt","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":1390,"y":60,"wires":[["b6852c6123b496b0"],["f27f1ab3f8eb58bf"]]},{"id":"b6852c6123b496b0","type":"time-of-day","z":"effce8e2e8a9f43c","g":"72b918efda5f705f","name":"","startTime":"09:01:00","endTime":"16:01:00","outputs":1,"x":1330,"y":140,"wires":[["8c9613cac1965ae9"]]},{"id":"1aa259781a6e2913","type":"debug","z":"effce8e2e8a9f43c","name":"IS SOMETHING WRITTEN?","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":3070,"y":640,"wires":[]},{"id":"6f57fd58660bf7dc","type":"inject","z":"effce8e2e8a9f43c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":2840,"y":640,"wires":[["1aa259781a6e2913"]]},{"id":"cb05b2a950f8de3d","type":"cronplus","z":"effce8e2e8a9f43c","name":"Every second","outputField":"payload","timeZone":"","storeName":"","commandResponseMsgOutput":"output1","defaultLocation":"","defaultLocationType":"default","outputs":1,"options":[{"name":"schedule1","topic":"topic1","payloadType":"default","payload":"","expressionType":"cron","expression":"* * * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":540,"y":560,"wires":[[]]},{"id":"c8e0d9aa9ca9caeb","type":"debug","z":"effce8e2e8a9f43c","g":"e209b9134d0bb2d2","name":"MORE THAN $MAXPEAKPRICE","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":900,"y":820,"wires":[]},{"id":"34990cd67c990907","type":"debug","z":"effce8e2e8a9f43c","g":"e209b9134d0bb2d2","name":"LESS THAN $MAXPEAKPRICE","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":880,"y":880,"wires":[]},{"id":"f52c691bee1e0932","type":"function","z":"effce8e2e8a9f43c","g":"b9ef723c9e5d6e8c","name":"1500W DISCHARGE","func":"msg.StorCtl_Mod = \"1\"\n// 65536 - 1500\nmsg.InWRte = \"64036\"\n\nmsg.newstate = \"1kWdischarge\"\n\nreturn msg","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":2140,"y":820,"wires":[["fad803646bcd93ee"]]},{"id":"3fccdd784ca45eca","type":"api-current-state","z":"effce8e2e8a9f43c","g":"b9ef723c9e5d6e8c","name":"InWRte already -15?","server":"afa7e6c.89d5e18","version":3,"outputs":2,"halt_if":"-15","halt_if_type":"num","halt_if_compare":"is","entity_id":"sensor.gen24_storage_inwrte","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1900,"y":820,"wires":[[],["f52c691bee1e0932"]]},{"id":"f888ef1ef01b3e83","type":"api-current-state","z":"effce8e2e8a9f43c","g":"7a2e734eead34d16","name":"ChaSt already HOLDING?","server":"afa7e6c.89d5e18","version":3,"outputs":2,"halt_if":"HOLDING","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.gen24_storage_chast","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1920,"y":720,"wires":[[],["5d370aec7b2aa1ce"]]},{"id":"96365e785c02b8ce","type":"api-current-state","z":"effce8e2e8a9f43c","g":"d93cd01b0135c571","name":"OutWRte already -15?","server":"afa7e6c.89d5e18","version":3,"outputs":2,"halt_if":"-15","halt_if_type":"num","halt_if_compare":"is","entity_id":"sensor.gen24_storage_outwrte","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1900,"y":620,"wires":[[],["62364dcb3387db2b"]]},{"id":"21da80d2a0e2aa42","type":"api-current-state","z":"effce8e2e8a9f43c","g":"d93cd01b0135c571","name":"OutWRte already -45?","server":"afa7e6c.89d5e18","version":3,"outputs":2,"halt_if":"-45","halt_if_type":"num","halt_if_compare":"is","entity_id":"sensor.gen24_storage_outwrte","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1900,"y":560,"wires":[[],["66d147c4d9a586f8"]]},{"id":"8c9613cac1965ae9","type":"api-current-state","z":"effce8e2e8a9f43c","g":"7b45bdf5d2c774a4","name":"OutWRte already 100?","server":"afa7e6c.89d5e18","version":3,"outputs":2,"halt_if":"100","halt_if_type":"num","halt_if_compare":"is","entity_id":"sensor.gen24_storage_outwrte","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1900,"y":460,"wires":[[],["7a60a2b45d28626d"]]},{"id":"bc399a85c5ad3281","type":"function","z":"effce8e2e8a9f43c","g":"b9ef723c9e5d6e8c","name":"4500W DISCHARGE","func":"\nmsg.StorCtl_Mod = \"1\"\n// 65536 - 4500\nmsg.InWRte = \"61036\"\n\nmsg.newstate = \"3kWdischarge\"\n\nreturn msg","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":2140,"y":880,"wires":[["fad803646bcd93ee"]]},{"id":"7b05462e688a5afd","type":"api-current-state","z":"effce8e2e8a9f43c","g":"b9ef723c9e5d6e8c","name":"InWRte already -45?","server":"afa7e6c.89d5e18","version":3,"outputs":2,"halt_if":"-45","halt_if_type":"num","halt_if_compare":"is","entity_id":"sensor.gen24_storage_inwrte","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1900,"y":880,"wires":[[],["bc399a85c5ad3281"]]},{"id":"ec6756e96722cebb","type":"api-current-state","z":"effce8e2e8a9f43c","g":"7a697ccd23e6b3cb","name":"GRID LOAD less than 5500W?","server":"afa7e6c.89d5e18","version":3,"outputs":2,"halt_if":"5500","halt_if_type":"num","halt_if_compare":"lte","entity_id":"sensor.gen24_ac_meter_watts","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":950,"y":140,"wires":[["21da80d2a0e2aa42"],["96365e785c02b8ce"]]},{"id":"2f6678d42b0de023","type":"ha-time","z":"effce8e2e8a9f43c","g":"0bd67f9e3d7f071c","name":"VW START (NOW)","server":"afa7e6c.89d5e18","version":3,"exposeAsEntityConfig":"","entityId":"sensor.volkswagen_start_charging_time","property":"","offset":"30","offsetType":"num","offsetUnits":"seconds","randomOffset":false,"repeatDaily":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"sunday":true,"monday":true,"tuesday":true,"wednesday":true,"thursday":true,"friday":true,"saturday":true,"x":130,"y":340,"wires":[["19a007dca869d5ac"]]},{"id":"906228c962c8c1e3","type":"ha-time","z":"effce8e2e8a9f43c","g":"0bd67f9e3d7f071c","name":"VW STOP (NOW)","server":"afa7e6c.89d5e18","version":3,"exposeAsEntityConfig":"","entityId":"sensor.volkswagen_stop_charging_time","property":"","offset":"30","offsetType":"num","offsetUnits":"seconds","randomOffset":false,"repeatDaily":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"sunday":true,"monday":true,"tuesday":true,"wednesday":true,"thursday":true,"friday":true,"saturday":true,"x":130,"y":480,"wires":[["e47b6a6830c96cef"]]},{"id":"ee12a627340871cc","type":"ha-time","z":"effce8e2e8a9f43c","g":"7a697ccd23e6b3cb","name":"VW START OFFSET -1H","server":"afa7e6c.89d5e18","version":3,"exposeAsEntityConfig":"","entityId":"sensor.volkswagen_start_charging_time","property":"","offset":"-3570","offsetType":"num","offsetUnits":"seconds","randomOffset":false,"repeatDaily":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"sunday":true,"monday":true,"tuesday":true,"wednesday":true,"thursday":true,"friday":true,"saturday":true,"x":150,"y":160,"wires":[["d5351cdc453ee22e"]]},{"id":"3bffd91c351286ee","type":"delay","z":"effce8e2e8a9f43c","g":"f155037011aa0d79","name":"Rate limit","pauseType":"rate","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"10","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":2820,"y":520,"wires":[["9f84293f8db8abd4"]]},{"id":"79428347ba72398e","type":"function","z":"effce8e2e8a9f43c","g":"f1579354c1921264","name":"ALLOW SUN CHARGE","func":"msg.StorCtl_Mod = \"3\"\nmsg.OutWRte = \"65536\"\nmsg.InWRte = \"10000\"\n\nmsg.newstate = \"allow_suncharge\"\n\nreturn msg","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":2130,"y":360,"wires":[["fad803646bcd93ee"]],"info":"Example 3: Do not permit charging or discharging\nThis behavior can be achieved by limiting the maximum charge capacity to 0%\nand the maximum discharge capacity to 0%\n=> results in window [0 W, 0 W]\n- InWRte = 0% (set charge limit of WchaMax to 0%)\n- OutWRte = 0% (set discharge limit of WchaMax to 0%)\n- StorCtl_Mod = 3 (activate both limit values, bit pattern: 11)"},{"id":"f27f1ab3f8eb58bf","type":"time-of-day","z":"effce8e2e8a9f43c","g":"72b918efda5f705f","name":"","startTime":"09:01:00","endTime":"16:01:00","outputs":1,"x":1550,"y":140,"wires":[["b77df5e20a3eff97"]]},{"id":"d3317acef2826bb6","type":"ha-time","z":"effce8e2e8a9f43c","g":"e209b9134d0bb2d2","name":"MAX DISCHARGE @ PEAK","server":"afa7e6c.89d5e18","version":3,"exposeAsEntityConfig":"","entityId":"sensor.peak_48_hours_time","property":"","offset":"2","offsetType":"num","offsetUnits":"minutes","randomOffset":false,"repeatDaily":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"sunday":true,"monday":true,"tuesday":true,"wednesday":true,"thursday":true,"friday":true,"saturday":true,"x":160,"y":940,"wires":[["f8111ebed4317fd9"]]},{"id":"f8111ebed4317fd9","type":"api-current-state","z":"effce8e2e8a9f43c","g":"e209b9134d0bb2d2","name":"PEAK PRICE (170)","server":"afa7e6c.89d5e18","version":3,"outputs":2,"halt_if":"170","halt_if_type":"num","halt_if_compare":"gt","entity_id":"sensor.peak_48_hours_price","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":410,"y":940,"wires":[["7b05462e688a5afd"],["f032a97315254445"]]},{"id":"b77df5e20a3eff97","type":"api-current-state","z":"effce8e2e8a9f43c","g":"f1579354c1921264","name":"InWRte already 100?","server":"afa7e6c.89d5e18","version":3,"outputs":2,"halt_if":"100","halt_if_type":"num","halt_if_compare":"is","entity_id":"sensor.gen24_storage_inwrte","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1880,"y":300,"wires":[[],["b30d06bcfe2e62de"]]},{"id":"1aab75cc0f069305","type":"cronplus","z":"effce8e2e8a9f43c","g":"e209b9134d0bb2d2","name":"Every hour","outputField":"payload","timeZone":"","storeName":"","commandResponseMsgOutput":"output1","defaultLocation":"","defaultLocationType":"default","outputs":1,"options":[{"name":"schedule1","topic":"topic1","payloadType":"default","payload":"","expressionType":"cron","expression":"15 0 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":130,"y":680,"wires":[["d02c29a8f72609bd","7f4903812faedc8c"]]},{"id":"8306b11f2939be75","type":"cronplus","z":"effce8e2e8a9f43c","name":"Every minute","outputField":"payload","timeZone":"","storeName":"","commandResponseMsgOutput":"output1","defaultLocation":"","defaultLocationType":"default","outputs":1,"options":[{"name":"schedule1","topic":"topic1","payloadType":"default","payload":"","expressionType":"cron","expression":"0 * * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":810,"y":560,"wires":[[]]},{"id":"b30d06bcfe2e62de","type":"api-current-state","z":"effce8e2e8a9f43c","g":"f1579354c1921264","name":"ChaSt already HOLDING?","server":"afa7e6c.89d5e18","version":3,"outputs":2,"halt_if":"HOLDING","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.gen24_storage_chast","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":2120,"y":300,"wires":[[],["79428347ba72398e"]]},{"id":"2b9f4c9abc1148dd","type":"debug","z":"effce8e2e8a9f43c","g":"e209b9134d0bb2d2","name":"LESS THAN 100","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":790,"y":980,"wires":[]},{"id":"afa7e6c.89d5e18","type":"server","name":"Home Assistant","addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":true,"heartbeatInterval":"30","statusSeparator":"","enableGlobalContextStore":false},{"id":"ecd41b68db8d4254","type":"modbus-client","name":"Fronius Gen24","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":true,"queueLogEnabled":false,"failureLogEnabled":true,"tcpHost":"10.10.10.4","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","serialAsciiResponseStartDelimiter":"0x3A","unit_id":1,"commandDelay":1,"clientTimeout":1000,"reconnectOnTimeout":true,"reconnectTimeout":2000,"parallelUnitIdsAllowed":true,"showWarnings":true,"showLogs":true}]

Any suggestions of improvments?

1 Like

How does it go after 9 days?

I’m working through my solution - finding edge cases I should’ve thought about.

Max discharge of battery at 4.5kW - reduces solar panel production due to maximum AC output of the inverter. So have had to dynamically adjust battery output instead of forcing max discharge.

Wish I could start doing forecasting but still need to get the basics down first…

My loong answer got lost due to read-only…

Basically yes - it works OK, but I’m starting to question if it’s worth it in the end when importing electricity from GRID is so expensive.

OK, so now I want to change Fronius to Sunspec in my Energy dashboard, but I’m not sure which entities to use in my templates.

Does anyone have a clue?

Hope you figure out an optimal charging strategy!!

Energy Dashboard:

From smart meter - Sunspec integration:
Smartmeter Energy Real Consumption:
_total_watt_hours_imported

Smatermeter Energy Real Produced:
_total_watt_hours_exported

Total Photovoltaics Energy:
You’ll need to make your own template sensor - you can use if you have 2 strings - 1 on each input:
kw10_mppt_module_0_lifetime_energy + kw10_mppt_module_1_lifetime_energy

  - name: "Power Photovoltaics 10kw"
    unique_id: "power_photovoltaics_10kw"
    unit_of_measurement: W
    device_class: power
    state: "{{ states('sensor.kw10_mppt_module_0_dc_power') | float(default=0) 
    + states('sensor.kw10_mppt_module_1_dc_power') | float(default=0)}}"

And then integration sensor:

- platform: integration
  source: sensor.total_power_photovoltaics
  name: "Total Photovoltaics Energy"
  unit_prefix: k
  method: left

And Total Battery Energy Charge/Discharge
Same thing - you’ll need your own integration sensor for that based on:

kw10_mppt_module_3_dc_power
kw10_mppt_module_2_dc_power

- platform: integration
  source: sensor.kw10_mppt_module_2_dc_power
  name: "Total Battery Energy Charged"
  unit_prefix: k
  method: left

- platform: integration
  source: sensor.kw10_mppt_module_3_dc_power
  name: "Total Battery Energy Discharged"
  unit_prefix: k
  method: left

Something like that…

1 Like

Thanks!

For feed in effect (Fronius), I have this today:

{{ max(0, 0 - states('sensor.gen24_ac_meter_watts') | float) }}

And for ‘drawn effect’ (Fronius) I have this:

{{ max(0, states('sensor.gen24_ac_meter_watts') | float) }}

Is that wrong?

Yeah looks good if you’re measuring import/export power! Just remember the Energy dashboard requires Energy sensors - like:
Ac_meter Total Watt-hours Exported
Ac_meter Total Watt-hours Imported

@heyyitsal It all works now as expected, and I have removed the Fronius app. Finally everything is local!

Also, I have now run my Node-RED for some weeks and are satisfied, a few more parameters are now set as well (only charge the home battery if my HVAC doesn’t need to work hard for example)

The whole scheme is to large to add here, but if someone’s interested, please ask.

1 Like

Hi, thank you for the great examples!

My setup:

  • GEN24 10.0 plus
  • Tesla M3 battery (with BYD emulator) and capable of charge/discharge 10kW.

When I test it with my Gen24, I need to use start address 40358. With 40348 it doe snot work. How can that be?

If I do the following:

msg.StorCtl_Mod = "2"
// 4500W (65536-1500)
msg.OutWRte = "64036"

msg.newstate = "forcecharge1500w"

return msg

My inverter starts to charge with 6,2kW. I can not figure out why that is happening. Do you have an idea?

This is how I do force discharge of 1500W

msg.StorCtl_Mod = "1"
// 65536 - 1500
msg.InWRte = "64036"

msg.newstate = "1500wdischarge"

return msg

And force 1500 charge:

msg.StorCtl_Mod = "2"
// 4500W (65536-1500)
msg.OutWRte = "64036"

msg.newstate = "forcecharge1500w"

return msg

I’m also on the Gen24 Plus 10 kw, so it should be the same. But it may be related to your battery…

Try with 6 kw:

msg.StorCtl_Mod = "1"
// 65536 - 6000
msg.InWRte = "59536"

msg.newstate = "6000wdischarge"

return msg

And force charge:

msg.StorCtl_Mod = "2"
// 65536 - 6000
msg.InWRte = "59536"

msg.newstate = "6000wcharge"

return msg

You’re using “Int + SF” instead of “floats” (or the reverse …) this is set in the inverter under Modbus settings and the addresses change depending on that. Might also be why your charge is set to 6.2kW since that address is close to others if you’ve selected the “wrong” typesetting for your Modbus. Might also be the defaults in the BYD emu that is messing with your charge settings.

6.22kW also matches the testbed for the emu and when I read about it on github i always felt they missed the point of one of the datapoints they got “6240W” reported from the battery, now this is just a theory but i do believe the Gen24 actually utilitizes this data for setting the charge and discharge speeds when communicating with the battery since I know when my HVS 5.1 drops below 5 degrees the charge and discharge gets derated from 4.6kW-ish to 1500W-ish or so before it starts to heat up to proper temperatures again.

Very intrested in your complete works. Also have you considered using the calender function to create a map of sorts over the next 24 hours from 13.30 forward to try and optimize on a per day basis? Usually I have a baseload of around 2-5kW in the household during winter. Alleviating the most expensive hours with batterypower from the cheapest hours thus needs around 6 - 15 kWh to transfer those to the previous night or during mid-day cheap prices.

Here you go: Pastebin.com - Locked Paste

Password: qfgk5CaEPU

2 Likes

I think I’ve figured out a slight improvment of sort. (Ab)using the I/O Power Managment Controll Priorities to reduce yours (and my) number of writes to nvram on the inverter. By setting up a Export limitation that says NO discharge combined with a previous discharge command already written to modbus previously. We’ve now reduced the "normal switch to just a single Enable / Disable Export limitations command over Modbus. This requires Export Limitation to take the top spot in the Controlling Priorities que however, but as long as it is disabled this won’t affect the modbus commands.