tmjo / charger-card

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

Error on card - only when car is not connected #24

Closed AMajland closed 1 year ago

AMajland commented 2 years ago

I have an easee home configured with the card filled with full template from the main instruction page.

When a car is connected by cable I have the stop, resume and override schedule icons at the bottom of the card.

But when the car is not connected i get an error instead of these 3 icons.

2022-05-24 11:07:36 ERROR (MainThread) [frontend.js.latest.202205041] http://homeassistant:8123/hacsfiles/charger-card/charger-card.js?hacstag=308752409011:7113:24 Uncaught TypeError: Cannot read properties of null (reading 'entity_id') and it shows a single (?) icon.

I'm completely new to home assistant - still finding my way around like an elephant in a porcelain store :-)

tmjo commented 2 years ago

Hi,

It seems to be looking for something that doesn't exist (hence the null). It could be something in the configuration of the card (either a bugin the template, or something that possibly added up during back and forth). Could you post the complete card config?

AMajland commented 2 years ago

I've just verified that my my config is identical to the full advanced configuration as shown on https://github.com/tmjo/charger-card (Did a diff of my config vs the online one)

I've also verified that all the entity_id are available and active.

The only thing that comes to my mind is that the CHARGERID and CHARGERNAME is the same for me. But have not tried to look below the surface .... (yet)

tmjo commented 2 years ago

Better if you post the config. Anyway, you can try to open DevTools in Chrome (or similar) with CTRL+SHIFT+I and look for some more detailed debugging info in the messages there.

Also, you could try replacing


disconnected:
      - {}

with

disconnected:
      - service: easee.stop
        service_data:
          charger_id: CHARGERID
        text: stop
        icon: hass:stop

in the toolbar_left section as a test just to see what happens.

AMajland commented 2 years ago

I'm not sure if the serial number can be abused in some way, but here is my code with it removed. I'll try you suggestion tonight - Slow charging all day with solar power (Nordpool DK1 is almost 0 most of the day so tries to use most of my solar power instead of selling it for nothing)

