InventoCasa/ha-advanced-blueprints

Add support for two-phase appliance usage

smileyman-1 opened this issue · 0 comments

Please add support for two-phase usage

The calculation of dynamic current control is only correct for usage with 1- oder 3-phase. However, if a 2-phase consumer is connected (On a 3-phase connected wallbox), the target value is not calculated appropriately.
Background: Application actual Power is the consumption value over 2 phases and not as expected over 3 phases.

2023-04-23 12:22:00.006 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] PV Excess (PV Power - Load Power) History: [-2746.0, 4837.0, 4278.0, 4999.0, 3398.0, 3204.0, 3113.0, 1054.0, 843.0, 1931.0, 1518.0, 2394.0, 4595.0, -347.0, 2012, -130.0, 468.0, 4267.0, -70.0, 188.0, -5.0, 570.0, 1475.0, 3581.0, 2166.0, 596.0, 1020.0, 472.0, 878.0, 2486.0, 1664.0, 2861.0, 2648.0, 3416, -1188.0, 1859.0, 2220.0, 3203.0, 3159.0, 4937.0, 4926.0, 5042.0, 4884.0, 3218.0, 387.0, 3345.0, 3131.0, 3116.0, 3231.0, 1874.0, 3155.0, 3144.0, 3247.0, 3173.0, 3116.0, 1224.0, 3847, 5856, -1201, -1358]
2023-04-23 12:22:00.006 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] Export History: [0, 4837.0, 4278.0, 4999.0, 3398.0, 3204.0, 3113.0, 1054.0, 843.0, 1931.0, 1518.0, 2394.0, 4595.0, 0, 2012, 0, 468.0, 4267.0, 0, 188.0, 0, 570.0, 1475.0, 3581.0, 2166.0, 596.0, 1020.0, 472.0, 878.0, 2486.0, 1664.0, 2861.0, 2648.0, 3416, 0, 1859.0, 2220.0, 3203.0, 3159.0, 4937.0, 4926.0, 5042.0, 4884.0, 3218.0, 387.0, 3345.0, 3131.0, 3116.0, 3231.0, 1874.0, 3155.0, 3144.0, 3247.0, 3173.0, 3116.0, 1224.0, 3847, 5856, 0, 0]
2023-04-23 12:22:00.006 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.wallbox_1_charging_enabled (Prio 1)] Home battery charge is sufficient (100/100.0 %) OR remaining solar forecast is higher than remaining capacity of home battery. Calculated average excess power based on >> solar power - load power <<: -1279 W
2023-04-23 12:22:00.006 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.wallbox_1_charging_enabled (Prio 1)] Appliance is already switched on.
2023-04-23 12:22:00.007 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.wallbox_1_charging_enabled (Prio 1)] Average Excess Power (-1279 W) is less than minimum excess power (-10 W).
2023-04-23 12:22:00.007 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.wallbox_1_charging_enabled (Prio 1)] actual_current=31.0A | diff_current=-5.6A | target_current=25.4A
2023-04-23 12:22:00.007 INFO (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.wallbox_1_charging_enabled (Prio 1)] Reducing dynamic current appliance from 31.0 A to 25.4 A.
2023-04-23 12:22:00.008 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.wallbox_1_charging_enabled (Prio 1)] Added diff_power=1288.0000000000002 W to prev_consumption_sum, which is now 1288.0000000000002 W.
2023-04-23 12:22:00.008 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] Adjusting power history by 1288.0000000000002.
2023-04-23 12:22:00.008 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] Export history: [0, 4837.0, 4278.0, 4999.0, 3398.0, 3204.0, 3113.0, 1054.0, 843.0, 1931.0, 1518.0, 2394.0, 4595.0, 0, 2012, 0, 468.0, 4267.0, 0, 188.0, 0, 570.0, 1475.0, 3581.0, 2166.0, 596.0, 1020.0, 472.0, 878.0, 2486.0, 1664.0, 2861.0, 2648.0, 3416, 0, 1859.0, 2220.0, 3203.0, 3159.0, 4937.0, 4926.0, 5042.0, 4884.0, 3218.0, 387.0, 3345.0, 3131.0, 3116.0, 3231.0, 1874.0, 3155.0, 3144.0, 3247.0, 3173.0, 3116.0, 1224.0, 3847, 5856, 0, 0]
2023-04-23 12:22:00.009 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] Adjusted export history: [0, 4837.0, 4278.0, 4999.0, 3398.0, 3204.0, 3113.0, 1054.0, 843.0, 1931.0, 1518.0, 2394.0, 4595.0, 0, 2012, 0, 468.0, 4267.0, 0, 188.0, 0, 570.0, 1475.0, 3581.0, 2166.0, 596.0, 1020.0, 472.0, 878.0, 2486.0, 1664.0, 2861.0, 2648.0, 3416, 0, 1859.0, 2220.0, 3203.0, 3159.0, 4937.0, 4926.0, 5042.0, 4884.0, 3218.0, 387.0, 3345.0, 3131.0, 3116.0, 3231.0, 1874.0, 3155.0, 3144.0, 3247.0, 3173.0, 3116.0, 1224.0, 3847, 5856, 1288.0000000000002, 1288.0000000000002]
2023-04-23 12:22:00.009 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] PV Excess (solar power - load power) history: [-2746.0, 4837.0, 4278.0, 4999.0, 3398.0, 3204.0, 3113.0, 1054.0, 843.0, 1931.0, 1518.0, 2394.0, 4595.0, -347.0, 2012, -130.0, 468.0, 4267.0, -70.0, 188.0, -5.0, 570.0, 1475.0, 3581.0, 2166.0, 596.0, 1020.0, 472.0, 878.0, 2486.0, 1664.0, 2861.0, 2648.0, 3416, -1188.0, 1859.0, 2220.0, 3203.0, 3159.0, 4937.0, 4926.0, 5042.0, 4884.0, 3218.0, 387.0, 3345.0, 3131.0, 3116.0, 3231.0, 1874.0, 3155.0, 3144.0, 3247.0, 3173.0, 3116.0, 1224.0, 3847, 5856, -1201, -1358]
2023-04-23 12:22:00.009 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] Adjusted PV Excess (solar power - load power) history: [-2746.0, 4837.0, 4278.0, 4999.0, 3398.0, 3204.0, 3113.0, 1054.0, 843.0, 1931.0, 1518.0, 2394.0, 4595.0, -347.0, 2012, -130.0, 468.0, 4267.0, -70.0, 188.0, -5.0, 570.0, 1475.0, 3581.0, 2166.0, 596.0, 1020.0, 472.0, 878.0, 2486.0, 1664.0, 2861.0, 2648.0, 3416, -1188.0, 1859.0, 2220.0, 3203.0, 3159.0, 4937.0, 4926.0, 5042.0, 4884.0, 3218.0, 387.0, 3345.0, 3131.0, 3116.0, 3231.0, 1874.0, 3155.0, 3144.0, 3247.0, 3173.0, 3116.0, 1224.0, 3847, 5856, 87.00000000000023, -69.99999999999977]
2023-04-23 12:22:00.044 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall number.set_value (c:01GYPT4ZA2WPHX7A9QP3E422EG): entity_id=['number.wallbox_1_current_limit_override'], value=25.4>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/core.py", line 1838, in catch_exceptions
await coro_or_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1857, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 216, in handle_service
await service.entity_service_call(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 798, in entity_service_call
future.result()  # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 977, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 838, in _handle_entity_call
await result
File "/usr/src/homeassistant/homeassistant/components/number/__init__.py", line 96, in async_set_value
raise ValueError(
ValueError: Value 25.4 for number.wallbox_1_current_limit_override is outside valid range 6.0 - 16.0
2023-04-23 12:23:00.005 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] PV Excess (PV Power - Load Power) History: [4837.0, 4278.0, 4999.0, 3398.0, 3204.0, 3113.0, 1054.0, 843.0, 1931.0, 1518.0, 2394.0, 4595.0, -347.0, 2012, -130.0, 468.0, 4267.0, -70.0, 188.0, -5.0, 570.0, 1475.0, 3581.0, 2166.0, 596.0, 1020.0, 472.0, 878.0, 2486.0, 1664.0, 2861.0, 2648.0, 3416, -1188.0, 1859.0, 2220.0, 3203.0, 3159.0, 4937.0, 4926.0, 5042.0, 4884.0, 3218.0, 387.0, 3345.0, 3131.0, 3116.0, 3231.0, 1874.0, 3155.0, 3144.0, 3247.0, 3173.0, 3116.0, 1224.0, 3847, 5856, 87.00000000000023, -69.99999999999977, 7]
2023-04-23 12:23:00.005 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] Export History: [4837.0, 4278.0, 4999.0, 3398.0, 3204.0, 3113.0, 1054.0, 843.0, 1931.0, 1518.0, 2394.0, 4595.0, 0, 2012, 0, 468.0, 4267.0, 0, 188.0, 0, 570.0, 1475.0, 3581.0, 2166.0, 596.0, 1020.0, 472.0, 878.0, 2486.0, 1664.0, 2861.0, 2648.0, 3416, 0, 1859.0, 2220.0, 3203.0, 3159.0, 4937.0, 4926.0, 5042.0, 4884.0, 3218.0, 387.0, 3345.0, 3131.0, 3116.0, 3231.0, 1874.0, 3155.0, 3144.0, 3247.0, 3173.0, 3116.0, 1224.0, 3847, 5856, 1288.0000000000002, 1288.0000000000002, 7]
2023-04-23 12:23:00.006 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.wallbox_1_charging_enabled (Prio 1)] Home battery charge is sufficient (100/100.0 %) OR remaining solar forecast is higher than remaining capacity of home battery. Calculated average excess power based on >> solar power - load power <<: -31 W
2023-04-23 12:23:00.006 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.wallbox_1_charging_enabled (Prio 1)] Appliance is already switched on.
2023-04-23 12:23:00.006 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.wallbox_1_charging_enabled (Prio 1)] Average Excess Power (-31 W) is less than minimum excess power (-10 W).
2023-04-23 12:23:00.007 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.wallbox_1_charging_enabled (Prio 1)] actual_current=11.9A | diff_current=-0.1A | target_current=11.8A
2023-04-23 12:23:00.007 INFO (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.wallbox_1_charging_enabled (Prio 1)] Reducing dynamic current appliance from 11.9 A to 11.8 A.
2023-04-23 12:23:00.007 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] [switch.wallbox_1_charging_enabled (Prio 1)] Added diff_power=22.99999999999992 W to prev_consumption_sum, which is now 22.99999999999992 W.
2023-04-23 12:23:00.007 DEBUG (MainThread) [custom_components.pyscript.file.pv_excess_control.on_time] Adjusting power history by 22.99999999999992.

Thanks for the great solution.