Skip to main content

API to get oil tank from Kingspan SENSiT sensors

Project description

kingspan-connect-sensor

build: build:

API to get oil tank from Kingspan SENSiT sensors

To make use of the API, you will need the credentials you used to register with the App. You do not need other details such as the tank ID as these are already associated with your account.

Installation

python3 -m pip kingspan-connect-sensor

Usage

NOTE from version 2.0.0, the API changes to use attributes rather than methods for tank parameters.

Reading documents:

from connectsensor import SensorClient

client = SensorClient()
client.login("test@example.com", "s3cret")
tanks = client.tanks
tank_level = tanks[0].level

The tanks method returns a Tanks object which can be queried for the status of the specific tank.

Async Usage

From version 2.0.0, an asyncio verison of the client is available:

async with AsyncSensorClient() as client:
    await client.login("test@example.com", "s3cret")
    tanks = await client.tanks
    tank_level = await tanks[0].level
    tank_capcity = await tanks[0].capacity
    tank_percent = 100 * (tank_level / tank_percent)
    print(f"Tank is {tank_percent:.1f}% full")

Tanks object

As of version 3.0, history no longer returns a Pandas dataframe to simplify packge dependencies. Instead, an list of dicts is returned, where each list element is a sample from the web API, sorted by logging time. There should be one record per day. Each dict has the following keys:

  • reading_date: a datetime object indicating the time a measurement was made
  • level_percent: integer percentage full
  • level_litres: number of lites in the tank

You can construct a Pandas dataframe simply using:

tanks = await client.tanks
history = await tanks[0].history
df = pd.DataFrame(history)

Scripts

Reporting on the current status of the tank using kingspan-status:

% kingspan-status --username=test@example.com --password=s3cret

Home Tank:
 Capacity = 2000
 Serial Number = 20001999
 Model = Unknown
 Level = 90% (1148 litres)
 Last Read = 2021-10-09 00:42:47.947000

History:
 Reading date           %Full  Litres
 30-Jan-2021 00:29      94     1224 
 31-Jan-2021 00:59      80     1040 
 01-Feb-2021 00:29      78     1008 
 02-Feb-2021 00:59      76     986  

kingspan-notifier can be used to check the status of a tabk and report via email when the tank is likely to run out of oil. As of version 3.0, pandas is no longer installed as a dependency so you must pip install pandas manually to use kingspan-notifier.

% kingspan-notifier --config kingspan.ini
Current level 1148 litres
No notification; 196 days oil remain

Command line options include:

  • --config CONFIG: a config file in ini-format
  • --no-update: don't update cache with new data (defaults to updating the DB cache)
  • --window WINDOW: the number of days history to consider (default: 14 days)
  • --notice NOTICE: the number of days before out-of-oil forecast to warn (default: 14)

An example config file is:

[sensit]
username=test@example.com
password=s3cret
cache=/home/me/kingspan.db
start-date=2021-01-31

[smtp]
server=smtp.isp.co.uk
username=ispuser
email=test@example.com
password=smtps3cret

The cache is an SQLite database and will be intialised if not present.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kingspan_connect_sensor-3.0.5.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

kingspan_connect_sensor-3.0.5-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file kingspan_connect_sensor-3.0.5.tar.gz.

File metadata

  • Download URL: kingspan_connect_sensor-3.0.5.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.13.0 Darwin/24.1.0

File hashes

Hashes for kingspan_connect_sensor-3.0.5.tar.gz
Algorithm Hash digest
SHA256 ee2d79cb1dcd95f4cd56b263000e9eaabadf9e633a5e8f6e38b705896352e6b8
MD5 c1ad8d8df9b4a7eb451d5419befc6743
BLAKE2b-256 b68ceebde83b7bec4a7ae4e97ed5e4e48fa02f5a3d56841009c6f1e4fc6af677

See more details on using hashes here.

File details

Details for the file kingspan_connect_sensor-3.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for kingspan_connect_sensor-3.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f72690d5f46dc69d02f16129897e4feb7b62c2de1b83c322cc56543315361898
MD5 8d4a4983accf2284aca285c15a6d9e8a
BLAKE2b-256 62ae00d3f375353dedf325a49d70d3f7d575af6ad62d5cc2ce98d693a34341c7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page