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

Dynamic sensors #109

Merged
merged 22 commits into from
Oct 19, 2022
Merged

Dynamic sensors #109

merged 22 commits into from
Oct 19, 2022

Conversation

rklomp
Copy link
Collaborator

@rklomp rklomp commented Sep 12, 2022

This will get rid of device classes and use the getAllOnlValues.json and getAllParamValues.json to figure out which sensors are present on the device.

@FindusK
Copy link
Contributor

FindusK commented Sep 17, 2022

I did a small test on my inverter, all sensors seem to be available.
I have problems to decode some of the values, most importanly the array based sensors pv_current_b and pv_voltage_b of the inverter.

Here the full output of the script:

battery_capacity_total              0 %
     battery_charge_total            0.0 kWh
        battery_current_a            0.0 A
  battery_discharge_total            0.0 kWh
battery_power_charge_total              0 W
battery_power_discharge_total              0 W
        battery_soc_total              0 %
battery_status_operating_mode            Off
           battery_temp_a            0.0 °C
        battery_voltage_a            0.0 V
               current_l1            6.0 A
               current_l2            6.0 A
               current_l3            6.0 A
            current_total           18.0 A
              daily_yield           9065 Wh
                frequency          49.99 Hz
      grid_apparent_power           4290 VA
   grid_apparent_power_l1           1431 VA
   grid_apparent_power_l2           1431 VA
   grid_apparent_power_l3           1431 VA
               grid_power           4290 W
        grid_power_factor            0.0
      grid_reactive_power              0 var
   grid_reactive_power_l1             -2 var
   grid_reactive_power_l2             -2 var
   grid_reactive_power_l3             -2 var
        grid_relay_status         Closed
       inverter_condition             Ok
     inverter_power_limit          10000 W
     inverter_system_init            Yes
 operating_status_general      Activated
                 power_l1           1433 W
                 power_l2           1428 W
                 power_l3           1434 W
             pv_current_a          4.371 A
             pv_current_b
             pv_gen_meter        2654.88 kWh
               pv_power_a           1583 W
               pv_power_b              0 W
             pv_voltage_a          362.1 V
             pv_voltage_b
                   status             Ok
              total_yield        2655.21 kWh
               voltage_l1          236.7 V
               voltage_l2          235.3 V
               voltage_l3          236.6 V
  metering_power_supplied           3680 W
  metering_power_absorbed              0 W
       metering_frequency          49.98 Hz
     metering_total_yield       1523.549 kWh
  metering_total_absorbed        238.848 kWh
      metering_current_l1          5.457 A
      metering_current_l2          4.562 A
      metering_current_l3          5.967 A
      metering_voltage_l1         234.98 V
      metering_voltage_l2         234.57 V
      metering_voltage_l3         235.23 V
metering_active_power_feed_l1           1269 W
metering_active_power_feed_l2           1014 W
metering_active_power_feed_l3           1397 W
metering_active_power_draw_l1              0 W
metering_active_power_draw_l2              0 W
metering_active_power_draw_l3              0 W
metering_current_consumption
metering_total_consumption

@rklomp
Copy link
Collaborator Author

rklomp commented Sep 18, 2022

I did a small test on my inverter, all sensors seem to be available.
I have problems to decode some of the values, most importanly the array based sensors pv_current_b and pv_voltage_b of the inverter.

Looking good! About the array based sensors. Do you have two strings of solar panels? Otherwise they wont give any values.

@FindusK
Copy link
Contributor

FindusK commented Sep 18, 2022

I have both strings connected on my inverter, the value of pv_power_b should be around 2100W.
This is the corresponding section in the json from another day:

            "6380_40251E00": {
                "1": [
                    {
                        "val": 3718
                    },
                    {
                        "val": 5975
                    }
                ]
            },
            "6380_40451F00": {
                "1": [
                    {
                        "val": 34110
                    },
                    {
                        "val": 61650
                    }
                ]
            },
            "6380_40452100": {
                "1": [
                    {
                        "val": 10900
                    },
                    {
                        "val": 9691
                    }
                ]
            },

@codecov
Copy link

codecov bot commented Sep 22, 2022

Codecov Report

Merging #109 (e472cc2) into master (50b26a9) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##            master      #109    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files            6         5     -1     
  Lines          428       241   -187     
==========================================
- Hits           428       241   -187     
Impacted Files Coverage Δ
pysma/definitions.py 100.00% <ø> (ø)
pysma/const.py 100.00% <100.00%> (ø)
pysma/sensor.py 100.00% <100.00%> (ø)
pysma/__init__.py

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@rklomp
Copy link
Collaborator Author

rklomp commented Sep 22, 2022

I have both strings connected on my inverter, the value of pv_power_b should be around 2100W. This is the corresponding section in the json from another day:

I found the issue and committed a fix.
Also updated the tests to cover this.

I am creating a file with test data for testing the code. Would you be able to share the response of your inverter for POST requests to /dyn/getAllOnlValues.json and /dyn/getAllParamValues.json so I can include them?

@rklomp
Copy link
Collaborator Author

rklomp commented Sep 22, 2022

@kellerza,

Do you know of any users with a devices that requires the alternative jmespath queries?

JMESPATH_VAL = "val"
JMESPATH_VAL_TAG = JMESPATH_VAL + "[0].tag"
JMESPATH_VAL_STR = "[?str==sum([`1`,`{}`])].val | [0]"

Trying to build a file with test data and having this data would be really useful

@rklomp rklomp linked an issue Sep 25, 2022 that may be closed by this pull request
@rklomp rklomp self-assigned this Sep 25, 2022
@rklomp
Copy link
Collaborator Author

rklomp commented Oct 14, 2022

@FindusK , Could you share the response of your inverter for POST requests to /dyn/getAllOnlValues.json and /dyn/getAllParamValues.json so I can include them? I expect this gets the tests coverage to 100%

@phdelodder
Copy link
Contributor

@rklomp here is mine: pysma-debug.log

@FindusK
Copy link
Contributor

FindusK commented Oct 16, 2022

@rklomp
Copy link
Collaborator Author

rklomp commented Oct 19, 2022

Thanks @phdelodder and @FindusK! I have added both your data to the testfile and got a 100% coverage now

@rklomp rklomp merged commit 947b1a8 into kellerza:master Oct 19, 2022
@rklomp rklomp deleted the dynamic-sensors branch October 19, 2022 10:18
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.

New "Sunny Tripower Smart Energy"
3 participants