Small updates
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
# airthings-influxdb
|
||||
This tool is using the library provided by kotlarz at https://github.com/kotlarz/airthings. Thanks for the project!
|
||||
|
||||
## Install
|
||||
```x-sh
|
||||
@@ -26,6 +27,6 @@ Options:
|
||||
|
||||
Commands:
|
||||
identify Lists available sensors nearby
|
||||
start
|
||||
verify verify your configuration
|
||||
start Start collecting data from your airthings sensors
|
||||
verify Verify your Influxdb configuration
|
||||
```
|
||||
|
||||
@@ -31,7 +31,7 @@ def cli(ctx, debug, config):
|
||||
@cli.command()
|
||||
@click.pass_context
|
||||
def verify(ctx):
|
||||
"""verify your configuration - does not do much yet!"""
|
||||
"""Verify your Influxdb configuration"""
|
||||
config = read_config(ctx.obj['CONFIG'])
|
||||
|
||||
influx_host = env.get("InfluxdbHost", config['DEFAULT']['InfluxdbHost'])
|
||||
@@ -41,32 +41,37 @@ def verify(ctx):
|
||||
influx_db = env.get("InfluxdbDatabase", config['DEFAULT']['InfluxdbDatabase'])
|
||||
|
||||
client = InfluxDBClient(influx_host, influx_port, influx_user, influx_pass, influx_db)
|
||||
|
||||
click.echo("Trying to connect to influxdb...")
|
||||
try:
|
||||
ping = client.ping()
|
||||
click.echo("Success! Version: %s"% ping)
|
||||
except InfluxDBClientError as e:
|
||||
click.echo("An error occured: %s" % e)
|
||||
|
||||
@cli.command()
|
||||
def identify():
|
||||
"""Lists available sensors nearby"""
|
||||
|
||||
airthings_devices = fetch_measurements()
|
||||
print("Found %s Airthings device(s):" % len(airthings_devices))
|
||||
click.echo("Found %s Airthings device(s):" % len(airthings_devices))
|
||||
for device in airthings_devices:
|
||||
print("=" * 36)
|
||||
print("\tMAC address:", device.mac_address)
|
||||
print("\tIdentifier:", device.identifier)
|
||||
print("\tModel:", device.label)
|
||||
print("\tModel number:", device.model_number)
|
||||
print("\tHas measurements:", device.has_measurements)
|
||||
print("\tSensor capabilities:")
|
||||
click.echo("=" * 36)
|
||||
click.echo("\tMAC address: %s" % device.mac_address)
|
||||
click.echo("\tIdentifier: %s" % device.identifier)
|
||||
click.echo("\tModel: %s" % device.label)
|
||||
click.echo("\tModel number: %s" % device.model_number)
|
||||
click.echo("\tHas measurements:" + str(device.has_measurements))
|
||||
click.echo("\tSensor capabilities:")
|
||||
for sensor, supported in device.sensor_capabilities.items():
|
||||
print("\t", sensor, "=", "YES" if supported else "NO")
|
||||
print("+" * 11, "Measurements", "+" * 11)
|
||||
print("\t", device.humidity)
|
||||
print("\t", device.radon_short_term_avg)
|
||||
print("\t", device.radon_long_term_avg)
|
||||
print("\t", device.temperature)
|
||||
print("\t", device.atmospheric_pressure)
|
||||
print("\t", device.co2)
|
||||
print("\t", device.voc)
|
||||
click.echo("\t" + sensor + "=" + "YES" if supported else "\t" + "NO")
|
||||
click.echo("+" * 11 + "Measurements" + "+" * 11)
|
||||
click.echo("\t %s" % device.humidity)
|
||||
click.echo("\t %s" % device.radon_short_term_avg)
|
||||
click.echo("\t %s" % device.radon_long_term_avg)
|
||||
click.echo("\t %s" % device.temperature)
|
||||
click.echo("\t %s" % device.atmospheric_pressure)
|
||||
click.echo("\t %s" % device.co2)
|
||||
click.echo("\t %s" % device.voc)
|
||||
|
||||
|
||||
|
||||
@@ -75,7 +80,7 @@ def identify():
|
||||
@click.pass_context
|
||||
def start(ctx):
|
||||
"""
|
||||
|
||||
Start collecting data from your airthings sensors
|
||||
"""
|
||||
click.echo("Starting the Airthings to Influxdb Bridge")
|
||||
click.echo("Reading the config...")
|
||||
@@ -98,14 +103,14 @@ def start(ctx):
|
||||
while True:
|
||||
click.echo("Searching devices...")
|
||||
airthings_devices = fetch_measurements()
|
||||
print("Found %s Airthings devices:" % len(airthings_devices))
|
||||
click.echo("Found %s Airthings devices:" % len(airthings_devices))
|
||||
for device in airthings_devices:
|
||||
print("=" * 36)
|
||||
print("\tMAC address:", device.mac_address)
|
||||
print("\tIdentifier:", device.identifier)
|
||||
print("\tModel:", device.label)
|
||||
print("\tModel number:", device.model_number)
|
||||
print("\tHas measurements:", device.has_measurements)
|
||||
click.echo("=" * 36)
|
||||
click.echo("\tMAC address: %s" % device.mac_address)
|
||||
click.echo("\tIdentifier: %s" % device.identifier)
|
||||
click.echo("\tModel: %s" % device.label)
|
||||
click.echo("\tModel number: %s" % device.model_number)
|
||||
click.echo("\tHas measurements: %s" % device.has_measurements)
|
||||
|
||||
click.echo("Collecting sensor data...")
|
||||
now = datetime.datetime.now()
|
||||
|
||||
Reference in New Issue
Block a user