Quick question about debug logging for a custom integration. I am creating a new light integration, with a light.py, and I have written a library that light.py uses (lampster.py), which light.py draws upon to make an object and then makes calls into the object. Nothing exciting there…thats how integrations work.
But I can only get debug logging to actually write to the HA logs when I do logger calls from light.py.
When I do the same logger calls in my lampster.py library in the same way absolutely nothing seems to happen. It runs and the lines seem to execute, but no logs appear in the HA logs (System/Logs)
Any ideas? It makes it really hard to work out what’s going on when the library is failing silently (incidentally if I raise an Exception in the library that doesn’t seem to feature in the logs either)
You shouldnt set the log level in your integration. If you want to turn on debug logging for a custom component you should do this in configuration.yaml.
EDIT: Oh and if lamster.py is part of a library loaded via pip (or in your manifest.json) you would need to add a line for that library in the above. If just part of your custom component files, above will work (providing you have the same definition for logger in that file too.
Ok … the library is just a file in the same folder I import that I wrote (it’s a library because I use it outside HA too so it saves me writing the complicated BLE command set out twice) and not installed with pip.
My configuration.yaml names the component already in debug logging. (I copied another integration when I started and the logging code earlier was already there so I assumed i needed it!)
As the component is set to debug logging should my library I import be captured by the same config? Otherwise do I put the name of the python library in configuration.yaml?
The code is long and messy. It doesn’t need to be seen in public. I’ve got fragments of working code and lots of mess as I try to work out why I am having so much of a problem in HA with BLE*
It’s just a typical light.py in structure and the lampster library looks something like the one in my GitHub repo
I could just rewrite the whole thing in light.py so logging works but I would rather keep my library separate so I can keep it in sync
So it’s an annoyance really but it must be fixable
Chris
*(I have been talking to bdraco as the HA wrapper for Bleak seems to cause me issues when Bleak works fine outside HA. One issues has been fixed but the wrapper combined with a really badly engjneered light I’m controlling is making this hard)