Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Replace value_json in templates with filters #811
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
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
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.
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