sensors: Add sensor name argument
This commit is contained in:
parent
581665fa95
commit
9b64fa14fb
1 changed files with 9 additions and 9 deletions
18
main.py
18
main.py
|
@ -72,11 +72,11 @@ async def state(ctx):
|
|||
|
||||
# !co2
|
||||
@HobbyBot.command(description="co2 levels")
|
||||
async def co2(ctx):
|
||||
async def co2(ctx, where='hoofdruimte'):
|
||||
async with ctx.typing():
|
||||
try:
|
||||
msg = await mqtt_get_one("bitlair/climate/hoofdruimte/co2_ppm")
|
||||
await ctx.send(f"Hoofdruimte: {msg.payload.decode('ascii')} ppm\n")
|
||||
msg = await mqtt_get_one(f"bitlair/climate/{where}/co2_ppm")
|
||||
await ctx.send(f"{where}: {msg.payload.decode('ascii')} ppm\n")
|
||||
except Exception as err:
|
||||
await ctx.send("Meh, stuk")
|
||||
raise err
|
||||
|
@ -84,11 +84,11 @@ async def co2(ctx):
|
|||
|
||||
# !temp
|
||||
@HobbyBot.command(description="Temperature")
|
||||
async def temp(ctx):
|
||||
async def temp(ctx, where="hoofdruimte"):
|
||||
async with ctx.typing():
|
||||
try:
|
||||
msg = await mqtt_get_one("bitlair/climate/hoofdruimte/temperature_c")
|
||||
await ctx.send(f"Hoofdruimte: {msg.payload.decode('ascii')} °C\n")
|
||||
msg = await mqtt_get_one(f"bitlair/climate/{where}/temperature_c")
|
||||
await ctx.send(f"{where}: {msg.payload.decode('ascii')} °C\n")
|
||||
except Exception as err:
|
||||
await ctx.send("Meh, stuk")
|
||||
raise err
|
||||
|
@ -96,11 +96,11 @@ async def temp(ctx):
|
|||
|
||||
# !humid
|
||||
@HobbyBot.command(description="Humidity")
|
||||
async def humid(ctx):
|
||||
async def humid(ctx, where="hoofdruimte"):
|
||||
async with ctx.typing():
|
||||
try:
|
||||
msg = await mqtt_get_one("bitlair/climate/hoofdruimte/humidity_pct")
|
||||
await ctx.send(f"Hoofdruimte: {msg.payload.decode('ascii')} pct\n")
|
||||
msg = await mqtt_get_one(f"bitlair/climate/{where}/humidity_pct")
|
||||
await ctx.send(f"{where}: {msg.payload.decode('ascii')} pct\n")
|
||||
except Exception as err:
|
||||
await ctx.send("Meh, stuk")
|
||||
raise err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue