If you want to easily write rules in python (3) you should check out HABApp.
It’s a python rule engine which focuses on simplicity and provides type hints and auto complete if you use an IDE. Together with PyCharm as an IDE it’s an awesome and fun way to create automation rules.