Skip to content

Rewrite packet parsing code#249

Open
celsworth wants to merge 19 commits into
masterfrom
road-to-1-0
Open

Rewrite packet parsing code#249
celsworth wants to merge 19 commits into
masterfrom
road-to-1-0

Conversation

@celsworth

@celsworth celsworth commented Mar 13, 2024

Copy link
Copy Markdown
Owner

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
Comment on lines +13 to +19
pub fn to_string(&self) -> String {
match self {
Self::Integer(i) => i.to_string(),
Self::Float(f) => f.to_string(),
Self::String(s) => s.to_string(),
}
}

Check warning

Code scanning / clippy

implementation of inherent method `to_string(&self) -> String` for type `lxp::register_parser::ParsedValue`

implementation of inherent method `to_string(&self) -> String` for type `lxp::register_parser::ParsedValue`
Comment thread src/lxp/register_parser.rs Fixed
Comment thread src/lxp/register_parser.rs Fixed
* 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

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
Comment thread src/influx.rs Fixed
Comment thread src/influx.rs Fixed
Comment thread src/influx.rs Fixed
Comment thread src/influx.rs Fixed
@presto8

presto8 commented Mar 15, 2024

Copy link
Copy Markdown
Contributor

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`

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.

3 participants