wubbl0rz / FiatChamp

FIAT (uconnect) Home Assistant Addon 🚗
https://github.com/wubbl0rz/FiatChamp
MIT License
91 stars 17 forks source link

500e blink #19

Open thecem opened 1 year ago

thecem commented 1 year ago

THANK YOU for this integration!!

Do blinking for the neuer 500 (MJ22/500e) work?

My 2 cents for optimizing:

Entiity position should be a device_tracker. Sensors for units could a attribute in the entity. Tire information should one entity per tire with all attributes. Battery could change the icon on status if the sensor type is battery, so the icon belongs to the SOC. And with the information of charging or discharging the icon could even animated: "device_class: battery" If you change the door switch to a lock you have only one state: "entriegeln" if the door is closed and "verriegeln" if it is open

Thanks a lot!

wubbl0rz commented 1 year ago

i never used blink or light control myself :smile: it should do the same as the app. if not maybe it has connection issues and does not work first try. the app sometimes has timeouts too.

changing the entities is a bit problematic because i mainly just transform the response from the fiat api to home assistant sensors. i do not know every key. it might be a completely different response with other cars or other vendors. for example tire info is already contained multiple times in the api response. i do not know which car uses which field. so i cannot create more concise sensors with the information. because it varies from car to car the users has to look through the provided data and extract the information thats relevant.

Entiity position should be a device_tracker. CAR_LOCATION is a device tracker

Sensors for units could a attribute in the entity. just ignore the unit sensors they only exist because of the things i explained above 😁 the most sensors already have correct units and device_class.

Tire information should one entity per tire with all attributes. not really possible because response can be different between cars.

Battery could change the icon on status if the sensor type is battery, so the icon belongs to the SOC. And with the information of charging or discharging the icon could even animated: "device_class: battery" isnt the battery already "unit_of_measurement: %" and "device_class: battery" ? for changing icons depending on sensors status this can already be done in the home assistant frontend with suitable lovelace cards. maybe i can change the battery icon to better match the %.

but better do it in the frontend. mine looks like this and changes colors and icon depending on the charge %

image

kduchrow commented 1 year ago

I really like your type of visualization. Could you please share your YAML configuration for that? Thank you!

wubbl0rz commented 1 year ago

yes here it is. using mushroom-template-card and card mod for font size.

hmm now that i'm looking at it i think instead of the ugly if statements one could use string interpolation for the icons :smile: maybe i try it later. @kduchrow if you find a cleaner way let me know :smile:

type: custom:mushroom-template-card
primary: Auto Ladung
secondary: '{{ states(entity) }} %'
icon: |-
  {% if states(entity) | int > 90  %}
    mdi:battery-charging-90
  {% elif states(entity) | int > 80 %}
    mdi:battery-charging-80
  {% elif states(entity) | int > 70 %}
    mdi:battery-charging-70
  {% elif states(entity) | int > 60 %}
    mdi:battery-charging-60
  {% elif states(entity) | int > 50 %}
    mdi:battery-charging-50
  {% elif states(entity) | int > 40 %}
    mdi:battery-charging-40
  {% elif states(entity) | int > 30 %}
    mdi:battery-charging-30
  {% elif states(entity) | int > 20 %}
    mdi:battery-charging-20
  {% else %}
    mdi:battery-charging-outline
  {% endif %}
entity: sensor.car_evinfo_battery_stateofcharge
icon_color: |-
  {% if states(entity) | int > 90  %}
    green
  {% elif states(entity) | int > 80 %}
    green
  {% elif states(entity) | int > 70 %}
    green
  {% elif states(entity) | int > 60 %}
    orange
  {% elif states(entity) | int > 50 %}
    orange
  {% else %}
    red
  {% endif %}
badge_icon: ''
fill_container: false
multiline_secondary: false
layout: horizontal
tap_action:
  action: none
double_tap_action:
  action: none
hold_action:
  action: more-info
card_mod:
  style: |
    ha-card {
      --icon-size: 154px;
      --card-primary-font-size: 24px;
      --secondary-text-color: none;
      --card-secondary-font-size: 84px;
    }
kduchrow commented 1 year ago

Nice, thank you! yes, it looks a little bit like some code duplication but it works and looks good. I will have a closer look and come back if I find a cleaner way :)

kduchrow commented 1 year ago

I think I have found a somewhat cleaner solution that should do nearly the same job and add the complete full state. hope it helps :) Edit: I added the charging status to the icon and fixed one remaining issue


type: custom:mushroom-template-card
primary: Ladezustand
secondary: '{{ states(entity) }} % '
icon: |-
  {% if is_state('sensor.car_evinfo_battery_chargingstatus', 'CHARGING') -%}
    {%set c = "-charging"%}
  {%- else -%}
    {%set c = ""%}
  {%- endif %}
  {% if states(entity)|int < 20  %}
    mdi:battery{{c}}-outline
  {% elif states(entity)|int >= 99 %}
    mdi:battery
  {% else %}
    mdi:battery{{c}}-{{(states(entity)|string)[:1]}}0
  {% endif %}
entity: sensor.car_evinfo_battery_stateofcharge
icon_color: |
  {% if states(entity)|int > 50 and states(entity)|int <= 80 %}
    orange
  {% elif states(entity)|int > 80 %}
    green
  {% else %}
    red
  {% endif %}
badge_icon: ''
fill_container: false
multiline_secondary: false
layout: horizontal
tap_action:
  action: none
double_tap_action:
  action: none
hold_action:
  action: more-info
card_mod:
  style: |
    ha-card {
      --icon-size: 154px;
      --card-primary-font-size: 24px;
      --secondary-text-color: none;
      --card-secondary-font-size: 84px;
    }