Skip to content

Map GECloud three-phase *_power_rate controls to percent-rate entities#3817

Merged
springfall2008 merged 9 commits intomainfrom
copilot/fix-gecloud-inverter-rate-issues
Apr 23, 2026
Merged

Map GECloud three-phase *_power_rate controls to percent-rate entities#3817
springfall2008 merged 9 commits intomainfrom
copilot/fix-gecloud-inverter-rate-issues

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 21, 2026

GECloud auto-configuration was assigning three-phase charge_power_rate / discharge_power_rate number entities to watt-based charge_rate / discharge_rate. These entities are percentage controls and should be wired through the percent-rate paths.

  • Auto-config rate mapping correction (apps/predbat/gecloud.py)

    • Removed charge_power_rate / discharge_power_rate from watt-rate entity candidates.
    • Added detection for three-phase percent-rate register names.
    • Mapped three-phase rate controls to:
      • charge_rate_percent via inverter_charge_power_percentage fallback to charge_power_rate
      • discharge_rate_percent via inverter_discharge_power_percentage fallback to discharge_power_rate
    • Kept existing behavior for standard watt-based battery_charge_power / battery_discharge_power.
  • Targeted GECloud config test update (apps/predbat/tests/test_ge_cloud.py)

    • Updated the three-phase auto-config assertions to verify:
      • charge_rate / discharge_rate are not populated from *_power_rate
      • charge_rate_percent / discharge_rate_percent use the *_power_rate entities
# three-phase mapping now uses percent-rate channels
self.set_arg("charge_rate", build_entities("number", ["battery_charge_power"]))
self.set_arg("discharge_rate", build_entities("number", ["battery_discharge_power"]))

