tmjo / charger-card

A lovelace card for electrical vehicle (EV) home chargers and charging robots.
MIT License
88 stars 58 forks source link

Zappi adaptation - first proposal - help needed #40

Open sabbie-github opened 1 year ago

sabbie-github commented 1 year ago

Thank you for this card - much appreciated! Could you help me with a Zappi adaptation? I am only a newbie with no experience here - I made my first attempt in adapting the card. It works just fine, but would need help to get the group1 mode change functionality to work, for it to actually call the service of eco/eco+/boost/stop of the zappi.

Thankful for any guidance!

Here is how it looks on pics and the code zappi Screenshot 2023-02-17 130622 zappi Screenshot 2023-02-17 130622 select

type: custom:charger-card
title: Zappi EV Charger
entity: sensor.myenergi_zappi_xxx_status
customCardTheme: theme_transp_white
customImage: /local/media/white_zappi-removebg-preview.png
brand: zappi
show_leds: false
details:
  status:
    entity_id: sensor.myenergi_zappi_xxx_status
  substatus:
    entity_id: null
    unit_show: true
  smartcharging:
    entity_id: switch.myenergi_zappi_xxx_charge_mode
  currentlimits:
    - Fast
    - Eco
    - Eco+
    - Stopped
  statetext:
    Charging: Charging
    Paused: Paused
    Stopped: Stopped
    Completed: Complete
    Boosting: Boosting
  collapsiblebuttons:
    group1:
      text: Charger Mode
      icon: mdi:speedometer
    group2:
      text: Info
      icon: mdi:information
    group3:
      text: Settings
      icon: mdi:cog
  info_left:
    - entity_id: sensor.myenergi_zappi_xxx_plug_status
      text: Connection Status
    - entity_id: sensor.myenergi_xxx_power_charging
      text: Charge Power NOW
      unit_show: true
      icon: mdi:car-electric
  info_right:
    - entity_id: sensor.bmw_530e_remaining_battery_percent
      text: Car Battery Charge %
      icon: mdi:car-electric-outline
      unit_show: true
  group1:
    - entity_id: select.myenergi_zappi_xxx_charge_mode
      tap_action:
        action: call-service
        service: select.select_option
        data:
          option: Eco
        target:
          entity_id: select.myenergi_zappi_xxx_charge_mode
  group2:
    - entity_id: sensor.myenergi_xxx_power_charging
      unit_show: true
      text: Charge NOW
      icon: mdi:car-electric
    - entity_id: sensor.myenergi_zappi_xxx_charge_added_session
      unit_show: true
      text: Charge in Last Session
    - entity_id: sensor.myenergi_zappi_xxx_energy_used_today
      unit_show: true
      text: Grid Use Today
      icon: mdi:transmission-tower-export
    - entity_id: sensor.bmw_530e_remaining_battery_percent
      unit_show: true
      icon: mdi:battery-charging-medium
      text: Car Battery Charge %
    - entity_id: sensor.myenergi_xxx_voltage_grid
      unit_show: true
      text: Grid Voltage
      icon: mdi:flash-triangle-outline
    - entity_id: sensor.myenergi_xxx_frequency_grid
      unit_show: true
      text: Grid Frequency
  group3:
    - entity_id: number.myenergi_zappi_xxx_device_priority
      unit_show: true
      text: Device Priority
    - entity_id: number.myenergi_zappi_xxx_minimum_green_level
      unit_show: true
      text: Minimum Green Level
  stats:
    default:
      - entity_id: sensor.myenergi_zappi_xxx_charge_added_session
        text: Charge in Last Session
        unit_show: true
      - entity_id: select.myenergi_zappi_xxx_charge_mode
        text: Charge Mode
    Charging:
      - entity_id: sensor.myenergi_zappi_xxx_charge_added_session
        text: Charge in Last Session
        unit_show: true
      - entity_id: sensor.myenergi_xxx_power_charging
        text: Charge Power Now
        unit_show: true
      - entity_id: select.myenergi_zappi_xxx_charge_mode
        text: Charge Mode
    Paused:
      - entity_id: sensor.myenergi_zappi_xxx_charge_added_session
        text: Charge in Last Session
        unit_show: true
      - entity_id: select.myenergi_zappi_xxx_charge_mode
        text: Charge Mode
    Completed:
      - entity_id: sensor.myenergi_zappi_xxx_charge_added_session
        text: Charge in Last Session
        unit_show: true
      - entity_id: select.myenergi_zappi_xxx_charge_mode
        text: Charge Mode
    Boosting:
      - entity_id: sensor.myenergi_zappi_xxx_charge_added_session
        text: Charge in Last Session
        unit_show: true
      - entity_id: sensor.myenergi_xxx_power_charging
        text: Charge Power Now
        unit_show: true
      - entity_id: select.myenergi_zappi_xxx_charge_mode
        text: Charge Mode
