Skip to content

Additional OBIS PF, Average Net Power#47

Merged
PolarGoose merged 1 commit intoesphome-libs:mainfrom
geduxas:lt_obis
Feb 24, 2026
Merged

Additional OBIS PF, Average Net Power#47
PolarGoose merged 1 commit intoesphome-libs:mainfrom
geduxas:lt_obis

Conversation

@geduxas
Copy link
Copy Markdown

@geduxas geduxas commented Feb 23, 2026

I have added additional obis which was missing for Lithuania meters

OBIS Description
1-0:1.24.0 Average Net Power (|+A|-|-A|)
1-0:13.7.0 Instantaneous Power factor (+A/+VA)
1-0:33.7.0 Instantaneous power factor in phase L1
1-0:53.7.0 Instantaneous power factor in phase L2
1-0:73.7.0 Instantaneous power factor in phase L3
1-0:13.3.0 Minimum Power factor (+A/+VA) (in last 10min.)

1-0:1.24.0 also can have negative value (generation/export)

@PolarGoose
Copy link
Copy Markdown
Collaborator

@geduxas,

Thanks a lot for the pull request.
Do you have a PDF spec that describes these?

@geduxas
Copy link
Copy Markdown
Author

geduxas commented Feb 23, 2026

No, only Excel sheets from energy provider
https://www.eso.lt/web/storage/public/uploads/2025/07/p1-duomenu-modelis.xlsx

@PolarGoose PolarGoose force-pushed the lt_obis branch 2 times, most recently from 8825cbc to a599bce Compare February 23, 2026 17:02
@PolarGoose
Copy link
Copy Markdown
Collaborator

Great. Thanks. It is enough. I will add it to the docs.
You have done a very good job overall. I will just do a small cleanup.

Copy link
Copy Markdown

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

This PR adds support for parsing negative numeric values in the DSMR parser and introduces several new OBIS field definitions for Lithuanian smart meters, including instantaneous power factor measurements and average net power demand.

Changes:

  • Modified numeric parser to support negative values by changing from uint32_t to int32_t and adding negative sign handling
  • Added six new OBIS field definitions: active_demand_net (previously commented out), power_factor, power_factor_l1/l2/l3, and min_power_factor
  • Updated test suite to verify parsing of negative values and new dimensionless power factor fields

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

File Description
src/dsmr_parser/parser.h Modified NumParser to support negative numbers by changing return type to int32_t, adding negative sign detection, and updating value accumulation logic
src/dsmr_parser/util.h Added explicit static_cast in succeed() method to support type conversions when assigning parsed int32_t values to different target types
src/dsmr_parser/fields.h Changed internal value storage from uint32_t to int32_t throughout, enabled active_demand_net field definition, and added five new power factor field definitions using units::none
tests/parser_test.cpp Extended test data with negative power value and dimensionless power factor values, added corresponding field declarations and assertions to verify correct parsing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@PolarGoose PolarGoose force-pushed the lt_obis branch 2 times, most recently from 10b77db to af56cb1 Compare February 23, 2026 20:01
@PolarGoose
Copy link
Copy Markdown
Collaborator

@geduxas,

Are you ok with the current changes?

@geduxas
Copy link
Copy Markdown
Author

geduxas commented Feb 24, 2026

I think so ;)

@geduxas
Copy link
Copy Markdown
Author

geduxas commented Feb 24, 2026

hi @PolarGoose, i checked whole list, i think i still missing one OBIS :)

OBIS description
1-0:0.8.2 Measurement Period 3 for Instantaneous values

It's not so big deal, but it could be added to same PR
example of data: 1-0:1.8.2(000081.859*kWh)

@PolarGoose
Copy link
Copy Markdown
Collaborator

@geduxas,

I have added 1-0:0.8.2.

example of data: 1-0:1.8.2(000081.859*kWh)

This is an incorrect example. I used 1-0:0.8.2(00900*s)

Copy link
Copy Markdown

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

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

src/dsmr_parser/parser.h:160

  • The numeric parsing logic does not check for integer overflow when multiplying value by 10. For signed int32_t, values can overflow when parsing large numbers. Consider adding overflow checks before the multiplication operations on lines 139, 152, and 160 to prevent undefined behavior. For example, check if value would exceed INT32_MAX/10 before multiplying.
      value *= 10;
      value += (*cur_symbol - '0');
      ++cur_symbol;
    }

    // Parse decimal part, if any
    if (max_decimals && cur_symbol < end && *cur_symbol == '.') {
      ++cur_symbol;

      while (cur_symbol < end && !strchr("*)", *cur_symbol) && max_decimals) {
        max_decimals--;
        if (*cur_symbol < '0' || *cur_symbol > '9')
          return res.fail(INVALID_NUMBER, cur_symbol);
        value *= 10;
        value += (*cur_symbol - '0');
        ++cur_symbol;
      }
    }

    // Fill in missing decimals with zeroes
    while (max_decimals--)
      value *= 10;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@esphome-libs esphome-libs deleted a comment from Copilot AI Feb 24, 2026
@esphome-libs esphome-libs deleted a comment from Copilot AI Feb 24, 2026
@esphome-libs esphome-libs deleted a comment from Copilot AI Feb 24, 2026
@esphome-libs esphome-libs deleted a comment from Copilot AI Feb 24, 2026
@PolarGoose PolarGoose merged commit 79fb672 into esphome-libs:main Feb 24, 2026
2 checks passed
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