Closed GeekyTim closed 5 years ago
The template parser can't parse that expression, probably because you're using single quotes '
for both the element names (e.g. 'temp_out'
) and the "words" that make up the #calc#
expression, (e.g. 'wind_chill(data('temp_out'], data['wind_ave'])'
).
I have it outputting some data now. Not sure how accurate it is at the moment, but I think I have got it now.
@GeekyTim
I noticed you had data('temp_out']
instead of data['temp_out']
Could you post here your final working template for others?
Thanks
That's a mistake I hadn't spotted. Should definitely be square brackets.
Here is the line:
'#calc \'wind_chill(data["temp_out"], data["wind_ave"])\' \'"chill": "%.1f", \' #\n'
And it works!
I prefer to use double quotes for the #calc
delimiters and single quotes for the dict
keys, which is the style I've been consistent in using in pywws.
#calc "wind_chill(data['temp_out'],data['wind_ave'])" "'chill':'%.1f',"#
I've tried formatting the wind_chill in the MQTT template, but for the life of me I cannot get it to work. I get:
File "", line 12
Jun 01 19:44:34 PiWeather pywws-livelog[1570]: '#calc \'wind_chill(data('temp_out'], data['wind_ave'])\' \'"chill": "%.0f",\' \'\' \'scale(x, 10.0)\'#\n'
Do you have any idea what is happening here?