ebaauw / homebridge-deconz

Homebridge plugin for deCONZ
Apache License 2.0
137 stars 7 forks source link

help with log Levels #211

Closed ThunderFD closed 9 months ago

ThunderFD commented 9 months ago

I'm doing the first steps of migrating from homebridge hue and have 2 questions about logging (as I wanted to reduce clutter in my homebridge logs)

  1. Is it correct that the logLevel setting has to be set (with the ui command line tool) for each accessory? Or is there some global setting for this or a command that sets this for all devices?
  2. What exactly do the logLevels 0, 1 and 2 stand for? I don't want to take too much about errors/infos away from the logs but I don't have to know every time a light turns on

thanks for any answers!

ebaauw commented 9 months ago

Ad 1. Yes, log level is per accessory, but newly paired accessories inherit the level from the gateway.

Ad 2. See https://github.com/ebaauw/homebridge-lib/wiki/Log-Messages. Even with level 0, you’ll still see the warnings and errors.

ThunderFD commented 9 months ago

Thanks for your reply!

Ad 1. Yes, log level is per accessory, but newly paired accessories inherit the level from the gateway.

I see, then I'll have to write a little script that changes the log level for all of them. (that could be a neat future feature to have a built in command for that) But good to see that newly added accessories will inherit the log level from the gateway 👍

Ad 2. See https://github.com/ebaauw/homebridge-lib/wiki/Log-Messages. Even with level 0, you’ll still see the warnings and errors.

Perfect, thanks for the link!

closing this issue 🙏

ThunderFD commented 9 months ago

for anyone stumbling over this, here's a short python3 script to change the logLevel for all accessories and the gateway to 0

import os
import json

# the command to get a dictionary of all the accessories
accessories_command = "ui get /accessories"

# run the command and get the output
accessories = os.popen(accessories_command).read()

# create a list of the keys
accessory_ids = list(json.loads(accessories).keys())

# what to change for each accessory and the gateway
payload = {"logLevel": 0}

# set the change for each accessory
for accessory_id in accessory_ids:
    os.system(f"ui put /accessories/{accessory_id} '{json.dumps(payload)}'")

# set the change for the gateway
os.system(f"ui put / '{json.dumps(payload)}'")
ebaauw commented 9 months ago

Or, using bash:

for i in $(ui get -al /accessories | grep /name | cut -d / -f 2) ; do
  ui put /accessories/$i '{"logLevel": 0}'
done