#HA 2023.8.1 it is not possible to create a template sensor

1 messages · Page 1 of 1 (latest)

crystal pasture
#

Hi. I am new in HA.
I have read a lot of documentation to learn how to create a template sensor, but this task have been unsuccesful for me.

#

This is my configuration.yaml file:

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

sensor:
  - platform: template
    sensors:
      H_meter2:
        friendly_name: "H meter 2"
        value_template: "{{ states('sensor.ltst_2_as_humidity') | float(0) }}"

template:
  - sensor:
    - name: "T meter 2"
      state_class: "measurement"
      unit_of_measurement: "W"
      state: "{{ states('sensor.ltst_2_as_temperature') | float(0) }}"
#

The template sensors in my configuration.yaml files were tested Ok in template tool, but they do not even show up in the Development Tool --> States.

After restarting HA, no errors appear related to template sensors.

I appreciate any help

tiny vault
#

You're unnecessarily using two different formats to create two template sensors, but the only thing I see obviously wrong is that you're using a capital letter in the slug for the first sensor. It should be all lowercase

#

Otherwise, check the log

crystal pasture
#

Hi @tiny vault , thanks for youur reply.

I tried only one of the template configurations at the time.

The FIRST one with:

sensor:
  - platform: template
    sensors:
      h_meter2:
        friendly_name: "H meter 2"
        value_template: "{{ states('sensor.ltst_2_as_humidity') | float(0) }}"

RESULT:it did not work, and it does not show up in the Development tool --> STATES
The log does not indicate any problem/error with template sensor.
Settings -> System ->log, I will attache file.

NOTE: I appreciate any help

crystal pasture
#

Sorry. Do you know how to attach a file ??????

#

With the SECOND one with:

template:
  - sensor:
    - name: "T meter 2"
      state_class: "measurement"
      unit_of_measurement: "W"
      state: "{{ states('sensor.ltst_2_as_temperature') | float(0) }}"

RESULT:it did not work, and it does not show up in the Development tool --> STATES
The log does not indicate any problem/error with template sensor.
Settings -> System ->log, I will attache file.

NOTE: I appreciate any help to solve this problem, and to indicate how to attach a file to this chat.

deep shard
#

You can't attach files, what do you want to attach?

crystal pasture
steady auroraBOT
#

Please use a code share site to share code or logs, for example:

Please don't use Pastebin, since it can randomly add spaces to the main view. Please also don't share text as images since it makes it harder for people to help you. Remember that others may have colour blindness, impaired vision, etc.

deep shard
#

logs are text, put them on a code sharing file

crystal pasture
crystal pasture
deep shard
#

there is nothing in this log related to your template sensor

crystal pasture
deep shard
#

what are you trying to do anyway? Adding state class to your sensors?

#

as you are only outputting the state of another sensor

deep shard
crystal pasture
crystal pasture
# deep shard and is this your complete configuration.yaml?

This is my whole configuration.yaml file, testing the moderm style:

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

template:
  - sensor:
    - name: "T meter 2"
      unit_of_measurement: "°C"
      device_class: temperature
      state: "{{ states('sensor.ltst_2_as_temperature') | float(0) }}"
amber storm
#

Looks like the indentation is off

#
template:
  - sensor:
      - name: "T meter 2"
        unit_of_measurement: "°C"
        device_class: temperature
        state: "{{ states('sensor.ltst_2_as_temperature') | float(0) }}"