Skip to content

Commit

Permalink
Fix charge_priority_en in hold/21/bits message (#201)
Browse files Browse the repository at this point in the history
* Fix charge_priority_en in hold/21/bits message

* Update CHANGELOG for #201
  • Loading branch information
celsworth authored Sep 29, 2023
1 parent e4d0d99 commit 883e25d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Avoid floating point maths oddities in e_pv_day and e_pv_all calculations (#185)
* Add internal_fault/warning_code/fault_code keys (#189, #190, #191)
* Revert to unsigned integers for inverter registers/values (#196)
* Fix charge_priority_en value in hold/21/bits MQTT message (#201)


# 0.11.0 - 16th July 2023
Expand Down
2 changes: 1 addition & 1 deletion src/lxp/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ impl Register21Bits {
sw_seamless_en: Self::is_bit_set(data, 1 << 8),
set_to_standby: Self::is_bit_set(data, 1 << 9),
forced_discharge_en: Self::is_bit_set(data, 1 << 10),
charge_priority_en: Self::is_bit_set(data, 1 << 1),
charge_priority_en: Self::is_bit_set(data, 1 << 11),
iso_en: Self::is_bit_set(data, 1 << 12),
gfci_en: Self::is_bit_set(data, 1 << 13),
dci_en: Self::is_bit_set(data, 1 << 14),
Expand Down
16 changes: 16 additions & 0 deletions tests/test_mqtt_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,22 @@ async fn for_hold_21() {
mqtt::Message { topic: "2222222222/hold/21/bits".to_owned(), retain: true, payload: "{\"eps_en\":\"OFF\",\"ovf_load_derate_en\":\"OFF\",\"drms_en\":\"ON\",\"lvrt_en\":\"ON\",\"anti_island_en\":\"OFF\",\"neutral_detect_en\":\"OFF\",\"grid_on_power_ss_en\":\"OFF\",\"ac_charge_en\":\"OFF\",\"sw_seamless_en\":\"OFF\",\"set_to_standby\":\"ON\",\"forced_discharge_en\":\"OFF\",\"charge_priority_en\":\"OFF\",\"iso_en\":\"OFF\",\"gfci_en\":\"ON\",\"dci_en\":\"OFF\",\"feed_in_grid_en\":\"OFF\"}".to_owned() }
]
);

// really should do every bit but thats very tedious.. lets just do this one for now
let packet = lxp::packet::TranslatedData {
datalog: inverter.datalog(),
device_function: lxp::packet::DeviceFunction::ReadHold,
inverter: inverter.serial(),
register: 21,
values: vec![0, 8],
};

assert_eq!(
mqtt::Message::for_hold(packet).unwrap(),
vec![mqtt::Message { topic: "2222222222/hold/21".to_owned(), retain: true, payload: "2048".to_owned() },
mqtt::Message { topic: "2222222222/hold/21/bits".to_owned(), retain: true, payload: "{\"eps_en\":\"OFF\",\"ovf_load_derate_en\":\"OFF\",\"drms_en\":\"OFF\",\"lvrt_en\":\"OFF\",\"anti_island_en\":\"OFF\",\"neutral_detect_en\":\"OFF\",\"grid_on_power_ss_en\":\"OFF\",\"ac_charge_en\":\"OFF\",\"sw_seamless_en\":\"OFF\",\"set_to_standby\":\"OFF\",\"forced_discharge_en\":\"OFF\",\"charge_priority_en\":\"ON\",\"iso_en\":\"OFF\",\"gfci_en\":\"OFF\",\"dci_en\":\"OFF\",\"feed_in_grid_en\":\"OFF\"}".to_owned() }
]
);
}

#[tokio::test]
Expand Down

0 comments on commit 883e25d

Please sign in to comment.