All Projects → Anrijs → Aranet4-Python

Anrijs / Aranet4-Python

Licence: MIT license
Aranet4 Python client

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Aranet4-Python

bt profile
BT Profile Switcher
Stars: ✭ 18 (-85.25%)
Mutual labels:  bluetooth
rpi3-wifi-conf
A simple Python script to configure wifi over bluetooth for a Raspberry Pi 3
Stars: ✭ 112 (-8.2%)
Mutual labels:  bluetooth
app-xyo-nodejs
XYO Archivist/Diviner CLI
Stars: ✭ 41 (-66.39%)
Mutual labels:  bluetooth
ble
Bluetooth Low Energy for Linux / macOS
Stars: ✭ 264 (+116.39%)
Mutual labels:  bluetooth
ESP32 Thing Plus
ESP32 Thing-compatible board using the WROOM module and a QWIIC connector.
Stars: ✭ 18 (-85.25%)
Mutual labels:  bluetooth
ionic-escpos-bluetooth-printer-sample
Sample use of ionic 3 with a bluetooth esc/pos thermal printer
Stars: ✭ 40 (-67.21%)
Mutual labels:  bluetooth
ganglion-ble
Web Bluetooth client for the Ganglion brain-computer interface by OpenBCI
Stars: ✭ 27 (-77.87%)
Mutual labels:  bluetooth
joyconpi
An attempt at emulating a Nintendo Switch Joy-Con controller with a Raspberry Pi
Stars: ✭ 24 (-80.33%)
Mutual labels:  bluetooth
esp32 bluetooth classic sniffer
Active Bluetooth BR/EDR Sniffer/Injector as cheap as any ESP32 board can get. Works with Scapy ;-)
Stars: ✭ 347 (+184.43%)
Mutual labels:  bluetooth
spotifypiHome
"Install and go" multiroom music playback solution, with support for spotify, airplay and bluetooth.
Stars: ✭ 32 (-73.77%)
Mutual labels:  bluetooth
AirPodsDesktop
☄️ AirPods desktop user experience enhancement program, for Windows and Linux (WIP)
Stars: ✭ 462 (+278.69%)
Mutual labels:  bluetooth
esp32-BLEKeyboard
Bluetooth keyboard made from ESP32 board and PS/2 keyboard
Stars: ✭ 26 (-78.69%)
Mutual labels:  bluetooth
joycon-rs
Joy-Con library for Rust 🦀 🎮
Stars: ✭ 104 (-14.75%)
Mutual labels:  bluetooth
gear-vr-controller-linux
Gear VR Controller Linux WebBrowser mouse
Stars: ✭ 37 (-69.67%)
Mutual labels:  bluetooth
libopenaptx
Open Source implementation of Audio Processing Technology codec (aptX)
Stars: ✭ 106 (-13.11%)
Mutual labels:  bluetooth
contact-tracer
A prototype contact tracer app for COVID-19 pandemic response
Stars: ✭ 50 (-59.02%)
Mutual labels:  bluetooth
coBlue
Use Bluetooth Low Energy for remote commands, file transfer, Based on bluez Bluetooth protocol stack (BLE Terminal)
Stars: ✭ 41 (-66.39%)
Mutual labels:  bluetooth
ioBroker.ble
Monitor Bluetooth Low Energy beacons
Stars: ✭ 39 (-68.03%)
Mutual labels:  bluetooth
ansible-playbook-volumio-bluetooth
Pair your phone and stream audio to a Raspberry Pi running Volumio
Stars: ✭ 13 (-89.34%)
Mutual labels:  bluetooth
lhctrl
Power management of Valve v1 lighthouses over Bluetooth LE
Stars: ✭ 28 (-77.05%)
Mutual labels:  bluetooth

Aranet4 Python client

Installation

  1. Install aranet4 and its dependencies:
pip3 install aranet4
  1. Pair Aranet4 device
  2. Run aranetctl or use as library

Note: Smart Home Integrations must be enabled in Aranet4 mobile app for full support.

aranetctl usage

$ aranetctl -h
usage: aranetctl [-h] [-u URL] [-r] [-s DATE] [-e DATE] [-o FILE] [-w] [-l COUNT]
                 [--xt] [--xh] [--xp] [--xc]
                 device_mac

positional arguments:
  device_mac            Aranet4 Bluetooth Address

optional arguments:
  -h, --help            show this help message and exit
  -r, --records         Fetch historical log records
  --scan                Scan Aranet4 devices

Options for current reading:
  -u URL, --url URL     Remote url for current value push

