- remove
- add new to
configuration.yaml, not your sensor file.
- restart HA.
See the gotcha’s in the main post about combining multiple.
configuration.yaml, not your sensor file.See the gotcha’s in the main post about combining multiple.
I got you, thx for the help, but I didnt ask how to add everything in my configuration yaml. I asked how can I add it in my sensor.yaml.
But I guess just have to change it to template: sensors.yaml and add the sensors there…
- sensor:
- unit_of_measurement: °C
default_entity_id: sensor.carlo_temperature
name: Carlo temperature
state: '{{ (states.climate.carlo_heizung_thermostat_2.attributes.current_temperature)-1|round(1)
}}'
quite a lot of manual work if you have so many sensors. ![]()
but maybe with the same problem will help this ![]()
You can’t… You have to add it to configuration.yaml. It’s a new section, template:, not sensor:
yes, got this now. That was the answer of my original question ![]()
Thx a lot for the help! Just didnt see the difference bindings here and the change from sensor to template
You can still use !include with the new format template sensors. you simply replace add to configuration.yaml:
template: !include templates.yaml
and inside templates.yaml
- sensor:
- default_entity_id: sensor.carlo_temperature
name: Carlo temperature
unit_of_measurement: "°C"
state: "{{ states.climate.carlo_heizung_thermostat_2.attributes.current_temperature)-1|round(1) }}"
then if you add more sensors
- sensor:
- default_entity_id: sensor.carlo_temperature
name: Carlo temperature
unit_of_measurement: "°C"
state: "{{ states.climate.carlo_heizung_thermostat_2.attributes.current_temperature)-1|round(1) }}"
- some other sensor config
then if you want to add binary sensors
- sensor:
- default_entity_id: sensor.carlo_temperature
name: Carlo temperature
unit_of_measurement: "°C"
state: "{{ states.climate.carlo_heizung_thermostat_2.attributes.current_temperature)-1|round(1) }}"
- some other sensor config
- binary_sensor:
- some binary sensor config
- some other
- etc
Not replace, add. There may still be other sensor platforms that use the sensor.yaml file.
Good point. ![]()
I’d to migrate 4 switches based on template.
During migration a default_entity_id was suggested but when inserted into template.yaml file, a warning was raised on that specific line and I’d to remove the default_entityId. Here is the generated syntax for one of the switches:
- unique_id: alarma_fueradecasa_switch
turn_on:
- target:
entity_id:
- alarm_control_panel.risco_so_1_partition_0
action: alarm_control_panel.alarm_arm_away
turn_off:
- target:
entity_id:
- alarm_control_panel.risco_so_1_partition_0
action: alarm_control_panel.alarm_disarm
default_entity_id: switch.alarma_fueradecasa_switch #<== here
name: AUSENTE
state: "{% if is_state('alarm_control_panel.risco_so_1_partition_0','armed_away')
%}\n on\n{% else %}\n off\n{% endif %}"
The warning message stated DisallowedExtraPropWarning
Studio Code Server Version is 6.0.1
Why is that happening?
Regards
Because the Studio Code Home Assistant Helper extension is very out of date. You can ignore the warning, it is a false positive. Personally I have disabled the extension. It is now more of a hindrance than help.
374 repairs
to
go… ![]()
I had template in sensors file. (actually 3 bcs technically they are sensors) As I understand now they cant be inside that file anymore so I moved they inside templates.yaml file (syntax exactly as in repairs told) as following
- sensor:
- unique_id: pellet_kwh
default_entity_id: sensor.pellet_kwh
state: '{{ states(''input_number.pellet_price'')|float(0) / states(''input_number.kwh_from_bag'')|float(0)* 100 }}'
name: pellet_kwh
- sensor:
- unique_id: operator_margins
unit_of_measurement: 'c/kWh'
default_entity_id: sensor.el_tariff
name: "Electricity Tariffs"
state: >-
{% macro calc(v) -%}
{%set d = {"operator_margin": 0.641,
"electricity_excise": 0.21,
"renewable_tariff": 0.84,
"nw_fee_night": 4.28,
"nw_fee_day": 7.41
} %}
{%set day_price = v + ((d.operator_margin + d.renewable_tariff + d.electricity_excise + d.nw_fee_day) * 1.2 | float ) | round(4)%}
{%set night_price = v + ((d.operator_margin + d.renewable_tariff + d.electricity_excise + d.nw_fee_night) * 1.2 | float ) | round(4)%}
{% if now().weekday() in (5,6) %}
{{night_price}}
{% else %}
{% if now().hour >= 7 and now().hour < 22%}
{{day_price}}
{% else %}
{{night_price}}
{% endif %}
{% endif %}
{%- endmacro %}
{{calc(0)}}
- sensor:
- unique_id: Total_e_price
unit_of_measurement: c/kWh
default_entity_id: sensor.total_el_price
name: Total Electicity Price
state: '{{ (states(''sensor.nordpool_ee'') | float + states(''sensor.el_tariff'')
| float) | round (2) }}'
No errors by restart however lots of errors after restart
Invalid config for 'template' at templates.yaml, line 130: 'default_entity_id' is an invalid option for 'template', check: default_entity_id Invalid config for 'template' at templates.yaml, line 131: 'state' is an invalid option for 'template', check: state Invalid config for 'template' at templates.yaml, line 132: 'name' is an invalid option for 'template', check: name
Invalid config for 'template' at templates.yaml, line 136: 'unit_of_measurement' is an invalid option for 'template', check: unit_of_measurement Invalid config for 'template' at templates.yaml, line 137: 'default_entity_id' is an invalid option for 'template', check: default_entity_id Invalid config for 'template' at templates.yaml, line 138: 'name' is an invalid option for 'template', check: name Invalid config for 'template' at templates.yaml, line 139: 'state' is an invalid option for 'template', check: state
Invalid config for 'template' at templates.yaml, line 164: 'unit_of_measurement' is an invalid option for 'template', check: unit_of_measurement Invalid config for 'template' at templates.yaml, line 165: 'default_entity_id' is an invalid option for 'template', check: default_entity_id Invalid config for 'template' at templates.yaml, line 166: 'name' is an invalid option for 'template', check: name Invalid config for 'template' at templates.yaml, line 167: 'state' is an invalid option for 'template', check: state
so what now??
Fix your indentation… there are plenty of examples in the top post.
Is this really what is shown in the repair?
Because it should be:
- sensor:
- unique_id: pellet_kwh
All template Ssnsors? Can you post a link to the file?
Hello, I need some help.
I have a switch template like below and cen’t get it to work with the repair.
Replace that entire yaml you posted with the yaml from the repair.
I did and the switch stopped working for me.
Do you have another template section? Please read the main post and the common issues
Should I move both to template.yaml and specify the file in configuration.yaml?
Sorry for the dumb questions, but I’m new to this.