tmjo commented 1 year ago

Looking good! Do you get any error message in HA log when you try to select something in the dropdown (i.e. call the service)?

Also, which integration are you using for Zappi? It would help to know the available services, if you go to Developer Tools -> Services and make a snip of the service you want to use.

I'm sure we'll get it working!

sabbie-github commented 1 year ago

Thank you for taking the time with this! with this code, I get the error "No service defined for this action or no service data given."

The myenergi zappi charger has four charge modes, that I want to use the group1 sector to select from: myenergi_zappi_xxx_charge_mode - fast eco+ eco stopped image

I can call these as service by creating four buttons (I dont know how to make it as one button that just has a dropdown option select). This works to call the services: image the code used for this is:

type: horizontal-stack
cards:
  - type: button
    tap_action:
      action: call-service
      service: select.select_option
      data:
        option: Eco+
      target:
        entity_id: select.myenergi_zappi_xxx_charge_mode
    name: Eco+
    icon: mdi:ev-station
    show_name: true
    show_icon: true
  - type: button
    tap_action:
      action: call-service
      service: select.select_option
      data:
        option: Eco
      target:
        entity_id: select.myenergi_zappi_xxx_charge_mode
    name: Eco
    icon: mdi:ev-station
    show_name: true
    show_icon: true
  - type: button
    tap_action:
      action: call-service
      service: select.select_option
      data:
        option: Fast
      target:
        entity_id: select.myenergi_zappi_xxx_charge_mode
    name: Boost
    icon: mdi:ev-station
    show_name: true
    show_icon: true
  - type: button
    tap_action:
      action: call-service
      service: select.select_option
      data:
        option: Stopped
      target:
        entity_id: select.myenergi_zappi_xxx_charge_mode
    name: Stop
    icon: mdi:ev-station
    show_name: true
    show_icon: true

Here I am using "select" from the services image

when browsing the services under developer tools, this EV charger (myenergi) only has two of its own services listed - I am not sure how they can be used and I dont really want to use these as the charger most frequently should be changed from eco+ to stopped, I dont use boost or smart boost (it does something I dont want): image

and image

Where I would like to get to is to have the group1 section of your code work as a dropdown selector of the select.myenergi_zappi_xxx_charge_mode entity, that calls the selected option...

Thanks again for your help here!

sabbie-github commented 1 year ago

the zappi integration I am using is https://github.com/CJNE/ha-myenergi

tmjo commented 1 year ago

Hi,

I did some adaptions, please try with v.0.2.1-alpha just released now. Then you should be able to use something like:

 group1:
    - entity_id: select.myenergi_zappi_xxx_charge_mode
      text: ChargeMode
      service: select.select_option
      service_data:
        option: '#SERVICEVAL#'
        target:
          entity_id: select.myenergi_zappi_xxx_charge_mode

then you need to add the values to currentlimitssince this will be a workaround. Currently all the dropdowns have the same values (i.e. the currentlimitsvariable), but I'll consider if I can change this in future releases so that each dropdown has its own. Guess it makes sense for general purpose usage.

  currentlimits:
    - Eco
    - Eco+
    - Fast
    - Stopped

