Help setting up history integration

I am trying to count my screen hours based on the ‘device_interactive’ entitiy provided by the companion app. This is in my config file:

- platform: history_stats
    name: Phone screentime
    entity_id: binary_sensor.phone.on
    state: "on"
    type: time
    start: "{{ now().replace(hour=0, minute=0, second=0) }}"
    end: "{{ now() }}"

The output is some strange value that is not even remotely close. It says “8:48:36” in the state, while I in reality it is closer to 3 hours.

I assume that indentation error is just a copy/paste issue?

What do you mean?

I mean it should be indented like this:

- platform: history_stats
  name: Phone screentime
  entity_id: binary_sensor.phone.on
  state: "on"
  type: time
  start: "{{ now().replace(hour=0, minute=0, second=0) }}"
  end: "{{ now() }}"

Ah, yes. That’s just a copy/paste thing.

I have noticed under dev options, it said something about having switched the unit to hour, which is strange, because it worked for a really short time. The sensor still updates, but with ‘useless’ data (because I can’t do anything with it).