Filter History Log Records:
  -s DATE, --start DATE
                        Records range start (UTC time, example:
                        2019-09-29T14:00:00
  -e DATE, --end DATE   Records range end (UTC time, example: 2019-09-30T14:00:00
  -o FILE, --output FILE
                        Save records to a file
  -w, --wait            Wait until new data point available
  -l COUNT, --last COUNT
                        Get <COUNT> last records
  --xt                  Don't get temperature records
  --xh                  Don't get humidity records
  --xp                  Don't get pressure records
  --xc                  Don't get co2 records

Current Readings Example

Usage: aranetctl XX:XX:XX:XX:XX:XX

Output:

--------------------------------------
Connected: Aranet4 00000 | v0.3.1
Updated 51 s ago. Intervals: 60 s
5040 total readings
--------------------------------------
CO2:          904 ppm
Temperature:  19.9 C
Humidity:     51 %
Pressure:     997.0 hPa
Battery:      96 %
Status Display: GREEN
--------------------------------------

Get History Example

Write full log to screen:

Usage: aranetctl XX:XX:XX:XX:XX:XX -r

-------------------------------------------------------------
Device Name    :        Aranet4 00000
Device Version :               v0.3.1
-------------------------------------------------------------
 id  |        date         |  co2   | temp | hum | pressure |
-------------------------------------------------------------
   1 | 2022-02-18T14:15:44 |    844 | 21.8 |  50 |    985.6 |
   2 | 2022-02-18T14:20:44 |    846 | 21.8 |  50 |    985.9 |
   3 | 2022-02-18T14:25:44 |    843 | 22.0 |  50 |    986.4 |
   4 | 2022-02-18T14:30:44 |    881 | 22.1 |  50 |    986.4 |
   5 | 2022-02-18T14:35:44 |    854 | 22.1 |  50 |    987.3 |
   6 | 2022-02-18T14:40:44 |    867 | 22.2 |  50 |    987.5 |
   7 | 2022-02-18T14:45:44 |    883 | 22.1 |  50 |    988.1 |
   8 | 2022-02-18T14:50:44 |    921 | 22.1 |  50 |    988.6 |
   9 | 2022-02-18T14:55:44 |    930 | 22.0 |  50 |    989.1 |
  10 | 2022-02-18T15:00:44 |    954 | 22.0 |  50 |    989.5 |
-------------------------------------------------------------

Usage: aranetctl XX:XX:XX:XX:XX:XX -r -o aranet4.csv

Output file format: Date,CO2,Temperature,Humidity,Pressure

Output file example:

date,co2,temperature,humidity,pressure
2022-02-18 10:05:47,1398,23.2,53,986.6
2022-02-18 10:10:47,1155,23.1,50,986.3

Usage of library

Current Readings Example

import aranet4

device_mac = "XX:XX:XX:XX:XX:XX"

current = aranet4.client.get_current_readings(device_mac)

print("co2 reading:", current.co2)
print("Temperature:", current.temperature)
print("Humidity:", current.humidity)
print("Pressure:", current.pressure)

Scanner Example

Usage: aranetctl --scan

Output:

=======================================
  Name:     Aranet4 00000
  Address:  XX:XX:XX:XX:XX:XX
  RSSI:     -85 dBm
--------------------------------------
  CO2:           662 pm
  Temperature:   21.9 °C
  Humidity:      48 %
  Pressure:      1019.2 hPa
  Battery:       34 %
  Status disp.:  GREEN

=======================================
  Name:     Aranet4 00001
  Address:  XX:XX:XX:XX:XX:XX
  RSSI:     -91 dBm

Note: To receive current measurements, Smart Home Integrations must be enabled and firmware version must be v1.2.0 or newer.

Logged Readings Example

import aranet4

device_mac = "XX:XX:XX:XX:XX:XX"

history = aranet4.client.get_all_records(
    device_mac, entry_filter={"humi": False, "pres": False}
)
print(f"{'Date':^20} | {'CO2':^10} | {'Temperature':^10} ")
for entry in history.value:
    print(f"{entry.date.isoformat():^20} | {entry.co2:^10} | {entry.temperature:^10}")

Library functions

get_current_readings(mac_address: str) -> client.CurrentReading

Get current measurements from device Returns CurrentReading object:

class CurrentReading:
    name: str = ""
    version: str = ""
    temperature: float = -1
    humidity: int = -1
    pressure: float = -1
    co2: int = -1
    battery: int = -1
    status: int = -1
    interval: int = -1
    ago: int = -1
    stored: int = -1

get_all_records(mac_address: str, entry_filter: dict) -> client.Record

Get stored datapoints from device. Apply any filters if required

entry_filter is a dictionary that can have the following values:

  • last: int : Get last n entries
  • start: datetime : Get entries after specified time
  • end: datetime : Get entries before specified time
  • temp: bool : Get temperature data points (default = True)
  • humi: bool : Get humidity data points (default = True)
  • pres: bool : Get pressure data points (default = True)
  • co2: bool : Get co2 data points (default = True)

Returns CurrentReading object:

class Record:
    name: str
    version: str
    records_on_device: int
    filter: Filter
    value: List[RecordItem] = field(default_factory=list)

Which includes these objects:

class RecordItem:
    date: datetime
    temperature: float
    humidity: int
    pressure: float
    co2: int

class Filter:
    begin: int
    end: int
    incl_temperature: bool
    incl_humidity: bool
    incl_pressure: bool
    incl_co2: bool
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].