I wouldn’t do it, but it will probably work.
If you share your code someone might come up with a better idea for you though. How to help us help you - or How to ask a good question.
For instance create an MQTT sensor on that topic and trigger on the sensor. MUCH more efficient that triggering an automation 86400 times a day.