charge_rate_percent = build_entities("number", ["inverter_charge_power_percentage", "charge_power_rate"])
discharge_rate_percent = build_entities("number", ["inverter_discharge_power_percentage", "discharge_power_rate"])

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • gitlab.com
    • Triggering command: /usr/lib/git-core/git-remote-https /usr/lib/git-core/git-remote-https origin REDACTED (dns block)
  • https://api.github.com/repos/springfall2008/batpred/contents/apps/predbat
    • Triggering command: /home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --quick (http block)
    • Triggering command: /home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --list (http block)
    • Triggering command: /home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --test ge_cloud (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Fix charge and discharge rate units in GECloud inverter Map GECloud three-phase *_power_rate controls to percent-rate entities Apr 21, 2026
Copilot AI requested a review from springfall2008 April 21, 2026 23:27
@springfall2008
Copy link
Copy Markdown
Owner

@copilot you havne't fixed this code

                if "%" in reg_name:
                    attributes["device_class"] = "battery"
                    attributes["unit_of_measurement"] = "%"
                elif "_power_percent" in ha_name:
                    attributes["device_class"] = "power_factor"
                    attributes["unit_of_measurement"] = "%"
                elif "_power" in ha_name:
                    attributes["device_class"] = "power"
                    attributes["unit_of_measurement"] = "W"

It needs to account for _power_rate being in percent

Copilot AI and others added 2 commits April 21, 2026 23:31
Agent-Logs-Url: https://github.com/springfall2008/batpred/sessions/b8258764-acf4-4a79-9294-4dd5ae8ad39c

Co-authored-by: springfall2008 <48591903+springfall2008@users.noreply.github.com>
Removed fallback assignment for charge and discharge rates.
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 21, 2026

@copilot you havne't fixed this code

                if "%" in reg_name:

...

Updated in 7ea42c9. publish_registers now treats _power_rate the same as _power_percent, so these entities are published with unit_of_measurement: % and device_class: power_factor instead of watts/power. I also added a focused test in test_publish_registers to cover Charge Power Rate metadata.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/springfall2008/batpred/contents/apps/predbat
    • Triggering command: /home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --test ge_cloud (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@springfall2008 springfall2008 marked this pull request as ready for review April 21, 2026 23:34
Copilot AI review requested due to automatic review settings April 21, 2026 23:34
@springfall2008
Copy link
Copy Markdown
Owner

@copilot The tests are failing you need to fix

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes GECloud auto-configuration for three-phase systems where *_power_rate number entities represent percentage rate controls (0–100%) but were previously being wired into watt-based charge_rate / discharge_rate config channels.

Changes:

  • Corrected GECloud auto-config entity candidate selection so charge_power_rate / discharge_power_rate map to charge_rate_percent / discharge_rate_percent instead of watt-based rate args.
  • Updated GECloud register publishing to classify *_power_rate number entities as percent-based controls (unit %, device_class=power_factor).
  • Updated GECloud tests to validate three-phase mapping and added a targeted assertion for percent attributes on the published charge_power_rate entity.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
apps/predbat/gecloud.py Adjusts register attribute classification and auto-config mapping to route three-phase *_power_rate controls through percent-rate args.
apps/predbat/tests/test_ge_cloud.py Updates auto-config assertions for three-phase setups and adds a publish-registers check for percent attributes on charge_power_rate.

Comment thread apps/predbat/gecloud.py
Comment on lines 713 to 718
if "%" in reg_name:
attributes["device_class"] = "battery"
attributes["unit_of_measurement"] = "%"
elif "_power_percent" in ha_name:
elif "_power_percent" in ha_name or "_power_rate" in ha_name:
attributes["device_class"] = "power_factor"
attributes["unit_of_measurement"] = "%"
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In publish_registers, percent-like registers such as Battery Reserve Percent Limit (e.g. HA name battery_reserve_percent_limit) won’t get unit_of_measurement/device_class because the code only treats registers as percent when the raw register name contains a literal %. The GE Cloud register names in tests use the word Percent (no %), so these entities will be published without a unit.

Consider detecting percentage registers based on the normalized ha_name (e.g. contains _percent) in addition to the % symbol, while keeping the special-cases for power percent/rate and watt-based _power registers.

Copilot uses AI. Check for mistakes.
Copilot AI and others added 2 commits April 21, 2026 23:42
Agent-Logs-Url: https://github.com/springfall2008/batpred/sessions/24987fae-5e8c-498a-940a-70bcb25389cc

Co-authored-by: springfall2008 <48591903+springfall2008@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 21, 2026

@copilot The tests are failing you need to fix

Fixed in 0dc91a2 (with a small follow-up in 8951973). I restored GECloud charge_rate_percent/discharge_rate_percent fallback assignment and stabilized the flaky manual_select test time parsing; the targeted failing tests now pass locally (ge_cloud and manual_select). No UI changes for this fix.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.octopus.energy
    • Triggering command: /home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --quick (dns block)
  • gitlab.com
    • Triggering command: /usr/lib/git-core/git-remote-https /usr/lib/git-core/git-remote-https origin REDACTED git conf�� get --global bin/lsb_release committer.email (dns block)
    • Triggering command: /usr/lib/git-core/git-remote-https /usr/lib/git-core/git-remote-https origin REDACTED git conf�� get --global release committer.email (dns block)
  • https://api.github.com/repos/springfall2008/batpred/contents/apps/predbat
    • Triggering command: /home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --test manual_select (http block)
    • Triggering command: /home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --test ge_cloud (http block)
    • Triggering command: /home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --quick (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@springfall2008
Copy link
Copy Markdown
Owner

@copilot The manual select tests are failing

Agent-Logs-Url: https://github.com/springfall2008/batpred/sessions/c43680af-98fa-402c-96ba-027ab946f2bc

Co-authored-by: springfall2008 <48591903+springfall2008@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 23, 2026

@copilot The manual select tests are failing

Fixed in b36346b. I made the manual_select test robust at day boundaries by preferring a non-today dropdown label and using the full day+time label for the conflict-removal checks; manual_select now passes consistently in repeated runs.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/springfall2008/batpred/contents/apps/predbat
    • Triggering command: /usr/bin/python3 python3 ../apps/predbat/unit_test.py --test ge_cloud (http block)
    • Triggering command: /home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --test manual_select (http block)
    • Triggering command: /home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --test ge_cloud (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@springfall2008 springfall2008 merged commit e463bf4 into main Apr 23, 2026
1 check passed
@springfall2008 springfall2008 deleted the copilot/fix-gecloud-inverter-rate-issues branch April 23, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GECloud three phase inverter charge/discharge rate is in watts

3 participants