I have a picture frame connected to HASS.IO and I want to send the number of current images on display to HA via MQTT. That part is (now) easy.
I am using a Python script on the picture frame which I guess is right but the number of counted images is not.
#!/usr/bin/env python3 import os jpgCounter = 0 for root, dirs, files in os.walk("/home/pi/Pictures/frame"): for file in files: if file.endswith('.jpg'): jpgCounter += 1 print(jpgCounter)
It returns about 30% more images than there are in the various directories. Where is the mistake?