rotationPercent and rotationAbsolute resets after page change or screen lock #275
-
So I have a volume knob for one of my media devices rotating them to change the volume works amazing. But keeping that volume is an issue. Since both If we could get the volume variable in the json area, that would be a temporary fix, as I can use the ticks to adjust. Here's my code for reference: { "volume_level": {{ rotationAbsolute / 255 }} } |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Hi, i understand your wish to have access to state variables in the service call JSON. Long story short: It would be very complicated to implement and make configuration much more complex than it already is. But there is hope: {
"color_temp": "{% raw %}{{ state_attr('light.living_room_ikea','color_temp') + {% endraw %}{{ ticks }}{% raw %} }}{% endraw %}"
} Not only my plugin supports the nunjucks syntax, the home-assistant side does as well. To send (parts) of the template to homeassistant, you can use the The above example sets the Entered in plugin: {
"color_temp": "{% raw %}{{ state_attr('light.living_room_ikea','color_temp') + {% endraw %}{{ ticks }}{% raw %} }}{% endraw %}"
} Sent to home-assistant after non-raw values were rendered on plugin side: {
"color_temp": "{{ state_attr('light.living_room_ikea','color_temp') + 5 }}"
} This is rendered again on home-assistant server side (where you can do almost everything). |
Beta Was this translation helpful? Give feedback.
-
That's awesome! I feel like I'm closer, but not close enough. I tried this: { "volume_level": "{% raw %}{{ state_attr('media_player.chromecastaudio6417','volume_level') + {% endraw %}{{ ticks / 100 }}{% raw %} }}{% endraw %}"}
And it's not quite working. |
Beta Was this translation helpful? Give feedback.
-
Sorry to awaken an old thread but how do I make it so the light doesn't go off when it hits zero? My math escapes me |
Beta Was this translation helpful? Give feedback.
-
Thanks again for your help! |
Beta Was this translation helpful? Give feedback.
Hi,
i understand your wish to have access to state variables in the service call JSON. Long story short: It would be very complicated to implement and make configuration much more complex than it already is.
But there is hope:
Not only my plugin supports the nunjucks syntax, the home-assistant side does as well. To send (parts) of the template to homeassistant, you can use the
raw
option.The above example sets the
color_temp
to the current (home-assistant side) value + the plugin's side ticks value. It looks confusing, but you should be able to use this to…