Here is a different way of doing what you are trying to accomplish and it will turn off when reaches a certain temp and also on at a certain temp:
alias: Turn Heater Off or On When Above or Below XX or XX
description: Turn Heater Off or On When Above or Below XX or XX
trigger:
- platform: state
entity_id: sensor.sonoff_10015dbf7f_temperature
condition: []
action:
- choose:
- conditions:
- condition: numeric_state
entity_id: sensor.sonoff_10015dbf7f_temperature
above: 'XX'
sequence:
- service: switch.turn_on
entity_id: switch.sonoff_100121d4d5
- conditions:
- condition: numeric_state
entity_id: sensor.sonoff_10015dbf7f_temperature
below: 'XX'
sequence:
- service: switch.turn_off
entity_id: switch.sonoff_100121d4d5
default: []
mode: single
I’m not sure how the counter works for this or what it is even counting, but if you know your temp limits you can just substitute the XXs I have in the above automation. But if this counter thing is what you really want, will will have to explain the setup in a little more detail, so I can wrap my head around it.