Skip to content

Templating of "service_data" ? #48

Answered by pkozul
misko2k asked this question in Q&A
Discussion options

You must be logged in to vote

@misko2k

This was actually quite easy to implement. New version 1.0.17 has support for functions. You can see this in the Ring example.

https://experiencelovelace.github.io/ha-floorplan/docs/example-ring/

There is a new (optional) config section called functions:. You can add as many functions as you need. They just need to be contained in the structure shown:

  functions: |
    >
    return {

      getPercentageFill: (entity) => {
        var max = [195, 232, 141];
        var min = [240, 113, 120];
        var r = Math.floor(min[0] + ((max[0] - min[0]) * (entity.state / 100)));
        var g = Math.floor(min[1] + ((max[1] - min[1]) * (entity.state / 100)));
        var b = Math.floor(m…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@exetico
Comment options

Answer selected by exetico
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants