reinhard-brandstaedter / solarflow-control

A tool to automatically control Zendure's Solarflow hub with more flexibility to match home power demand
67 stars 12 forks source link

Should the hub also trigger limit function? #212

Closed mavo closed 5 months ago

mavo commented 5 months ago

Hi @reinhard-brandstaedter,

I am not sure if this was like it before, I only started to notice today (I changed to latest master yesterday in the morning ours). For some reason (maybe even wanted) I do not see any "hub triggers limit function" calls, which I would expect when the hub input changes. The result for me is, that when the sun is out, household demand is matched, all good. But then a dark cloud happens to appear, as the hub is not triggering any update, my battery is then used to keep the inverter at its desired output rate (or the other way around, battery is fed instead of home).

Here are my startup logs:

2024-04-15 13:22:08,713:INFO: Solarflow Hub: A8yh63/ETFTke36
2024-04-15 13:22:08,713:INFO: Limit via inverter: True
2024-04-15 13:22:08,713:INFO: Control Parameters:
2024-04-15 13:22:08,713:INFO:   MIN_CHARGE_POWER = 0
2024-04-15 13:22:08,713:INFO:   MAX_DISCHARGE_LEVEL = 800
2024-04-15 13:22:08,713:INFO:   MAX_INVERTER_LIMIT = 920
2024-04-15 13:22:08,713:INFO:   MAX_INVERTER_INPUT = 920
2024-04-15 13:22:08,713:INFO:   SUNRISE_OFFSET = 60
2024-04-15 13:22:08,713:INFO:   SUNSET_OFFSET = 60
2024-04-15 13:22:08,920:INFO: Using AhoyDTU: Base topic: ahoydtu, Limit topic: ahoydtu/ctrl/limit/0, SF Channels: [3, 4]
2024-04-15 13:22:08,920:INFO: Using ShellyEM3: Base topic: shellies/shellyem3
2024-04-15 13:22:08,921:INFO: Connected to MQTT Broker!
2024-04-15 13:22:08,921:INFO: Hub subscribing: /A8yh63/ETFTke36/properties/report
2024-04-15 13:22:08,921:INFO: Hub subscribing: solarflow-hub/ETFTke36/telemetry/solarInputPower
2024-04-15 13:22:08,921:INFO: Hub subscribing: solarflow-hub/ETFTke36/telemetry/electricLevel
2024-04-15 13:22:08,921:INFO: Hub subscribing: solarflow-hub/ETFTke36/telemetry/outputPackPower
2024-04-15 13:22:08,921:INFO: Hub subscribing: solarflow-hub/ETFTke36/telemetry/packInputPower
2024-04-15 13:22:08,922:INFO: Hub subscribing: solarflow-hub/ETFTke36/telemetry/outputHomePower
2024-04-15 13:22:08,922:INFO: Hub subscribing: solarflow-hub/ETFTke36/telemetry/outputLimit
2024-04-15 13:22:08,922:INFO: Hub subscribing: solarflow-hub/ETFTke36/telemetry/inverseMaxPower
2024-04-15 13:22:08,922:INFO: Hub subscribing: solarflow-hub/ETFTke36/telemetry/masterSoftVersion
2024-04-15 13:22:08,922:INFO: Hub subscribing: solarflow-hub/ETFTke36/telemetry/pass
2024-04-15 13:22:08,922:INFO: Hub subscribing: solarflow-hub/ETFTke36/telemetry/batteries/+/socLevel
2024-04-15 13:22:08,922:INFO: Hub subscribing: solarflow-hub/ETFTke36/telemetry/batteries/+/totalVol
2024-04-15 13:22:08,923:INFO: Hub subscribing: solarflow-hub/ETFTke36/control/#
2024-04-15 13:22:08,923:INFO: DTU subscribing: ahoydtu/HM-1600/+/P_DC
2024-04-15 13:22:08,923:INFO: DTU subscribing: ahoydtu/HM-1600/ch0/P_AC
2024-04-15 13:22:08,923:INFO: DTU subscribing: ahoydtu/HM-1600/ch0/active_PowerLimit
2024-04-15 13:22:08,923:INFO: DTU subscribing: ahoydtu/status
2024-04-15 13:22:08,923:INFO: DTU subscribing: solarflow-hub/+/control/dryRun
2024-04-15 13:22:08,923:INFO: Shelly3EM subscribing: shellies/shellyem3/emeter/0/power
2024-04-15 13:22:08,923:INFO: Shelly3EM subscribing: shellies/shellyem3/emeter/1/power
2024-04-15 13:22:08,924:INFO: Shelly3EM subscribing: shellies/shellyem3/emeter/2/power
2024-04-15 13:22:08,925:INFO: Reading last full time: 2024-04-12 17:10:29
2024-04-15 13:22:08,925:INFO: Reading battery target mode: discharging

