Handle non-string values in JSON renderer (#20233)
Handle the case of async_render_with_possible_json_value's value argument being something other than a string. This can happen, e.g., when using the SQL sensor to extract a datetime column such as last_changed and also using its value_template to convert that datetime to another format. This was causing a TypeError from json.loads, but async_render_with_possible_json_value was only catching ValueError's.
This commit is contained in:
1 parent
3fcbcd5a38
commit
935e5c67a3
2 files changed
+12
-1
No files matched your search
@@ -167,7 +167,7 @@ class Template:
|
||||
|
||||
try:
|
||||
variables['value_json'] = json.loads(value)
|
||||
except ValueError:
|
||||
except (ValueError, TypeError):
|
||||
pass
|
||||
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user