I’m trying to build a binary sensor that will be an alarm for me if the temp in the house gets too low. However, I am unable to get the alarm to trigger (it is always off.) Here is my configuration.yaml:
ERROR (Thread-1) [homeassistant.util.yaml] while parsing a block mapping
in “/home/hass/.homeassistant/binary_sensor.yaml”, line 4, column 7
expected , but found ‘’
in “/home/hass/.homeassistant/binary_sensor.yaml”, line 4, column 42
ERROR (MainThread) [homeassistant.bootstrap] Invalid config for [binary_sensor.template]: invalid template (TemplateSyntaxError: expected token ‘end of print statement’, got ‘gig_technologies_ct30_thermostat_temperature_7_1’) for dictionary value @ data[‘sensors’][‘temp_alarm’][‘value_template’]. Got ‘{{ states.sensor.2gig_technologies_ct30_thermostat_temperature_7_1.state < “48”}}’. (See ?, line ?). Please check the docs at Template - Home Assistant
returns “False” (or “True”, depending on the value in the template) as expected. However, when I use that template in the configuration.yaml, I get the error described in my last post:
ERROR (Thread-1) [homeassistant.util.yaml] while parsing a block mapping
in “/home/hass/.homeassistant/binary_sensor.yaml”, line 4, column 7
expected , but found ‘’
in “/home/hass/.homeassistant/binary_sensor.yaml”, line 4, column 42
If your temperature is always a float or integer, you could use the int or float filters so you don’t need quotes around the numbers and use the states() function so you don’t need the brackets:
The key is to not use the same type of quotes within the string, otherwise the parser can’t tell where the real end of the string is. If you use double quotes around the string, use single quotes everywhere within and vice versa.
You can sometimes also use a backslash to escape the quote within the string to tell the parser to treat it as a normal character and not the end of the string:
I just hit this issue myself. There appears to be a “problem” in the template engine if you have an entity of the form foo.x_y_z where either of x or y are only digits. For example, I had an entity named weather.1234_main_st (not my real address) and it would throw the error:
TemplateSyntaxError: expected token ‘end of print statement’, got ‘main’
Using this workaround, weather[“1234_main_st”] gets around the issue and the template works. This took a LOT of googling to figure out, but once I plugged in the error I got this thread. So THANK YOU!