I would like to create a mariadb view to get state start and end timestamps for a selection of entities but it’s a bit more complicated with the HA db structure. Something like the history graph but directly with sql. This view will server for future sql sensors later on.