And here are some logs from the app running:

2024-04-15 13:35:08,929:INFO: Triggering telemetry update: iot/A8yh63/ETFTke36/properties/read
2024-04-15 13:36:08,923:INFO: HUB: S:89.4W [ 91.0,91.0,89.4 ], B: 31% (31|32), V:49.4V (49.4|49.4), C: 22W, P:False, F:68.4h, E:-1.0h, H: 78W, L:800W
2024-04-15 13:36:08,926:INFO: INV: AC:87.8W, AC_Prediction: 87.7W, DC:92.4W, DC_prediction: 92.3W (0.0|0.0|46.7|45.7), L:190.4W [1600W]
2024-04-15 13:36:08,928:INFO: SMT: T:ShellyEM3 P:285.0W [ 279.5,279.5,277.8,277.9,277.6,283.9 ] Predict: 277.2W
2024-04-15 13:36:08,928:INFO: Direct connected panels (0.0W) can't cover demand (371.7W), trying to get rest from hub.
2024-04-15 13:36:08,928:INFO: Checking if Solarflow is willing to contribute 371.7W ...
2024-04-15 13:36:08,929:INFO: Based on time, solarpower (89.4W) minimum charge power (0W) and bypass state (False), hub could contribute 89.4W - Decision path: 2.2.
2024-04-15 13:36:08,929:INFO: Hub should contribute more (89.0W) than what we currently get from panels (0.0W), we will use the inverter for fast/precise limiting!
2024-04-15 13:36:08,929:INFO: Not setting solarflow output limit to 800.0W as it is identical to current limit!
2024-04-15 13:36:08,929:INFO: Setting inverter output limit to 176W (1 min moving average of 44W x 4)
2024-04-15 13:36:08,929:INFO: Sun: 06:09 - 20:07 Demand: 371.7W, Panel DC: (0.0|0.0), Hub DC: (46.7|45.7), Inverter Limit: 176.0W, Hub Limit: 800.0W
2024-04-15 13:36:08,930:INFO: Triggering telemetry update: iot/A8yh63/ETFTke36/properties/read
2024-04-15 13:37:08,930:INFO: Triggering telemetry update: iot/A8yh63/ETFTke36/properties/read
2024-04-15 13:38:08,923:INFO: HUB: S:134.5W [ 130.5,130.5,131.0,131.5,133.0,134.5 ], B: 31% (31|32), V:49.5V (49.5|49.4), C: 56W, P:False, F:68.5h, E:-1.0h, H: 78W, L:800W
2024-04-15 13:38:08,927:INFO: INV: AC:87.8W, AC_Prediction: 87.8W, DC:92.4W, DC_prediction: 92.4W (0.0|0.0|46.7|45.7), L:176.0W [1600W]
2024-04-15 13:38:08,928:INFO: SMT: T:ShellyEM3 P:276.9W [ 279.3,279.3,277.6,273.4,270.2,266.0 ] Predict: 296.5W
2024-04-15 13:38:08,928:INFO: Direct connected panels (0.0W) can't cover demand (353.8W), trying to get rest from hub.
2024-04-15 13:38:08,928:INFO: Checking if Solarflow is willing to contribute 353.8W ...
2024-04-15 13:38:08,929:INFO: Based on time, solarpower (134.5W) minimum charge power (0W) and bypass state (False), hub could contribute 134.5W - Decision path: 2.2.
2024-04-15 13:38:08,929:INFO: Hub should contribute more (134.0W) than what we currently get from panels (0.0W), we will use the inverter for fast/precise limiting!
2024-04-15 13:38:08,929:INFO: Not setting solarflow output limit to 800.0W as it is identical to current limit!
2024-04-15 13:38:08,929:INFO: Setting inverter output limit to 268W (1 min moving average of 67W x 4)
2024-04-15 13:38:08,930:INFO: Sun: 06:09 - 20:07 Demand: 353.8W, Panel DC: (0.0|0.0), Hub DC: (46.7|45.7), Inverter Limit: 268.0W, Hub Limit: 800.0W
2024-04-15 13:38:08,930:INFO: Triggering telemetry update: iot/A8yh63/ETFTke36/properties/read
2024-04-15 13:39:08,931:INFO: Triggering telemetry update: iot/A8yh63/ETFTke36/properties/read
2024-04-15 13:40:08,923:INFO: HUB: S:173.1W [ 165.7,165.7,167.3,169.6,171.6,173.1 ], B: 31% (31|32), V:49.5V (49.5|49.4), C: 77W, P:False, F:68.5h, E:-1.0h, H: 95W, L:800W
2024-04-15 13:40:08,927:INFO: INV: AC:102.9W, AC_Prediction: 101.8W, DC:108.3W, DC_prediction: 107.3W (0.0|0.0|54.7|53.5), L:267.2W [1600W]
2024-04-15 13:40:08,929:INFO: SMT: T:ShellyEM3 P:243.0W [ 264.5,264.5,264.2,262.4,260.2,258.9 ] Predict: 272.5W
2024-04-15 13:40:08,929:INFO: Direct connected panels (0.0W) can't cover demand (361.8W), trying to get rest from hub.
2024-04-15 13:40:08,929:INFO: Checking if Solarflow is willing to contribute 361.8W ...
2024-04-15 13:40:08,930:INFO: Based on time, solarpower (173.1W) minimum charge power (0W) and bypass state (False), hub could contribute 173.1W - Decision path: 2.2.
2024-04-15 13:40:08,930:INFO: Hub should contribute more (173.0W) than what we currently get from panels (0.0W), we will use the inverter for fast/precise limiting!
2024-04-15 13:40:08,930:INFO: Not setting solarflow output limit to 800.0W as it is identical to current limit!
2024-04-15 13:40:08,930:INFO: Setting inverter output limit to 344W (1 min moving average of 86W x 4)
2024-04-15 13:40:08,931:INFO: Sun: 06:09 - 20:07 Demand: 361.8W, Panel DC: (0.0|0.0), Hub DC: (54.7|53.5), Inverter Limit: 344.0W, Hub Limit: 800.0W
2024-04-15 13:40:08,931:INFO: Triggering telemetry update: iot/A8yh63/ETFTke36/properties/read
2024-04-15 13:40:18,178:INFO: HUB: S:178.2W [ 168.1,168.1,170.4,172.0,174.8,178.2 ], B: 31% (31|32), V:49.5V (49.5|49.4), C: 58W, P:False, F:68.5h, E:-1.0h, H:124W, L:800W
2024-04-15 13:40:18,181:INFO: INV: AC:109.3W, AC_Prediction: 100.8W, DC:115.0W, DC_prediction: 106.3W (0.0|0.0|91.3|89.0), L:267.2W [1600W]
2024-04-15 13:40:18,183:INFO: SMT: T:ShellyEM3 P:167.7W [ 257.1,257.1,254.4,249.8,245.1,233.6 ] Predict: 283.1W
2024-04-15 13:40:18,183:INFO: Direct connected panels (0.0W) can't cover demand (342.9W), trying to get rest from hub.
2024-04-15 13:40:18,183:INFO: Checking if Solarflow is willing to contribute 342.9W ...
2024-04-15 13:40:18,183:INFO: Based on time, solarpower (178.2W) minimum charge power (0W) and bypass state (False), hub could contribute 178.2W - Decision path: 2.2.
2024-04-15 13:40:18,184:INFO: Hub should contribute more (178.0W) than what we currently get from panels (0.0W), we will use the inverter for fast/precise limiting!
2024-04-15 13:40:18,184:INFO: Not setting solarflow output limit to 800.0W as it is identical to current limit!
2024-04-15 13:40:18,184:INFO: Setting inverter output limit to 356W (1 min moving average of 89W x 4)
2024-04-15 13:40:18,184:INFO: Sun: 06:09 - 20:07 Demand: 342.9W, Panel DC: (0.0|0.0), Hub DC: (91.3|89.0), Inverter Limit: 356.0W, Hub Limit: 800.0W
2024-04-15 13:40:18,184:INFO: SMT triggers limit function: 245.1 -> 233.6: executed
2024-04-15 13:40:18,188:INFO: SMT triggers limit function: 244.0 -> 232.1: skipped
2024-04-15 13:40:18,192:INFO: SMT triggers limit function: 243.0 -> 230.7: skipped
2024-04-15 13:40:19,585:INFO: SMT triggers limit function: 242.0 -> 230.1: skipped
2024-04-15 13:40:19,589:INFO: SMT triggers limit function: 241.2 -> 229.5: skipped
2024-04-15 13:40:19,593:INFO: SMT triggers limit function: 240.9 -> 229.3: skipped
2024-04-15 13:40:20,190:INFO: SMT triggers limit function: 239.7 -> 227.0: skipped
2024-04-15 13:40:20,194:INFO: SMT triggers limit function: 239.4 -> 226.8: skipped
2024-04-15 13:40:20,199:INFO: SMT triggers limit function: 239.2 -> 226.6: skipped
2024-04-15 13:40:20,585:INFO: SMT triggers limit function: 238.9 -> 226.5: skipped
2024-04-15 13:40:20,589:INFO: SMT triggers limit function: 238.6 -> 226.3: skipped
2024-04-15 13:40:20,594:INFO: SMT triggers limit function: 238.1 -> 225.6: skipped
2024-04-15 13:40:22,202:INFO: SMT triggers limit function: 236.6 -> 219.9: skipped
2024-04-15 13:40:22,207:INFO: SMT triggers limit function: 236.0 -> 219.3: skipped
2024-04-15 13:40:22,212:INFO: SMT triggers limit function: 235.4 -> 218.6: skipped
2024-04-15 13:40:24,214:INFO: HUB: S:180.6W [ 171.1,171.1,172.8,175.6,176.8,180.6 ], B: 31% (31|32), V:49.5V (49.5|49.4), C: 37W, P:False, F:68.5h, E:-1.0h, H:147W, L:800W
2024-04-15 13:40:24,219:INFO: INV: AC:124.3W, AC_Prediction: 99.3W, DC:130.8W, DC_prediction: 105.1W (0.0|0.0|83.7|81.7), L:267.2W [1600W]
2024-04-15 13:40:24,221:INFO: SMT: T:ShellyEM3 P:186.9W [ 250.3,250.3,245.6,240.6,232.8,214.8 ] Predict: 285.4W
2024-04-15 13:40:24,221:INFO: Direct connected panels (0.0W) can't cover demand (339.1W), trying to get rest from hub.
2024-04-15 13:40:24,221:INFO: Checking if Solarflow is willing to contribute 339.1W ...
2024-04-15 13:40:24,222:INFO: Based on time, solarpower (180.6W) minimum charge power (0W) and bypass state (False), hub could contribute 180.6W - Decision path: 2.2.
2024-04-15 13:40:24,222:INFO: Hub should contribute more (180.0W) than what we currently get from panels (0.0W), we will use the inverter for fast/precise limiting!
2024-04-15 13:40:24,222:INFO: Not setting solarflow output limit to 800.0W as it is identical to current limit!
2024-04-15 13:40:24,222:INFO: Setting inverter output limit to 360W (1 min moving average of 90W x 4)
2024-04-15 13:40:24,223:INFO: Sun: 06:09 - 20:07 Demand: 339.1W, Panel DC: (0.0|0.0), Hub DC: (83.7|81.7), Inverter Limit: 360.0W, Hub Limit: 800.0W
2024-04-15 13:40:24,223:INFO: SMT triggers limit function: 232.8 -> 214.8: executed
2024-04-15 13:40:24,227:INFO: SMT triggers limit function: 232.2 -> 214.3: skipped
2024-04-15 13:40:24,231:INFO: SMT triggers limit function: 231.7 -> 213.9: skipped
2024-04-15 13:40:24,309:INFO: DTU triggers limit function: 133.1 -> 98.9: skipped

