-
Notifications
You must be signed in to change notification settings - Fork 26
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
Feature Request: Allow Template For Battery Entity #165
Comments
Please provide a PR. Maybe you can use something like this? |
When configuring manually providing the entity_id is fine, works great, but if you use something like Auto Entities there is no way to populate the battery field since it's not part of the plant entity itself. My request is so that I can template the proper value into that field when it is auto generated. |
My mistake, this should have been on the flower card - although, if we are using Home Assistant's built-in Plant system as a base for this replacement, the HA plant does have the ability to link to a battery entity on the plant template itself, which should then translate to the Flower Card. |
I am pretty sure my flower-card does not work with the standard HA-plant-integration. I have - on purpose - not added a battery entity to the plant device, as for many of my plants, I use different physical sensors for e.g temperature, humidity, light etc. Any of these (can) have batteries, so I don't like to include a single battery to the plant as I want the plant to be an autonomous entity and plants themselves do not usually have batteries... Regarding templating of the card config, I have no idea how to attack that, so I would really need help there. |
I think I've solved what your asking for using the auto entities. Works for me at least. Dashboard example (each card is an area, Vardagsrum (living room) in this example): views:
- title: Home
cards:
- square: false
type: grid
title: Vardagsrum
cards:
- type: custom:auto-entities
filter:
template: |-
{% for state in states.plant -%}
{%- if state.entity_id | regex_match("plant.plant.*", ignorecase=True) and area_id(state.entity_id) == 'vardagsrum' -%}
{{
{
'entity': state.entity_id,
'type': 'custom:flower-card',
'battery_sensor': state.entity_id | regex_replace(find='plant\\.plant\\_([\\d]+)', replace='sensor.mi_flora_\\1_battery', ignorecase=False),
'show_bars': [
'moisture',
'conductivity',
'temperature',
'illuminance',
'humidity',
'dli'
],
'display_type': 'full'
}
}},
{%- endif -%}
{%- endfor %}
columns: 1
sort:
method: friendly_name
show_empty: true
card_param: cards
card:
square: false
type: grid
columns: 1 |
This probably belongs under the flower-card. If someone can verify that the example works, I can add it to the README there. |
See below for verification it works. I should have added earlier that I use a naming scheme for plants and the devices I use for measuring (Mi Flora), so the example provided earlier requires plants named |
Would you be able to simplify the config to show it with just one card (e.g. without the auto-entities)? That way I can add examples for both a single card, and for auto-entites (unless auto-entities is a prerequisite for the battery-template to work). |
With one card you statically configure it so that's normally not a problem. A single card with static config: type: custom:flower-card
entity: plant.plant_001
battery_sensor: sensor.mi_flora_001_battery
show_bars:
- moisture
- conductivity
- temperature
- illuminance
- humidity
- dli |
No, with a template for battery. Just to get any escaped characters right |
I would love to be able to template the battery entity. I use this with auto entities and it works great, allowing me to filter the results as needed, but I can't display the battery percentage because the battery entity won't allow a template, i.e.:
Obviously the above would be a single line but I used that example just to show my request. My actual use case is a much more complex template that extracts the entity name to re-assemble the battery entity name.
The text was updated successfully, but these errors were encountered: