Consider leveraging the HA ecosystem of integrations, but for automations add Node Red. There is a well maintained WS node to HA that lets you call any service/action in HA and listen for events or device state changes. https://flows.nodered.org/node/node-red-contrib-home-assista...
Along with everything else NR provides like MQTT pub/sub, only limit is imagination and time. I've been doing this for years. Another moving piece I know, but it has been bullet proof for me