MQTT Sensor vs. Sensor entity

Hello,

just (kind of) worked out a custom sensor component that can get radiation values from some web page (https://odlinfo.bfs.de, for Germany only).

While coding (which was fun anyway), I came across the following alternative: what is the advantage of a custom component for HA compared to a separate python script (run periodically via cron) that obtains web service values and published them via MQTT. MQTT values could then be picked up by some MQTT sensor.

I am satisfied with what I did. Just would like to understand advantages / disadvantages of using MQTT as an alternative.

Any recommendation / experience ?

Lars

If you write something that uses MQTT, you can use it with all kinds of controllers, not just HA, which will make your code useful to more people.

You may be able to do more with the HA UI in a custom component, if you need to do so.

Thanks for clarification. Did not think about the open approach MQTT might bring beyond HA.

For the moment I like, that I do not need some separate process / cron setup but all is contained in HA.

Lars

You can also trigger a python_script by an automation. This python script can set sensor values.