From this log you can nicely see, that the radiation did increase, but nothing was triggered. At some point, some trigger happen and fix the "offset", but its not ideal.

Is this how it should be? If yes, please just close this ticket with a comment so that it does not clutter the other tickets.

reinhard-brandstaedter commented 5 months ago

I haven’t seen any need to trigger things on hub change. Usually this is reflected in DTU changes or smartmeter changes.

mavo commented 5 months ago

But if the demand of house does not change (a lot), its not triggering anything. Same for DTU, does not change as its stable fed by the hub/battery.

This can happen with no direct connected panels. And in those cases its actually required. Is it actually hard to incorporate something like this?

reinhard-brandstaedter commented 5 months ago

Not difficult, but usually too many triggers (that are linked) creates unnecessary steering noise. Already today a change happening on the DTU likely triggers a change on the smartmeter as well. A change on the hub usually also (in combination with min charge power) usually also triggers a change on the inverter. And as a backup there is still the regular interval trigger.

mavo commented 5 months ago

Not difficult, but usually too many triggers (that are linked) creates unnecessary steering noise.

Understood. However, for me (and most likely for all having no direct panels), the DTU does not trigger too much, as it only changes when the SMT changes due to changes in demand. Maybe the app can recognize when there is no direct connected panels...?

And as a backup there is still the regular interval trigger.

