I’ve not tried this using Sonoff, but it sounds like it can be done. I’ve got similar automations. I’m running hass.io on a Raspberry Pi, using the default installation method. I’ve got the Xiaomi human body sensor connected to a Dresden electric DeConzz stick. (I’ve also used Xiaomi sensors connected to smartthings, but there was too much lag). I’ve got some Xiaomi sensors also connected to the Xiaomi hub, and that’s connected to Hass.io as well. (I’ve found it’s easier to pair the sensors with the Xiaomi hub than it is with the Deconzz stick). As for turning on fans and lights, you can use an automation that will flip things on or off when presence is detected, and adding automation “conditions” will restrict it to the times you want. It sounds like you might be new to Home assistant though - please keep in mind, Hass.io is not an “off the shelf” consumer ready product. You will need to read the documentation on automation if you want to setup complex conditional logic.