From b72e8672afa7fbeb3118f1b8447d16fb3e3b7578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20=C3=98verli?= Date: Sun, 22 Jan 2023 13:11:06 +0100 Subject: [PATCH] Update card-power.md (#705) Added example of calculating the speed with HA templates. --- docs/card-power.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/card-power.md b/docs/card-power.md index b3404538..90c2ae2b 100644 --- a/docs/card-power.md +++ b/docs/card-power.md @@ -40,12 +40,17 @@ List of supported entitiy types for this page: Some details about speed: -It is possible to calculate the speed though home assistant templates, this allows to link the speed to something within your homeassistant. - -If you got a proper configuration for that, feel free to share it, would be a good addition to the documentation. +It is possible to calculate the speed through a Home Assistant template, this allows to calculate the speed in relation to other data in Home Assistant. +This template will calculate a speed setting based on the amount of power drawn on a device as a fraction of the total power usage. ``` - - entity: sensor.today_energy - speed: '{{ range(-3, 3) | random }}' + speed: >- + {% set entity_power = states('sensor.appliance_water_heater_power') |float | round(3)%} + {% set total_power = states('sensor.ams_power_active') | float | round(3) %} + {% set entity_usage = (entity_power / total_power * 100) | float %} + {{ (entity_usage | round()) * -1 }} +``` +It provides the number as a negative integer, making the dot move from the centre of the card toward the icon of your entity. If you want the dot to move towards the centre of the card, just skip inverting it at the end of the template like this: +``` + {{ (entity_usage | round()) }} ``` -