I tested this with a helper input_selectinstead of selectsince I don't have the select in any of my integrations, but I think they basically do the same thing.

Give it a try and let me know how it goes.

sabbie-github commented 1 year ago

YES, thank you, this works just fine! I have asked the owner of the myenergi/zappi integration to see if we can find a way to unlock and adjust charger schedule via the API. If they pick that up and if there is a way to do that, I would like to come back to check with you how that function best could be integrated. For now, it does just what I wanted, thank you!

tmjo commented 1 year ago

Great! I'll see if I can use your example to add a template for Zappi to make it easier for people to use (the idea with brand/template is that it just works magically by selecting the template).

sabbie-github commented 1 year ago

yes, of course! I would love it to "just work"! thank you for your help and setting this up to begin with!

tmjo commented 1 year ago

Hi!

I'd love to add support for this charger, but kindly read the wiki on how-to. Let me know if anything is unclear and I'll update it or try to explain.

Cheers!

Ulrar commented 1 month ago

Hey,

I've got two of those, anything I can do to help support it ?

Thanks

tmjo commented 1 month ago

@Ulrar; thanks for using the card. Do you have the card working well with Zappi already? If you do, sharing your yaml-code here would help. I can assist in making a template once we have a working (and generic) yaml-code.

FlokkieB commented 2 weeks ago

Hi, tnx for this card. I am setting up my Zappi and reading this i am wondering if the Zappi template is already available? The example above looks fine !

sabbie-github commented 2 weeks ago

I am not aware of a template finalized for this. @tmjo helped me to make mine work, this is how it looks now and the yaml The card allows you to change modes and display additional diagnostic info by clicking the 3 buttons on the right image

In this setup, sensors with xxx and xx are the zappi sensors (these should be self explanatory from your setup, just update the name from yours). I am also using some battery status sensors from the car (sensors with bmw). The only odd one is sensor.myenergi_solar_is_total_minus_grid which is a config.yaml defined calculation, where I want to display how much the car was charged from solar vs from grid.

To keep it simple, you can skip defining the collapsible buttons and decide what you want to see under "info left" and "info right".

