I do this all the time with node-red. I use the home assistant component along with the MQTT component. Here’s a sample flow. Node-red is pretty easy to use. I found it a lot easier and more powerful than automations. You can install it as an add on.
[{"id":"eee21803.27d698","type":"server-state-changed","z":"33715402.5f5d5c","name":"Check Light","server":"578e6426.d083ac","entityidfilter":"light.living_room_lights_level","entityidfiltertype":"substring","haltifstate":"","x":80,"y":620,"wires":[["28802b3b.fa54f4"]]},{"id":"28802b3b.fa54f4","type":"mqtt out","z":"33715402.5f5d5c","name":"local","topic":"light/living_room","qos":"","retain":"false","broker":"68c7942b.be311c","x":230,"y":620,"wires":[]},{"id":"578e6426.d083ac","type":"server","z":"","name":"Home Assistant","url":"http://192.168.3.5:8123","pass":"6tgkQJVAtnAeTQqU"},{"id":"68c7942b.be311c","type":"mqtt-broker","z":null,"name":"local","broker":"192.168.1.10","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]