type: custom:charger-card
entity: sensor.##Serialnumber/name##_status
customCardTheme: theme_custom
chargerImage: Anthracite
brand: easee
show_leds: true
details:
  name:
    entity_id: sensor.##Serialnumber/name##_status
    attribute: name
  location:
    entity_id: sensor.##Serialnumber/name##_status
    attribute: site_name
  status:
    entity_id: sensor.##Serialnumber/name##_status
  substatus:
    entity_id: sensor.##Serialnumber/name##_reason_for_no_current
  smartcharging:
    entity_id: switch.##Serialnumber/name##_smart_charging
  currentlimits:
    - 0
    - 6
    - 10
    - 16
    - 20
    - 25
    - 32
  statetext:
    disconnected: disconnected
    awaiting_start: awaiting_start
    charging: charging
    completed: completed
    error: error
    ready_to_charge: ready_to_charge
  collapsiblebuttons:
    group1:
      text: click_for_group1
      icon: mdi:speedometer
    group2:
      text: click_for_group2
      icon: mdi:information
    group3:
      text: click_for_group3
      icon: mdi:cog
  info_left:
    - entity_id: binary_sensor.##Serialnumber/name##_online
      text: online
  info_right:
    - entity_id: sensor.##Serialnumber/name##_voltage
      text: voltage
      unit_show: true
    - entity_id: sensor.##Serialnumber/name##_power
      text: power
      unit_show: true
  group1:
    - entity_id: sensor.##Serialnumber/name##_dynamic_charger_limit
      text: dyn_charger_limit
      service: easee.set_charger_dynamic_limit
      service_data:
        charger_id: ##Serialnumber/name##
        current: '#SERVICEVAL#'
    - entity_id: sensor.##Serialnumber/name##_dynamic_circuit_limit
      text: dyn_circuit_limit
      service: easee.set_charger_circuit_dynamic_limit
      service_data:
        charger_id: ##Serialnumber/name##
        currentP1: '#SERVICEVAL#'
    - entity_id: sensor.##Serialnumber/name##_max_charger_limit
      text: max_charger_limit
      service: easee.set_charger_max_limit
      service_data:
        charger_id: ##Serialnumber/name##
        current: '#SERVICEVAL#'
    - entity_id: sensor.##Serialnumber/name##_max_circuit_limit
      text: max_circuit_limit
      service: easee.set_circuit_max_limit
      service_data:
        charger_id: ##Serialnumber/name##
        currentP1: '#SERVICEVAL#'
    - entity_id: sensor.##Serialnumber/name##_offline_circuit_limit
      text: offline_circuit_limit
      service: easee.set_charger_circuit_offline_limit
      service_data:
        charger_id: ##Serialnumber/name##
        currentP1: '#SERVICEVAL#'
  group2:
    - entity_id: binary_sensor.##Serialnumber/name##_online
      text: online
    - entity_id: sensor.##Serialnumber/name##_voltage
      text: voltage
      unit_show: true
    - entity_id: sensor.##Serialnumber/name##_power
      text: power
      unit_show: true
    - entity_id: sensor.##Serialnumber/name##_current
      text: charger_current
      unit_show: true
    - entity_id: sensor.##Serialnumber/name##_circuit_current
      text: circuit_current
      unit_show: true
    - entity_id: sensor.##Serialnumber/name##_energy_per_hour
      text: energy_per_hour
      unit_show: true
    - entity_id: sensor.##Serialnumber/name##_session_energy
      text: session_energy
      unit_show: true
    - entity_id: sensor.##Serialnumber/name##_lifetime_energy
      text: lifetime_energy
      unit_show: true
  group3:
    - entity_id: switch.##Serialnumber/name##_is_enabled
      text: enabled
    - entity_id: switch.##Serialnumber/name##_enable_idle_current
      text: idle_current
    - entity_id: binary_sensor.##Serialnumber/name##_cable_locked
      text: cable_locked
    - entity_id: switch.##Serialnumber/name##_cable_locked_permanently
      text: perm_cable_locked
    - entity_id: switch.##Serialnumber/name##_smart_charging
      text: smart_charging
    - entity_id: sensor.##Serialnumber/name##_cost_per_kwh
      text: cost_per_kwh
    - entity_id: binary_sensor.##Serialnumber/name##_update_available
      text: update_available
    - entity_id: binary_sensor.##Serialnumber/name##_basic_schedule
      text: schedule
  stats:
    default:
      - entity_id: sensor.##Serialnumber/name##_session_energy
        text: session_energy
        unit_show: true
      - entity_id: switch.##Serialnumber/name##_cable_locked_permanently
        text: cable_locked
      - entity_id: binary_sensor.##Serialnumber/name##_basic_schedule
        text: schedule
    disconnected:
      - entity_id: sensor.##Serialnumber/name##_session_energy
        text: session_energy
        unit_show: true
      - entity_id: switch.##Serialnumber/name##_cable_locked_permanently
        text: cable_locked
      - entity_id: calculated
        text: used_limit
        unit: A
        unit_show: true
        calc_function: min
        calc_entities:
          - entity_id: sensor.##Serialnumber/name##_dynamic_charger_limit
          - entity_id: sensor.##Serialnumber/name##_dynamic_circuit_limit
          - entity_id: sensor.##Serialnumber/name##_max_charger_limit
          - entity_id: sensor.##Serialnumber/name##_max_circuit_limit
          - entity_id: sensor.##Serialnumber/name##_offline_circuit_limit
    awaiting_start:
      - entity_id: sensor.##Serialnumber/name##_session_energy
        text: session_energy
        unit_show: true
      - entity_id: binary_sensor.##Serialnumber/name##_basic_schedule
        text: schedule
      - entity_id: switch.##Serialnumber/name##_smart_charging
        text: smart_charging
      - entity_id: calculated
        text: used_limit
        unit: A
        unit_show: true
        calc_function: min
        calc_entities:
          - entity_id: sensor.##Serialnumber/name##_dynamic_charger_limit
          - entity_id: sensor.##Serialnumber/name##_dynamic_circuit_limit
          - entity_id: sensor.##Serialnumber/name##_max_charger_limit
          - entity_id: sensor.##Serialnumber/name##_max_circuit_limit
          - entity_id: sensor.##Serialnumber/name##_offline_circuit_limit
    charging:
      - entity_id: sensor.##Serialnumber/name##_session_energy
        text: session_energy
        unit_show: true
      - entity_id: sensor.##Serialnumber/name##_energy_per_hour
        text: energy_per_hour
        unit_show: true
      - entity_id: sensor.##Serialnumber/name##_circuit_current
        text: circuit_current
        unit_show: true
      - entity_id: sensor.##Serialnumber/name##_output_limit
        text: output_limit
        unit_show: true
      - entity_id: sensor.##Serialnumber/name##_current
        text: current
        unit_show: true
      - entity_id: sensor.##Serialnumber/name##_power
        text: power
        unit_show: true
    completed:
      - entity_id: sensor.##Serialnumber/name##_session_energy
        text: session_energy
        unit_show: true
      - entity_id: binary_sensor.##Serialnumber/name##_basic_schedule
        text: schedule
      - entity_id: calculated
        text: used_limit
        unit: A
        unit_show: true
        calc_function: min
        calc_entities:
          - entity_id: sensor.##Serialnumber/name##_dynamic_charger_limit
          - entity_id: sensor.##Serialnumber/name##_dynamic_circuit_limit
          - entity_id: sensor.##Serialnumber/name##_max_charger_limit
          - entity_id: sensor.##Serialnumber/name##_max_circuit_limit
          - entity_id: sensor.##Serialnumber/name##_offline_circuit_limit
    error:
      - entity_id: sensor.##Serialnumber/name##_session_energy
        text: session_energy
        unit_show: true
      - entity_id: binary_sensor.##Serialnumber/name##_basic_schedule
        text: schedule
    ready_to_charge:
      - entity_id: sensor.##Serialnumber/name##_session_energy
        text: session_energy
        unit_show: true
      - entity_id: binary_sensor.##Serialnumber/name##_basic_schedule
        text: schedule
      - entity_id: calculated
        text: used_limit
        unit: A
        unit_show: true
        calc_function: min
        calc_entities:
          - entity_id: sensor.##Serialnumber/name##_dynamic_charger_limit
          - entity_id: sensor.##Serialnumber/name##_dynamic_circuit_limit
          - entity_id: sensor.##Serialnumber/name##_max_charger_limit
          - entity_id: sensor.##Serialnumber/name##_max_circuit_limit
          - entity_id: sensor.##Serialnumber/name##_offline_circuit_limit
  toolbar_left:
    default:
      - {}
    disconnected:
      - {}
    awaiting_start:
      - service: easee.stop
        service_data:
          charger_id: ##Serialnumber/name##
        text: stop
        icon: hass:stop
      - service: easee.resume
        service_data:
          charger_id: ##Serialnumber/name##
        text: resume
        icon: hass:play
      - service: easee.override_schedule
        service_data:
          charger_id: ##Serialnumber/name##
        text: override
        icon: hass:motion-play
    charging:
      - service: easee.stop
        service_data:
          charger_id: ##Serialnumber/name##
        text: stop
        icon: hass:stop
      - service: easee.pause
        service_data:
          charger_id: ##Serialnumber/name##
        text: pause
        icon: hass:pause
    completed:
      - service: easee.stop
        service_data:
          charger_id: ##Serialnumber/name##
        text: stop
        icon: hass:stop
      - service: easee.override_schedule
        service_data:
          charger_id: ##Serialnumber/name##
        text: override
        icon: hass:motion-play
    error:
      - service: easee.reboot
        service_data:
          charger_id: ##Serialnumber/name##
        text: reboot
        icon: hass:restart
    ready_to_charge:
      - service: easee.stop
        service_data:
          charger_id: ##Serialnumber/name##
        text: stop
        icon: hass:stop
      - service: easee.override_schedule
        service_data:
          charger_id: ##Serialnumber/name##
        text: override
        icon: hass:motion-play
  toolbar_right:
    default:
      - service: persistent_notification.create
        service_data:
          message: Firmware update is available, but only possible when disconnected!
          title: Update
        text: update
        icon: mdi:file-download
        conditional_entity: binary_sensor.##Serialnumber/name##_update_available
    disconnected:
      - service: easee.update_firmware
        service_data:
          charger_id: ##Serialnumber/name##
        text: update
        icon: mdi:file-download
        conditional_entity: binary_sensor.##Serialnumber/name##_update_available
