Does History Sensor work on an ESPHome sensor?

I have a binary sensor defined in ESPHome and it shows when my water heater is on. I want to determine how long it is on each day. (It is inverted - the water heater is on when the contacts close so waterheater=false when on.) Other posts say to use the history sensor so I did like this in my configuration.yaml file:

  - platform: history_stats
    name: Water Heater ON Today
    entity_id: sensor.waterheater
    state: 'off'
    type: time
    start: "{{ now().replace(hour=0, minute=0, second=0) }}"
    end: "{{ now() }}"

The sensor in ESPHome is defined like this:

binary_sensor:
  - platform: gpio
    id: waterheater
    pin:
      number: GPIO27
      mode:
        input: true
        pullup: true
    name: Water Heater
    

Nothing shows up in the history sensor yet the water heater shows as going on anf off. When I bring up the history sensor, I get:

Can someone tell me why this is not working?
Thanks for any suggestions.

Also, I don’t understand why there are two lines of graphs instead of one like all other entities. How do I read this?