Writing sensor values to mysql?

HA writes for me a bunch of sensor values to influxdb. Now I want to write those same sensor values to mysql instead of influx. Is this possible?
(I don’t talk about the recorder, which can use myqsl)

I don’t think so by default, but of course you can use the mysql commandline.

How do I know when to write out a sensor? I would need some trigger to know when the sensor has changed.

You mean like an automation state trigger?

If I want to write out the sensor values to mysql, I need to know when there is a new value.

Nick means that what you explain is the definition of an automation state trigger. Check the doc…

I do not want to write a new automation for every sensor I want to write out to mysql.

Too bad. Write your own MySQL integration then.

The recorder does that for you.

I suspect you want to use a different database schema for some purpose of your own. All good, you could write a mysql script to update your separate database when the recorder writes to the home assistant database. You would use a trigger What are MySQL triggers and how to use them?.

This is a good idea. I could just copy the influx integration and replace the influx part with mysql. The central thing seems to be:
hass.bus.listen(EVENT_STATE_CHANGED, self._event_listener)
But maybe it is easier to copy the recorder component to a recorder2 components which then writes my selected sensor values to mysql.
(I don’t want to change the recorder, because I want to record all sensors to SQlite for 3 days, and 10-15 sensors to mysql for long time monitoring.)