How to replicate yaml sensors in "Helpers" UI

I track my “heat on %” with some basic yaml sensors like this:

# THE FOLLOWING TEMPLATE SENSORS USED FOR TRACKING FURNACE ON TIME
template:
- sensor:
  - default_entity_id: sensor.hvac_status
    name: Heat status
    state: "{%- if is_state_attr('climate.lyric_t5_thermostat', 'hvac_action',
      'heating') %}\n  on\n{% else %}\n  off\n{%- endif %}"
sensor:
  - platform: history_stats
    name: Heat ON pct
    entity_id: sensor.hvac_status
    state: 'on'
    type: ratio
    end: '{{ now() }}'
    duration:
      hours: 24

Which works fine, but with all the fancy complex options in the “Helpers” UI now it seems to me that I should be able to replicate this in the UI. How? I’ve experimented a bunch of different ways and I can’t figure it out. The fields in the Create Helper UI are not well explained, and all the online examples just use yaml.

Please tell and/or show us where you are having problems. Most of the fields in the Helpers’ config flows are exact matches or near matches to the YAML configuration variables. Some configuration variable that are available in YAML are not available in the Helper config flow, for example default_entity_id is not an option the the Template sensor config flow.

There may also be optional fields in the Helper flow that don’t exist in YAML configuration like “Select a Device”.

FWIW, that should really be a binary sensor, not a sensor. Then your state template would just be a boolean expression:

{{ is_state_attr('climate.lyric_t5_thermostat', 'hvac_action', 'heating') }}

1 Like

I should clarify that I mean specifically the Create Helper UI for Templates and History stats, the two used in the above yaml. I have no issue creating Helpers like input_boolean sensors in the UI.

The problem is that the UI for the Helpers in my yaml contains many mandatory fields that are not used in my yaml, and I have no idea how to set them. And some fields in the UI do not seem to correspond to the yaml,

For example I select Create Helper - Template - Sensor. Ok so far.
The first field (mandatory) is State. Ok, that corresponds to yaml. The format is slightly different, but easily adapted.
That brings me to the end of the fields in yaml.
Now the UI insists that I enter additional fields, even though they are not marked mandatory.
Unit of measurement? There is none.
Device class? Not mentioned or necessary in yaml.
State class? The options don’t seem to be relevant…
Select a device? Why? What device? The thermostat is already in the State.

I’m not allowed to leave these empty, and whatever selection I make results in a non-functional template sensor that’s not what I had in yaml.

I hope that explains better.

Only fields mark with an * are mandatory. For Template sensors and binary sensors that’s Name and State

2 Likes

Thanks!
In updating my old yaml to new yaml, I didn’t realize that I should now be using template binary_sensor instead of sensor, which resulted in a bunch more irrelevant mandatory Helper UI fields. Makes sense.