Skip to content
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

Rewrite packet parsing code #249

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Rewrite packet parsing code #249

wants to merge 19 commits into from

Conversation

celsworth
Copy link
Owner

@celsworth celsworth commented Mar 13, 2024

This will be a long-lived PR to try and address the list in https://github.com/celsworth/lxp-bridge/issues/245

I'll create smaller separate PRs and merge into this to try and keep it manageable.

This adds a new configuration option, publish_inputs_all_trigger. This lives at the root of the config (ie next to loglevel). By default, this is 80. If you have an inverter which publishes 4 sets of inputs data packets (like newer EG4 inverters with generator inputs) you probably need to bump this to 120 to get inputs/all sent with all the correct data.

However, with this release I'm heavily deprecating the MQTT messages inputs/1 (and 2 / 3 / 4) and inputs/all. Please do not use them in any new projects. Instead, use the individual messages published when each register is received. These have topics like input/status/parsed, input/e_pv_day_1/parsed etc and the payloads are equivalent to the old ones.

TODO:

  • re-add database support, it is missing
  • params messages are not implemented yet, but I don't think I'll bother as they weren't that useful.

* Improve RegisterCache to support Hold/Input registers

And write all incoming data to it

* Update CHANGELOG
…ption (#250)

* Remove (and enable unconditionally) publish_individual_input config option

* Update CHANGELOG
* WIP on new nomless inputs parser

* more registers

* temporarily throw parsed messages into MQTT for testing

* neaten up a bit

* remove unparsed registers

* small reorg
* Remove old inputs/1/2/3/all publishing

* Update CHANGELOG
* Convert HA discovery packets to point at input/status/parsed

* Remove unused value_template from Sensors

 - since they're in their own messages now
* Rework register_cache to support inputs/all

* get new data into InfluxDB

* Hook up InfluxDB again

* remove old code

for (r, v) in self.pairs.clone() {
let e = match r {
0 => vec![("status", self.parse_status(v))],

Check warning

Code scanning / clippy

some ranges overlap Warning

some ranges overlap
@celsworth celsworth changed the title Road to v1.0 Rewrite packet parsing code Mar 14, 2024
* Remove ReadInput1/2/3/4/All from codebase

* Remove ReadInput1/2/3/4/All from codebase
* Move time register parsing into new parser and out of TimeRegisterOps

This should make it easier to generate start/end JSON payloads for
registers that require it, on any relevant incoming packets.

Small improvement to how we generate and send the message after setting
the registers (re-read it back from the inverter).

Also fix retain bit for hold publishes.

* Update CHANGELOG

* remove debug
@presto8
Copy link
Contributor

presto8 commented Mar 15, 2024

This looks great, can't wait for it to land!

* Deal with multi-register holds properly

* First pass at reading back time registers when one is set

WIP

* convert pairs to HashMaps

* rename pairs to register_map and set a common type

* lint

* add rest of registers

* remove comment

* Update CHANGELOG
// return true if we have a value for ALL the registers requested
fn all_registers_present(&self, registers: &[u16]) -> bool {
registers
.into_iter()

Check warning

Code scanning / clippy

this .into_iter() call is equivalent to .iter() and will not consume the slice Warning

this .into\_iter() call is equivalent to .iter() and will not consume the slice
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.

2 participants