GithubHelp home page GithubHelp logo

stijnstijn / pyaranet4 Goto Github PK

View Code? Open in Web Editor NEW
47.0 4.0 8.0 34 KB

A cross-platform Python interface for the Aranet4 CO₂ meter

License: MIT License

Python 100.00%
aranet4 iot co2-sensor bluetooth-le

pyaranet4's People

Contributors

bede avatar drcormier avatar jeffmo avatar stijnstijn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pyaranet4's Issues

pyaranet4 --history Invocation Raises ValueError Exception

Issue Summary:

pyaranet4 --history raises ValueError exception.
See Issue Details section below for more information.

Python Version Details:

% python -VV
Python 3.10.8 (main, Oct 13 2022, 09:48:40) [Clang 14.0.0 (clang-1400.0.29.102)]

Aranet4 Sensor Details:

Firmware: v1.2.0
Smart Home Integration: enabled

Issue Details:

I am receiving a ValueError runtime exception when attempting to pull back history from my Aranet4:

% pyaranet4 --history
Traceback (most recent call last):
  File "/<redacted>/pyaranet4/.venv/bin/pyaranet4", line 8, in <module>
    sys.exit(main())
  File "/<redacted>/pyaranet4/.venv/lib/python3.10/site-packages/pyaranet4/__main__.py", line 56, in main
    collect_data(a4, args, sensors)
  File "/<redacted>/pyaranet4/.venv/lib/python3.10/site-packages/pyaranet4/__main__.py", line 114, in collect_data
    history = a4.get_history(sensors)
  File "/<redacted>/pyaranet4/.venv/lib/python3.10/site-packages/pyaranet4/pyaranet4.py", line 219, in get_history
    return self.loop.run_until_complete(self._get_history(sensors, start, end))
  File "/<redacted>/homebrew/Cellar/[email protected]/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/<redacted>/pyaranet4/.venv/lib/python3.10/site-packages/pyaranet4/pyaranet4.py", line 410, in _get_history
    index_map[max(self._datapoints)] = last_timestamp
ValueError: max() arg is an empty sequence
% 

I can pull back the most recent measurement without issue using pyaranet4:

% pyaranet4    
--------------------------------------
Connected: Aranet4 03263 | v0.4.10
Updated 40 s ago. Intervals: 60 s
5040 total readings
--------------------------------------
CO2:         846 ppm
Temperature: 20.00 C
Humidity:    32 %
Pressure:    980.50 hPa
Battery:     33 %
--------------------------------------

But for some reason when I pass the --history flag, I get the ValueError exception. Based on the detail message max() arg is an empty sequence, I wonder if self._datapoints isn't getting set for some reason.

Desired Resolution:

Can you provide any guidance on why I might be receiving this error, and how to resolve it?

Please let me know if I can provide any additional details!

Failed to read temperature, humidity, co2, pressure

pyaranet4 --history works as expected, but pyaranet4 produces the error:

--------------------------------------
Connected: Aranet4 1BAE8 | v0.4.14
Updated 20 s ago. Intervals: 60 s
249 total readings
--------------------------------------
Traceback (most recent call last):
  File "/home/ighor/.local/lib/python3.10/site-packages/pyaranet4/pyaranet4.py", line 477, in _read_value
    value = await self._client.read_gatt_char(uuid)
  File "/home/ighor/.local/lib/python3.10/site-packages/bleak/__init__.py", line 571, in read_gatt_char
    return await self._backend.read_gatt_char(char_specifier, **kwargs)
  File "/home/ighor/.local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 679, in read_gatt_char
    assert_reply(reply)
  File "/home/ighor/.local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 20, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.NotPermitted] Read not permitted

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ighor/.local/bin/pyaranet4", line 8, in <module>
    sys.exit(main())
  File "/home/ighor/.local/lib/python3.10/site-packages/pyaranet4/__main__.py", line 61, in main
    basic_overview(a4)
  File "/home/ighor/.local/lib/python3.10/site-packages/pyaranet4/__main__.py", line 76, in basic_overview
    print("CO2:         {:d} ppm".format(a4.current_readings.co2))
  File "/home/ighor/.local/lib/python3.10/site-packages/pyaranet4/pyaranet4.py", line 155, in current_readings
    return self._get_readings(simple=False)
  File "/home/ighor/.local/lib/python3.10/site-packages/pyaranet4/pyaranet4.py", line 284, in _get_readings
    data = self.read_from_uuid(uuid)
  File "/home/ighor/.local/lib/python3.10/site-packages/pyaranet4/pyaranet4.py", line 230, in read_from_uuid
    value = self.loop.run_until_complete(self._read_value(uuid))
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/ighor/.local/lib/python3.10/site-packages/pyaranet4/pyaranet4.py", line 479, in _read_value
    raise Aranet4UnpairedException("Error reading from device. Check if it is properly paired.")
pyaranet4.exceptions.Aranet4UnpairedException: Error reading from device. Check if it is properly paired.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.