Try as I might, I just can’t get any sensors defined in sensor.yaml to show up! I’ve done the sensor: !include sensor.yaml in configuration.yaml and I don’t see any errors in the log.
What am I missing?
template:
- sensor:
- name: 'PS Propane Tank Percentage'
unique_id: sensor.propane_ps_pct
icon: mdi:propane-tank
state: >
{# Set three user supplied variables. Use the same units that the mo>
{% set overall_length = 94.00 %}
{% set overall_tank_diameter = 30.00 %}
{% set wall_thickness = 0.25 %}
{% set internal_tank_diameter = overall_tank_diameter - 2 * wall_thi>
{% set side_length = overall_length - overall_tank_diameter %}
{% set measured_fill_depth = states('sensor.pro_check_b09e_tank_leve>
{% set R_tank = internal_tank_diameter / 2 %}
{% set spherical_volume = 4 / 3 * pi * R_tank**3 %}
{% set cylinder_volume = side_length * pi * R_tank**2 %}
{% set max_volume = spherical_volume + cylinder_volume %}
{# Calculate the volume of a spherical cap of height equal to the fi>
{% set fill_spherical_volume = pi / 3 * measured_fill_depth**2 * (3 >
{# Calculate the volume of a partial horizontal cylinder: https://ww>
{% set fill_cylinder_volume = side_length * (R_tank**2 * acos((R_tan>
{% set measured_fill_volume = fill_spherical_volume + fill_cylinder_>
{{ (100 * measured_fill_volume / max_volume) | round(2) }}
- sensor:
- name: kevin_test
unique_id: kevin_test
state: "1234"
then it’s NOT for Template Sensors defined in modern format, only in legacy format.
Modern format Template Sensors are defined under the template: key, which you have, but you then put them in a file that is under the sensor: key.
You can do this
template: !include template.yaml
Then put the modern format Template Sensors (and any other Template entities) in template.yaml. However, ensure the first line of the file does NOT contain template: because that would be redundant (and cause a YAML configuration error).
You could have a tiny syntax error in there, so start with a stripped down version with a simple number to get the sensor creation working and find some success. Then I would take that big template into the developer template tools and make sure what you want is happening. Then paste all that in the working sensor instead of the placeholder number above.
Small steps, testing between, saves frustration and brings better results.