AMajland commented 2 years ago

Clicking on it gives "charger-card.js?hacstag=308752409011:7147 Trying to call an empty service - please check your card configuration."

And as you noticed

 disconnected:
      - {}

is in fact empty.

And replacing it with the stop bottom got rid of the error (the stop bottom does nothing meaingfull when not connected but at least the card look nicer :-) )

tmjo commented 2 years ago

Hmmm, thats's kindof good. I see that if I simulate 'disconnected' as status I also get a icon '?' showing null. Do you get the error only when clicking the button, or all the time?

Seems like deleting the section

    default:
      - {}
    disconnected:
      - {}

solves it, then you get an empty toolbar. Or you could add something that makes sense while disconnected (although I couldn't really find anything).

tmjo commented 2 years ago

@AMajland; sorry for the delay, but if you don't mind, please check latest version just released to see if this bug is solved.

AMajland commented 2 years ago

Thankyou for the update. The stop button is now shown when the car is disconnected. Pressing the stop button gives the error shown here. image - But since it is disconnected there is nothing to stop :-)

But got this error in the settings after pressing the stop button: image

tmjo commented 2 years ago

Well, yes, two things: Stop doesn't work when car is disconnected, and the second error message is a deprecation of some services that has been changed in the Easee integration (will be added to card soon). But the original problem was that

    default:
      - {}
    disconnected:
      - {}

gave errors, right? And the workaround was to add a button (hence the stop-button).

tmjo commented 1 year ago

Closing this as I believe it has been solved. Please re-open if this is not the case.