-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace value_json in templates with filters #811
Conversation
Adding a way to add custom filters sounds like a good plan. It will allow new components to register filters too. The annotation should probably just live in the template package, no need for an extra file. The reason I went for the
I wouldn't want to add support for other formats but JSON is common enough. I would not want to add the |
…nent getting initialized twice. closes #913
* Add missing binary sensor types to sensor/mysensors. * Remove unneeded pylint disable.
Conflicts: homeassistant/const.py
I will create a new PR once I have a working solution |
When template support got implemented to replace the json parsing I originally created for the mqtt component I did like the idea of the template approach. However, I disliked the json support because it basically tries to parse every message as json. Supporting other message formats would require additional
value_XXX
keys in the templates and that seems quite inflexible.With templates however we can use filters and I figured I'd give that a try to see if this wouldn't be a nicer implementation of json support in messages. I have now implemented two filters
json
andjsonpath
. The idea is to create a set of filters ready for use but also find a way to allow for custom filters created by users (e.g. in their configuration directories maybe?)With the two filters in this PR you can do something like this in your config:
This pull request is meant to illustrate the idea - the implementation is for sure far from perfect and is missing tests, but I first wanted to collect feedback to see if investing more time into this made sense or not.