Repository navigation
Fix/1p ac power scaling #123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,12 @@ | |
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| substitutions: | ||
| # Register 54 = "AC power ratio". Only scale when it reads a known 10W/LSB | ||
| # value; pass raw watts through otherwise (covers 1, 0/unsupported and the | ||
| # not-yet-read NaN state). | ||
| func_scale_ac_power: "return (id(ac_power_ratio).state == 10.0f) ? x * 10.0f : x;" | ||
|
|
||
| globals: | ||
| - id: last_total_energy_bought | ||
| type: float | ||
|
|
@@ -21,11 +27,29 @@ globals: | |
| restore_value: yes | ||
|
|
||
| sensor: | ||
| # Register 54 = "AC power ratio". Per the V119 protocol, the AC power registers | ||
| # 167-169, 170-172 and 176-178 are reported in units of this value (1W or 10W | ||
| # per LSB). Verified on hardware: SG02 10kW reads 10 (10W units), SG04 6kW | ||
| # reads 0 (1W units) - so only a value of 10 triggers scaling. | ||
| - platform: modbus_controller | ||
| modbus_controller_id: ${modbus_controller_id} | ||
| name: "AC Power Ratio" | ||
| id: ac_power_ratio | ||
| register_type: holding | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change register type to read only
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't it a holding register? modbus 0x03? is to read from the holding register
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In ESPHome's modbus_controller, register_type: read doesn't mean "read-only", it means input registers, read with Modbus function 0x04. Deye exposes everything as holding registers (function 0x03): my raw poll 01 03 0036 0001 used 0x03 and got an answer. Register_type: read = FC 0x04 input registers, which Deye doesn't serve (atleast according to the documentation), and that it would be inconsistent with every other sensor in the repo.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok you are right about register type. Instead make it: internal: true
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It never change and it is related to modbus version. In older release this register address is use as a different parameter. It may confuse other people. Also it is use to change values of other sensor. So it role is done and nothing more is needed.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh okay I understand. I will update it accordingly. |
||
| address: 54 | ||
| value_type: U_WORD | ||
| accuracy_decimals: 0 | ||
| entity_category: diagnostic | ||
| icon: "mdi:multiplication" | ||
| internal: true | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · Ratio is hidden from Home Assistant When a Home Assistant user or automation tries to inspect the documented AC Power Ratio entity, Remove Also at Prompt for AI agentsIn `pv_inverter/packages/deye_hybrid_1p/grid.yaml` at line 44:
**Ratio is hidden from Home Assistant**
When a Home Assistant user or automation tries to inspect the documented AC Power Ratio entity, `internal: true` keeps ESPHome from exposing the sensor to Home Assistant, so users and automations cannot inspect the ratio or applied factor.
Remove `internal: true` from the AC Power Ratio sensor.
Also at `pv_inverter/packages/deye_hybrid_1p/grid.yaml:45`. |
||
|
|
||
| - platform: modbus_controller | ||
| modbus_controller_id: ${modbus_controller_id} | ||
| name: "Grid L1 Power" | ||
| register_type: holding | ||
| address: 167 | ||
| filters: | ||
| - lambda: ${func_scale_ac_power} | ||
| unit_of_measurement: "W" | ||
| device_class: power | ||
| state_class: "measurement" | ||
|
|
@@ -38,6 +62,8 @@ sensor: | |
| name: "Grid L2 Power" | ||
| register_type: holding | ||
| address: 168 | ||
| filters: | ||
| - lambda: ${func_scale_ac_power} | ||
| unit_of_measurement: "W" | ||
| device_class: power | ||
| state_class: "measurement" | ||
|
|
@@ -50,6 +76,8 @@ sensor: | |
| name: "Grid Power" | ||
| register_type: holding | ||
| address: 169 | ||
| filters: | ||
| - lambda: ${func_scale_ac_power} | ||
| unit_of_measurement: "W" | ||
| device_class: power | ||
| state_class: "measurement" | ||
|
|
@@ -208,6 +236,8 @@ sensor: | |
| name: "External CT L1 Power" | ||
| register_type: holding | ||
| address: 170 | ||
| filters: | ||
| - lambda: ${func_scale_ac_power} | ||
| unit_of_measurement: "W" | ||
| device_class: power | ||
| accuracy_decimals: 0 | ||
|
|
@@ -219,6 +249,8 @@ sensor: | |
| name: "External CT L2 Power" | ||
| register_type: holding | ||
| address: 171 | ||
| filters: | ||
| - lambda: ${func_scale_ac_power} | ||
| unit_of_measurement: "W" | ||
| device_class: power | ||
| accuracy_decimals: 0 | ||
|
|
@@ -230,6 +262,8 @@ sensor: | |
| name: "External CT Power" | ||
| register_type: holding | ||
| address: 172 | ||
| filters: | ||
| - lambda: ${func_scale_ac_power} | ||
| unit_of_measurement: "W" | ||
| device_class: power | ||
| accuracy_decimals: 0 | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium · AC power reads are under-scaled
When register 54 fails or its initial read completes after AC power reads succeed on a 10 W/LSB inverter,
func_scale_ac_powerreturns rawxwhileac_power_ratiois unread or invalid, so affected power sensors publish values 10× too low until a valid ratio read and power poll succeed.Handle an unread or failed ratio separately from a genuine non-10 ratio so 10 W/LSB power is not published unscaled.
Also at
pv_inverter/packages/deye_hybrid_1p/load.yaml:19.Prompt for AI agents