Hi Guys,
Just wanted to check if I am doing something wrong or if there is a bug here. I have a template which is working fine and I went to add a new sensor to it and it failed but the error message is strange. This works:
- unique_id: "power_circuit_2_all_other"
name: "Power Circuit 2 minus Devices"
unit_of_measurement: W
icon: mdi:transmission-tower
state: >
{{ [(states.sensor.power2b.state | float(0)
- states.sensor.tasmota_energy_power_2.state | float(0)
- states.sensor.gpo2_2_power.state | float(0)
- (states.sensor.car_charger_power.state | float(0) | multiply(0.97))),0] | max
}}
This fails with the error message: Invalid config for [template]: invalid template (TemplateSyntaxError: expected token 'end of print statement', got 'd_printer_power') for dictionary value @ data['sensor'][6]['state']. Got '{{ [(states.sensor.power2b.state | float(0)\n - states.sensor.tasmota_energy_power_2.state | float(0)\n - states.sensor.gpo2_2_power.state | float(0)\n - (states.sensor.car_charger_power.state | float(0) | multiply(0.97))),0] | max\n - states.sensor.3d_printer_power.state | float(0)\n}}\n'. (See /config/packages/energy.yaml, line 1).
- unique_id: "power_circuit_2_all_other"
name: "Power Circuit 2 minus Devices"
unit_of_measurement: W
icon: mdi:transmission-tower
state: >
{{ [(states.sensor.power2b.state | float(0)
- states.sensor.tasmota_energy_power_2.state | float(0)
- states.sensor.gpo2_2_power.state | float(0)
- (states.sensor.car_charger_power.state | float(0) | multiply(0.97))),0] | max
- states.sensor.3d_printer_power.state | float(0)
}}
The template editor shows a similar issue. I put in {{ (states.sensor.3d_printer_power.state) }}
and I get TemplateSyntaxError: expected token ')', got 'd_printer_power'
sensor.3d_printer_power
is working fine it has a state of 12.15 and the attributes are:
state_class: measurement
last_seen: '2022-05-04T23:47:44.870Z'
linkquality: 65
power: 12.15
unit_of_measurement: W
device_class: power
friendly_name: 3D Printer power
1 post - 1 participant