Hello,
not very clear how is your configuration.
I suppose you have split configuration so you include in your configuration.yaml for modbus via modbus: !include modbus.yaml
, correct?
Then don’t you have a split configuration for templates? you included in configuration.yaml?
you included templates in the modbus.yaml?
I suggest you split the configuration for templates too.
So your configuration,yaml will look like:
template: !include templates.yaml
modbus: !include modbus.yaml
then in same folder you will have two files:
modbus.yaml
- name: nilan
type: tcp
host: 192.168.188.107
port: 502
sensors:
- name: nilan_operation_mode
address: 5432
slave: 1
data_type: int16
input_type: holding
unique_id: nilanoperationsmodus
- name: Luftfeuchtigkeit
unique_id: nilan_humidity
# Current humidity
address: 4716
unit_of_measurement: "%"
slave: 1
no validation error in my test.
templates.yaml
- sensor:
- name: "yournameforsensor"
unique_id: auniqueid
state: >
{% set nilan = states("sensor.nilan_operation_mode") | float(0) %}
{% if nilan | int == 0 %}
"Wert ist undefiniert"
{% elif nilan | int == 1 %}
"kühlen"
{% elif nilan | int == 2 %}
"heizen"
{% elif nilan | int == 3 %}
"entfeuchten"
{% elif nilan | int == 4 %}
"Wasser aufheizen"
{% else %}
"Unbekannter Wert"
{% endif %}
availability: >
{{ states('sensor.nilan_operation_mode') | is_number }}
this gives no validation error in my test
VSCode or Notepad++