History statistics sensor and MariaDB

Hello,

I have couple of timers in my Home Assistant installation that uses History Statistics sensors.They have been working fine until I moved to MariaDB. After that they have been working really weird for example they have been counting when they should not and when they should they stay at 0.

Is there some modifications that I should made because fo the MariaDB? The DB itself is working fine.

Here is example of my timer sensor:

 - platform: history_stats
   name: Dishwasher washing time
   entity_id: switch.dishwasher
   state: 'on'
   type: time
   start: '{{ as_timestamp(states.switch.dishwasher.last_changed) }}'
   end: '{{ now() }}'

So this sensor is not counting when switch dishwasher is in state on but it is counting sometimes when it is in state off…

For some weird reason this works fine when I change config to following

   start: '{{ states.switch.dishwasher.last_changed }}'
   end: '{{ utcnow() }}'