I recently found out that the formatting of some of my template sensors is probably wrong… but in any case, they’ve been working consistently for quite a while. I’m going to start migrating everything into a templates directory, and I’ve confirmed this entry in configuration.yaml
is working for me:
template: !include_dir_merge_list templates
Here are the first three sensors in one of the yaml files in that directory:
# formatted date and time
- sensor:
- unique_id: date_formatted
name: Date Formatted
device_class: timestamp
state: "{{ now().strftime('%B %d, %Y') }}"
- sensor:
- unique_id: time_formatted
name: Time Formatted
device_class: timestamp
state: "{{ now().strftime('%-I:%M %p') }}"
- sensor:
- unique_id: day_date_formatted
name: Day Date Formatted
device_class: timestamp
state: "{{ now().strftime('%A, %B %d, %Y') }}"
None of them are working correctly. They are all in state “unknown.” Now… I’ve been told I could do without the - sensor
line before each of them, but all of the sensors but these three are working. For example:
- sensor:
- unique_id: outside_temperature
name: Outside Temperature
device_class: temperature
unit_of_measurement: "°F"
state: >
{% set darkskytemp = states('sensor.dark_sky_temperature') | float %}
{% set pooltemp = states('sensor.pool_heater_water_temperature') | float %}
{% if is_state('input_boolean.pool_open', 'on') %}
{{ darkskytemp }}
{% else %}
{{ pooltemp }}
{% endif %}
This is updating this morning just fine, and has continued to update after I moved it into the templates directory and rebooted.
So this morning, I set about altering each of my yaml files containing binary sensors, template sensors, etc. to the correct format, but the end result was that new entities were created for each of my sensors: sensor.day_date_formatted_2
, for example. I’ve got a lot of template sensors, and I really don’t want to go through all of my automations and change every reference. So instead, I figured I’d delete the newly-orphaned original entities and just change the name of each “_2” sensor in the UI… right?
Well… the new “_2” entities were unavailable to edit in the UI:
This entity (‘xxxx.xxxxx’) does not have a unique ID, therefore its settings cannot be managed from the UI. See the documentation for more detail."
So, I’m stuck. In the near term, I want to fix these simple little time & date sensors I have. In the long term, I want to figure out how to “fix” my split-out yaml files in a way that won’t cause me to have to spend several hours renaming things.
Any ideas?