Which is somewhat slowish.... 🤔

reinhard-brandstaedter commented 5 months ago

The challenge here is that the hub usually reports it's solarpower very frequently, the more change the faster actually. So if we would want the hub to trigger the limit function as well we will need some kind of fixed time window (not a moving avg) to determine a significant change, otherwise it would just be a a short-interval of minimal changes (and we certainly do not want to trigger on those) See this reported data:

image
mavo commented 5 months ago

we will need some kind of fixed time window (not a moving avg)

Which is tricky, as it might happen that the hub does not report anything if it does not change, such as it was the case for me when the shelly did not update with the fixed interval? As far as I get it, those fixed time window is also used for the usage reported by the SMT, isn't it?

I mean, I get that this is not THE most urgent issue and also it does work and only happens on day time, so you won't feed energy to the grid (at least I did not see this yet and also cannot come with a situation this happens and can be prevented by this trigger). On the other side, it would be great to have this, as in my config the only trigger thats left is the SMT, and if this does not change I need to wait for the regular interval. I was thinking about some sort of script which changes the DTU ever so slightly in intervals in case there was no change in the inverter reported. However, not only feels wrong, but also is as this would interfere with the whole sf-control eventually 😵

reinhard-brandstaedter commented 5 months ago

No, the smartmeter uses a moving average window of 10s, since there are typically up/down movements on the smartmeter this works well for triggering adjustments on change. (because the change is usually not +2W every 2 seconds, but rather something like +60W or more instantly).

I'm running with no direct panels for a couple of weeks now and I haven't seen any issue with this setup. You are not loosing any energy. If it doesn't go to the house it goes to the battery, and since you are running with a min_charge level of 0 (I still don't see the benefit of that) it will be adjusted soon enough. You are just getting a bit of charge power for max 2 mins.

mavo commented 5 months ago

As said, it's not really an issue. I was under the impression the hub would trigger as well. It does not, it's fine.

Regarding the 0w min charge - why not. For me, feeding the house has prio and it does not actually matter when the produced energy is used. Isn't it? For me, why I think it's good to do it like this is that in summer months, I think I might end up with a battery being full earlier in the day. So my goal (and summer might prove me wrong here) is to feed in as little as possible, that's why I prefer home consumption.

reinhard-brandstaedter commented 5 months ago

The latest master does have a trigger on hub solarinput change. Try if this changes the steering cadence for you.

mavo commented 5 months ago

You are an absolute hero! I'll try, but I probably won't have a result tomorrow, as it's time for a full charge cycle :-)

reinhard-brandstaedter commented 5 months ago

HUB triggers limit function now correctly