Utility metter reset in two periods is possible? Maybe another sensor is better?

'Hello everyone, I’ve been using home Assistant for a short time, I’m trying to make an automatism and I can’t do it. It’s about knowing how long my Nest Thermostat is on in 2 time periods: from 9am to 9pm (day) and from 9pm to 9am the next day (night) I need to receive a telegram at the end of each period and reset the counter to start counting again and get new information every day. In short, I need to know how long my heating is on during the day (from 9am to 9pm) and at night (from 9pm to 9am the next day).
The problem that I have found is that I have tried it with 2 different types of sensors and they have not been able to satisfy my needs, perhaps because I do not know how to use them properly: - history stats and
utility_meter. The history stats by itself is not possible to reset, on the other hand, with the utility meter it is possible, but the cycle period is only selectable between 15min, daily, monthly… it is not possible to reset every 12 hours or in the hours that I choose.
I was also doing tests with the offset but I couldn’t reset the counter at 9:00 p.m. and at 9:00 a.m. I have tried to create 2 utility_meter with two different offsets but I do not achieve the desired goal. I also tried boolean switches and nothing. I don’t quite understand how the utility_meter options work.

Does anyone know the correct way to use the utility meter for my need or does anyone know of another type of sensor that can help me? Maybe some kind of yaml code or formula to use a template that can work with my climate.nest entity? Thanks in advance, greetings to all and thanks for this community’

The utility meter supports chron tab syntax. Therefore you should be able to set a chron pattern for every twelve hours:


Thanks for your answer, but how can we select the start time so that it coincides with 09am to 09pm and from 09pm to 09am of the next day? Could you read the counter before the restart to be able to send the value by telegram? I have very basic notions I am still learning. Anyway, thanks.

The second group of numbers */12

Imagine * is a stand in for zero (midnight) those are both hours in 24 hr format. So for 9a / 9p it’s 9/21 instead of */12