type: custom:charger-card
title: Zappi EV Charger
entity: sensor.myenergi_zappi_xxx_status
customCardTheme: theme_transp_white
customImage: /local/media/white_zappi-removebg-preview.png
brand: zappi
show_leds: false
details:
  status:
    entity_id: sensor.myenergi_zappi_xxx_status
  substatus:
    entity_id: sensor.myenergi_zappi_xxx_status
    unit_show: null
  smartcharging:
    entity_id: switch.myenergi_zappi_xxx_charge_mode
  currentlimits:
    - Fast
    - Eco
    - Eco+
    - Stopped
  statetext:
    Charging: Charging
    Paused: Paused
    Stopped: Stopped
    Completed: Complete
    Boosting: Boosting
  collapsiblebuttons:
    group1:
      text: Charger Mode
      icon: mdi:speedometer
    group2:
      text: Info
      icon: mdi:information
    group3:
      text: Settings
      icon: mdi:cog
  info_left:
    - entity_id: sensor.myenergi_zappi_xxx_plug_status
      text: Connection Status
    - entity_id: binary_sensor.myenergi_zappi_xxx_update_available
      text: Zappi SW Update
      icon: mdi:cloud-upload-outline
  info_right:
    - entity_id: sensor.bmw_530e_remaining_battery_percent
      text: Car Battery Charge %
      icon: mdi:car-electric-outline
      unit_show: true
  group1:
    - entity_id: select.myenergi_zappi_xxx_charge_mode
      text: ChargeMode
      service: select.select_option
      service_data:
        option: '#SERVICEVAL#'
        target:
          entity_id: select.myenergi_zappi_xxx_charge_mode
  group2:
    - entity_id: sensor.myenergi_xx_power_charging_2
      unit_show: true
      text: Charge NOW
      icon: mdi:car-electric
    - entity_id: sensor.myenergi_zappi_xxx_charge_added_session
      unit_show: true
      text: Charge in Last Session
    - entity_id: sensor.myenergi_solar_is_total_minus_grid
      unit_show: true
      text: Charge from Solar
      icon: mdi:solar-power-variant
    - entity_id: sensor.myenergi_zappi_xxx_energy_used_today
      unit_show: true
      text: Grid Use Today
      icon: mdi:transmission-tower-export
    - entity_id: sensor.bmw_530e_remaining_battery_percent
      unit_show: true
      icon: mdi:battery-charging-medium
      text: Car Battery Charge %
  group3:
    - entity_id: number.myenergi_zappi_xxx_device_priority
      unit_show: true
      text: Device Priority
    - entity_id: number.myenergi_zappi_xxx_minimum_green_level
      unit_show: true
      text: Minimum Green Level
    - entity_id: sensor.myenergi_xx_voltage_grid_2
      unit_show: true
      text: Grid Voltage
      icon: mdi:flash-triangle-outline
    - entity_id: sensor.myenergi_xx_frequency_grid_2
      unit_show: true
      text: Grid Frequency
  stats:
    default:
      - entity_id: sensor.myenergi_zappi_xxx_charge_added_session
        text: Charge in Last Session
        unit_show: true
      - entity_id: select.myenergi_zappi_xxx_charge_mode
        text: Charge Mode
    Charging:
      - entity_id: sensor.myenergi_zappi_xxx_charge_added_session
        text: Charge in Last Session
        unit_show: true
      - entity_id: sensor.myenergi_xx_power_charging_2
        text: Charge Power Now
        unit_show: true
      - entity_id: select.myenergi_zappi_xxx_charge_mode
        text: Charge Mode
    Paused:
      - entity_id: sensor.myenergi_zappi_xxx_charge_added_session
        text: Charge in Last Session
        unit_show: true
      - entity_id: select.myenergi_zappi_xxx_charge_mode
        text: Charge Mode
    Completed:
      - entity_id: sensor.myenergi_zappi_xxx_charge_added_session
        text: Charge in Last Session
        unit_show: true
      - entity_id: select.myenergi_zappi_xxx_charge_mode
        text: Charge Mode
    Boosting:
      - entity_id: sensor.myenergi_zappi_xxx_charge_added_session
        text: Charge in Last Session
        unit_show: true
      - entity_id: sensor.myenergi_xx_power_charging_2
        text: Charge Power Now
        unit_show: true
      - entity_id: select.myenergi_zappi_xxx_charge_mode
        text: Charge Mode
show_toolbar: false
compact_view: false
show_name: true
show_collapsibles: true
show_stats: true
chargerImage: Black

the card with all diagnostics enabled image

FlokkieB commented 2 weeks ago

Tnx a lot. Its the one that is described above, isn’t it? I was using that one already in my own design. This enhanced version helps me! I am Dutch, so i try to use Dutch in the card. Most thing are easy, just change some text, but states aren’t so obvious. Statetext is a good way to translate the Zappi status, but do you have an idea how to translate the substatus? In your card the small text ‘Paused’ below the larger text ‘Paused’?

sabbie-github commented 2 weeks ago

This is the status returned by the Zappi and I would expect it depends on the language Zappi speaks with you. Here I have just duplicated what zappi provides both as status and substatus (if you remove it, the integration template still expects a value there and will return "undefined", hence the duplication of the same thing)

details:
  status:
    entity_id: sensor.myenergi_zappi_xxx_status
  substatus:
    entity_id: sensor.myenergi_zappi_xxx_status
    unit_show: null
FlokkieB commented 1 week ago

Hi, tnx again for your answer.

Yes, i have those status and substatus defined. With statetext i am able to translate the status of the zappi sensor. Its here:

statetext: Charging: Charging Paused: Paused Stopped: Stopped Completed: Complete Boosting: Boosting

In my setup i have dutch translation there: example Charging: Opladen

However the substatus text does not translate with this statetext.

So: EV Connected: remains at EV Connected.

Any idea?