sander1988 / Indego

Home Assistant Custom Component for Bosch Indego Lawn Mower
Apache License 2.0
96 stars 29 forks source link

[Request] Provide indego informations as attributes in addition to entities #141

Closed xguitoux closed 3 years ago

xguitoux commented 3 years ago

Hey there,

I'm making a custom card for our indego mowers First draft example : https://cdn.discordapp.com/attachments/719165482346741777/869572421525598258/unknown.png

But in order to be user friendly it's better to provide only 1 entity (main indego entity, maybe "connected" value) with custom attributes (battery, mowing mode etc.) I had to make a custom entity with a template

platform: template sensors: tondeusebosch: friendly_name: Tondeuse Bosch value_template: states.binary_sensor.indego_xxxxx_online_2.state attribute_templates: battery: > {{states.sensor.indego_xxxx_battery_percentage_2.state}} details: > {{states.sensor.indego_xxx_mower_state_detail_2.state}} status: > {{states.sensor.indego_xxx_mower_state_detail_2.state}} connection: > {{states.binary_sensor.indego_xxxx_online_2.state}} lawn_mowed: > {{states.sensor.indego_xxx_lawm_mowed_2.state}} mode: > {{states.sensor.indego_xxxx_mowing_mode_2.state}} last_completed: > {{states.sensor.indego_xxxx_last_completed_2.state}} mowtime_total: > {{states.sensor.indego_xxxxx_runtime_total_2.state}}

Is it possible for you to add custom attributes to the main entity ?

Thank you

jm-73 commented 3 years ago

@eavanvalkenburg I need your comment on this!

eavanvalkenburg commented 3 years ago

@xguitoux and @jm-73 I see the asks but since we also have the seperate sensors, I'm not sure this is the way to go, for two reasons, 1) there is work being done to create a dedicated Mower entity HA wide, so depending on what that looks like we should make sure this visual aligns with that effort 2) in general it makes more sense to get the visual to pull in states from multiple entities because then different mowers (existing ones) can also use this visual, but I have never developed a visual so not sure how easy that is...

xguitoux commented 3 years ago

@eavanvalkenburg Hello and thank you for the answer, my small work was based on a xiaomi vacuum, but in general when you add a custom card for a group of entities you only add the main sensor and all other informations are based on attributes.

But again it's my first attempt to make a custom card, there may be a better way to implement it...

eavanvalkenburg commented 3 years ago

@xguitoux no problem, let me know if you figure out a way to use multiple sensors, that would be my preference and is most likely to align with HA guidance!

eavanvalkenburg commented 3 years ago

I use this one that has multiple sensors as input: https://github.com/gurbyz/power-wheel-card

xguitoux commented 3 years ago

@eavanvalkenburg If you stick with the naming convention of your indego sensors I can maybe manage to generate all needed sensors based on the state on, but I will have to use regular expressions and I hate that ^^

Do you have a link to the HA guidance for sensors/attributes ?

urbatecte commented 3 years ago

Hi, By the way, if you find a way to display "Last completed..." in a "normal" display, it will be great I've try to change the format but unsuccessfully :-(

image

May be more like that: image

Thanks a lot !

xguitoux commented 3 years ago

image

Salut @urbatecte, I changed a little the template to display how many days ago last mow was made with this in the template

 last_completed: >
          {{ relative_time(states.sensor.indego_XXXXX_last_completed.state|as_datetime) }}

For a friendly display of the date try this {{ as_timestamp(states.sensor.indego_xxxxxx_last_completed.state) | timestamp_custom('%c') }}

urbatecte commented 3 years ago

Fantastic @xguitoux, but here is my noob question: Should I add this template in the card or in the configuration.yaml or somewhere else ?

Shamshala commented 3 years ago

Try edit this and this from "ISO8601" to None and you shouldn't have to do that modification.

urbatecte commented 3 years ago

Thanks @xguitoux and @Shamshala .

I'm quite happy with templating. image

I prefer to keep @jm-73 code as is in order to be update-proof :-)

I will dig a bit more within the timestamp_custom.

xguitoux commented 3 years ago

I've managed to work without attributes and custom template, you can find v1 here https://github.com/xguitoux/lovelace-bosch-indego-card

eavanvalkenburg commented 3 years ago

Super cool @xguitoux !

urbatecte commented 3 years ago

Hi @xguitoux , I've try your card but, I didn't succeed.. image Even if when I click on the icon it seems that the entity is reached ? image

By the way, you may have to open the issue in your repository (that why, I post here) Thanks

xguitoux commented 3 years ago

@urbatecte Didnt saw that issues had to be opened, it's now done, can you open one in my repo and post your config, maybe a screenshot of F12 console when you load the card ? Thank you