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

Data validation is overexited #276

Open
sbf- opened this issue Mar 25, 2023 · 8 comments
Open

Data validation is overexited #276

sbf- opened this issue Mar 25, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@sbf-
Copy link

sbf- commented Mar 25, 2023

Running a script for a few weeks without issues, until today:

Mar 25 12:00:03 raspberrypi sdmpvo:     self.validate_data(data, ADDSTATUS_PARAMETERS)
Mar 25 12:00:03 raspberrypi sdmpvo:   File "/usr/local/lib/python3.7/dist-packages/pvoutput/utils.py", line 128, in validate_data
Mar 25 12:00:03 raspberrypi sdmpvo:     raise ValueError(f"v3 cannot be higher than 200000, is {data['v3']}")
Mar 25 12:00:03 raspberrypi sdmpvo: ValueError: v3 cannot be higher than 200000, is 217621

According to the PVO documentation for addstatus service there is no limitation for v3 (consumption in Wh)
I also provide c1=1 which means Both v1 and v3 values are lifetime energy values.

Commenting out the validation in /usr/local/lib/python3.7/dist-packages/pvoutput/utils.py makes the script running again (PVO accepts the data)

    #if int(data.get("v3", 0)) > 200000:
    #    raise ValueError(f"v3 cannot be higher than 200000, is {data['v3']}")
    #if int(data.get("v4", 0)) > 100000:
    #    raise ValueError(f"v4 cannot be higher than 100000, is {data['v4']}")

Edit: pvoutput was installed on raspberry pi using pip3 install pvoutput

@yaleman yaleman added the bug Something isn't working label Mar 26, 2023
@yaleman
Copy link
Owner

yaleman commented Mar 26, 2023

So it looks like... before validation, check if the c1 flag is set, then if it's:

  1. remove the maxval validators from v1 and v3
  2. remove the maxval validator from v1
  3. remove the maxval validator from v3

No changes to v4 - that's unrelated to this.

@sbf-
Copy link
Author

sbf- commented Mar 26, 2023

Well, I'm a bit confused now...

I installed it using pip3 install pvoutput but my utils.py is different from the one in the main branch

So it seems the install source is completely out-of-sync

c1flag is set; this is my code:

    configuration = get_apikey_systemid_sync()
    data = {
        "v3": wh_cons,
        "v4": watt,
        "v6": voltage,
        "c1": 1
    }
    pvo = PVOutput(
        apikey=configuration["apikey"],
        systemid=configuration["systemid"],
        donation_made=configuration["donation_made"],
    )

@yaleman
Copy link
Owner

yaleman commented Mar 28, 2023

can you please do a pip3 freeze | grep pvoutput to see what version you're getting?

@sbf-
Copy link
Author

sbf- commented Mar 28, 2023

pi@raspberrypi:~ $ pip3 freeze | grep pvoutput
pvoutput==0.0.8

@yaleman
Copy link
Owner

yaleman commented Mar 28, 2023

That'll explain why it's different - the current released version is 0.0.11 - https://pypi.org/project/pvoutput/#history

pip might be limiting the installed version if you're running an older version of python, I think I bumped the minimum version a while back due to dependency-related things.

@sbf-
Copy link
Author

sbf- commented Mar 28, 2023

So, leaving the utils.py with the validation removed I guess? I'm pretty new to Python...
Or maybe I have to try How To Install the Latest Python Version on Raspberry Pi

pi@raspberrypi:~ $ python3 --version
Python 3.7.3
pi@raspberrypi:~ $ sudo apt install python3
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3 is already the newest version (3.7.3-1).
python3 set to manually installed.
The following packages were automatically installed and are no longer required:
  dh-python ibverbs-providers libboost-atomic1.67.0 libboost-iostreams1.67.0
  libboost-regex1.67.0 libboost-system1.67.0 libboost-thread1.67.0 libgfapi0 libgfrpc0
  libgfxdr0 libglusterfs0 libibverbs1 libnspr4 python3-asn1crypto python3-cffi-backend
  python3-crypto python3-dbus python3-entrypoints python3-keyrings.alt python3-xdg
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 32 not upgraded.
pi@raspberrypi:~ $ pip3 install pvoutput==0.0.11
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pvoutput==0.0.11
  Could not find a version that satisfies the requirement pvoutput==0.0.11 (from versions: 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.0.6, 0.0.7, 0.0.8)
No matching distribution found for pvoutput==0.0.11

@yaleman
Copy link
Owner

yaleman commented Mar 28, 2023

Yeah, starting in 0.0.9 the minimum version's 3.8 - you might be be able to include it in your project by cloning the repository and grabbing the pvoutput folder, but dependencies like pydantic require relatively new python versions too, so your best bet's probably to upgrade the OS on the Pi to something that supports a version newer than 5 years old 😄

@sbf-
Copy link
Author

sbf- commented Mar 30, 2023

upgrade the OS on the Pi to something that supports a version newer than 5 years old

And now I realise this RPi is still on Buster...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants