8

Just curious, but have you checked CPU usage ? Programs that run in a while loop can be terribly inefficient and taxing. Here you are just probing a sensor, this does not look like a computationally-intensive task but it's still overkill. Seems to me that a timer would be preferable. Sampling values from your sensors at regular intervals, even every few ...


6

If I understand what you are trying to do, I think you can (1) remember the prior state, (2) print only on changes, and (3) select the message to print based on the new state. def water_level(): messages = { False: "The system has water", True: "The system is dry and needs water", } previous = None while ...


5

Overall not bad! You've managed to avoid many of the "usual suspects" when it comes to Python scripting practices. make_logger could use a return typehint display_disk_usage, trivially modified to accept a mountpoint path, would be a more flexible implementation display_disk_usage is doing two things: displaying (what it says on the tin), and ...


4

I agree with @Anonymous that you should not loop continuously like that, or you'll waste energy and CPU time continuously checking the values. To solve this you can just sleep, wake up every minute, check the state and go back to sleep. Another more code-style related observation is that you don't need to nest while loops like that, but only keep track of ...


3

chatId -> chat_id and similar for other members and method names, by PEP8 standard f"Initializing temperature bot for 123 - " does not need to be an f-string - it has no fields if alertResp is not true, you should be raising an exception, not early-returning if alertResp is not True is equivalent to if not alertResp temperaturePolling should not ...


3

First, some minor issues: logger is a global variable, and all your functions are completely dependent on it being present -- and if you import this file it won't be. You may want to create the logger outside the if __name__ == '__main__': block, or pass the logger around as a parameter, or have your functions call logging.getLogger(__name__) themselves ...


Only top voted, non community-wiki answers of a minimum length are eligible