Newbie question - how do I install a community add-on, Nissan Leaf

I’ve just started getting going with Home Assistant and so far loving what I’m seeing. I’ve spent a couple of weeks reading documentation, community posts, etc to get a theoretical understanding before going out and buying a Pi 4 and trying it for real, so it has gone pretty well so far.

I’ve got a few integrations working successfully including Zwave thermostat, IKEA lights and outlets. But I’m stuck trying to add an integration for my Nissan Leaf. I’ve found the details of the add-on in Github and I’ve read up how to install third party repositories via the UI. But I think I’m missing something. I think perhaps I need to download the add-on code directly to my device, but cannot find any documentation about how to do that. Please can you give me some pointers?

Thanks,

Phil

It appears the nissan leaf add on is not available via the User interface (UI). ie you can’t add it via the Configuration/Integration menu. Instead you add it via the configuration file. See here for instructions / examples on the configuration file

Thanks. Do I also need to install the code for the add-on onto my local device, or does that happen automatically behind the scenes?

No, you add the configuration to configuration.yaml.

That sounds pretty straight-forward. Thanks for clarifying. :grinning:

Hi

I put that on the config file

nissan_leaf:

username: XXX

password: XXXX

region: NE

update_interval:

hours: 1

update_interval_charging:

minutes: 15

update_interval_climate:

minutes: 5

force_miles: true

now I need help to make a card information about the charge level , do you know how to do that ?

It needs to be in yaml.

I put it on the YAML but it is missing sensors to make a card on dashboard there I need help

Post your config properly then, you haven’t posted anything resembling yaml.

nissan_leaf:

username: XXX

password: XXXX

region: NE

update_interval:

hours: 1

update_interval_charging:

minutes: 15

update_interval_climate:

minutes: 5

force_miles: true

that is from my YAML

Hi,

To get the Leaf charge information onto a dashboard there are two steps. Firstly, you need a bit more yaml code in your configuration which creates variables that you can use throughout Home Assistant, and then you need to add those to a panel.

So, here are all the entries for my Leaf in the configuration.yaml file. Note: you will need to replace leaf1phil with the name that you chose for your car.


# Add Nissan Leaf integration
nissan_leaf:
  username: "xxxxxxx"
  password: "xxxxxxx"
  region: "NE"
  update_interval:
    minutes: 10
  update_interval_charging:
    minutes: 10
  update_interval_climate:
    minutes: 5
  force_miles: true

sensor: 
  - platform: template
    sensors:
      leaf_charge_state:
        value_template: "Charging: {{ states('binary_sensor.leaf1phil_charging_status') }}"
      leaf_charge_message:
        value_template: "{{ states('sensor.leaf1phil_charge') }}% - {{ states('sensor.leaf1phil_range') }} miles ({{ states('sensor.leaf1phil_range_ac') }} with AC)"
        icon_template: "{%- if states.sensor.leaf1phil_charge.state >= '95' %}mdi:battery{%- elif states.sensor.leaf1phil_charge.state == '100' %}mdi:battery{%- elif states.sensor.leaf1phil_charge.state <= '15' %}mdi:battery-outline{% else %}mdi:battery-{{(states.sensor.leaf1phil_charge.state|float / 10)|round*10}}{%- endif %}"
      leaf_range_ac:
        value_template: "{{ states('sensor.leaf1phil_range_ac') }} miles with AC"
      leaf_range: 
        value_template: "{{ states('sensor.leaf1phil_range') }} miles"
      leaf_battery:
        unit_of_measurement: '%'
        value_template: "{{ states('sensor.leaf1phil_charge') }}"
        icon_template: "{%- if states.sensor.leaf1phil_charge.state >= '95' %}mdi:battery{%- elif states.sensor.leaf1phil_charge.state == '100' %}mdi:battery{%- elif states.sensor.leaf1phil_charge.state <= '15' %}mdi:battery-outline{% else %}mdi:battery-{{(states.sensor.leaf1phil_charge.state|float / 10)|round*10}}{%- endif %}"

This is what the car pane on my dashboard looks like. The extra information about ‘updating’, ‘last’ and ‘next’ is to help me see if the Nissan servers have got stuck mid update, in which case a restart of HA is needed. The carport light is just a light. The ‘Fossil Fuel %’ comes from the CO2 signal integration. If you’re interested the plugin information is here: Electricity Maps - Home Assistant

Screenshot 2022-07-08 09.09.25a

And here’s the YAML code from the dashboard. Note: you will need to replace leaf1phil with the name that you chose for your car, in the configuration, above. Also, there is a place which I have marked where you need to enter the VIN of your car (the code you can see on the small metal plate just inside the windscreen).

views:
  - title: Home
    cards:
      - type: vertical-stack
        cards:
          - type: grid
            columns: 4
            cards:
              - type: gauge
                min: 0
                max: 100
                name: Car Batt
                entity: sensor.leaf1phil_charge
              - type: gauge
                entity: sensor.grid_fossil_fuel_percentage
                unit: '%'
                max: 100
                min: 0
                name: Fos. Fuel
                severity:
                  green: 0
                  yellow: 10
                  red: 50
              - type: custom:gap-card
              - type: custom:gap-card
              - type: button
                entity: button.start_leaf1phil_charging
                name: Charge now
                icon: mdi:power
                hold_action:
                  action: none
                tap_action:
                  action: call-service
                  service: nissan_leaf.start_charge
                  service_data:
                    vin: >-
                      *************************************** put your VIN here
                      and remove the apostrophes ********************
                  target: {}
              - type: button
                show_icon: true
                entity: switch.leaf1phil_climate_control
                icon: mdi:fan
                name: Preheat car
                hold_action:
                  action: none
              - type: custom:gap-card
              - type: markdown
                content: >-
                  Leaf updating:
                  {{states.sensor.leaf1phil_range.attributes.update_in_progress}}
            square: true
          - type: grid
            columns: 2
            cards:
              - type: glance
                entities:
                  - entity: binary_sensor.leaf1phil_plug_status
                  - entity: binary_sensor.leaf1phil_charging_status
                show_name: false
                show_state: true
              - type: entities
                entities:
                  - type: attribute
                    entity: sensor.leaf1phil_charge
                    name: Last
                    icon: mdi:car
                    attribute: updated_on
                    format: relative
                  - type: attribute
                    entity: sensor.leaf1phil_charge
                    name: Next
                    icon: mdi:car
                    attribute: next_update
                    format: relative
            square: false

Hope this works for you. And of-course huge credit to all the people in this community who helped me reach this solution since my original post!

many thanks for your help.
I added everything as you described but I am getting uknown status

Logger: homeassistant.helpers.template_entity
Source: helpers/template_entity.py:312
First occurred: 9:18:23 AM (2 occurrences)
Last logged: 9:18:23 AM

Template loop detected while processing event: <Event state_changed[L]: entity_id=sensor.leaf_range_ac, old_state=<state sensor.leaf_range_ac=unknown miles with AC; friendly_name=leaf_range_ac @ 2022-07-10T09:18:21.669370+02:00>, new_state=<state sensor.leaf_range_ac=unknown miles with AC miles with AC; friendly_name=leaf_range_ac @ 2022-07-10T09:18:23.171946+02:00>>, skipping template render for Template[{{ states(‘sensor.LEAF_range_ac’) }} miles with AC]
Template loop detected while processing event: <Event state_changed[L]: entity_id=sensor.leaf_range, old_state=<state sensor.leaf_range=unknown miles; friendly_name=leaf_range @ 2022-07-10T09:18:21.674337+02:00>, new_state=<state sensor.leaf_range=unknown miles miles; friendly_name=leaf_range @ 2022-07-10T09:18:23.177112+02:00>>, skipping template render for Template[{{ states(‘sensor.LEAF_range’) }} miles]

did I missed something ?

Hello,

I have same problem. no entity existing.

No logs, no yaml = no issue. Please people read the posting guidelines.

Hi
here is the yaml:

nissan_leaf:

username: XXX

password: XXXX

region: NE

update_interval:

minutes: 10

update_interval_charging:

minutes: 15

update_interval_climate:

minutes: 5

force_miles: true

sensor:

  • platform: template

    sensors:

    leaf_charge_state:

    value_template: "Charging: {{ states('binary_sensor.LEAF_charging_status') }}"
    

    leaf_charge_message:

    value_template: "{{ states('sensor.LEAF_charge') }}% - {{ states('sensor.LEAF_range') }} miles ({{ states('sensor.LEAF_range_ac') }} with AC)"
    
    icon_template: "{%- if states.sensor.LEAF_charge.state >= '95' %}mdi:battery{%- elif states.sensor.LEAF_charge.state == '100' %}mdi:battery{%- elif states.sensor.LEAF_charge.state <= '15' %}mdi:battery-outline{% else %}mdi:battery-{{(states.sensor.LEAF_charge.state|float / 10)|round*10}}{%- endif %}"
    

    leaf_range_ac:

    value_template: "{{ states('sensor.LEAF_range_ac') }} miles with AC"
    

    leaf_range:

    value_template: "{{ states('sensor.LEAF_range') }} miles"
    

    leaf_battery:

    unit_of_measurement: '%'
    
    value_template: "{{ states('sensor.LEAF_charge') }}"
    
    icon_template: "{%- if states.sensor.LEAF_charge.state >= '95' %}mdi:battery{%- elif states.sensor.LEAF_charge.state == '100' %}mdi:battery{%- elif states.sensor.LEAF_charge.state <= '15' %}mdi:battery-outline{% else %}mdi:battery-{{(states.sensor.LEAF_charge.state|float / 10)|round*10}}{%- endif %}"
    

the card:

  • theme: Backend-selected
    title: leaf
    path: leaf
    icon: mdi:car
    badges: []
    cards:
    • type: vertical-stack
      cards:
      • type: grid
        columns: 4
        cards:
        • type: gauge
          min: 0
          max: 100
          name: cAR bATT
          entity: sensor.LEAF_charge
        • type: gauge
          entity: sensor.grid_fossil_fuel_percentage
          unit: ‘%’
          max: 100
          min: 0
          name: Fos. Fuel
          severity:
          green: 0
          yellow: 10
          red: 50
        • type: custom:gap-card
        • type: custom:gap-card
        • type: button
          entity: button.start_LEAF_charging
          name: Charge now
          icon: mdi:power
          hold_action:
          action: none
          tap_action:
          action: call-service
          service: nissan_leaf.start_charge
          service_data:
          vin: SJNFAAZE0U6023145
          target: {}
        • type: button
          show_icon: true
          entity: switch.LEAF_climate_control
          icon: mdi:fan
          name: Preheat car
          hold_action:
          action: none
        • type: custom:gap-card
        • type: markdown
          content: >-
          Leaf updating:
          {{states.sensor.LEAF_range.attributes.update_in_progress}}
          square: true
      • type: grid
        columns: 2
        cards:
        • type: glance
          entities:
          • entity: binary_sensor.LEAF_plug_status
          • entity: binary_sensor.LEAF_charging_status
            show_name: false
            show_state: true
        • type: entities
          entities:
          • type: attribute
            entity: sensor.LEAF_charge
            name: Last
            icon: mdi:car
            attribute: updated_on
            format: relative
          • type: attribute
            entity: sensor.LEAF_charge
            name: Next
            icon: mdi:car
            attribute: next_update
            format: relative
            square: false
    • type: entities
      entities:
      • sensor.leaf_battery

log:
Logger: homeassistant.helpers.template_entity
Source: helpers/template_entity.py:312
First occurred: 5:28:13 PM (2 occurrences)
Last logged: 5:28:13 PM

  • Template loop detected while processing event: <Event state_changed[L]: entity_id=sensor.leaf_range_ac, old_state=<state sensor.leaf_range_ac=unknown miles with AC; friendly_name=leaf_range_ac @ 2022-07-12T17:28:12.303621+02:00>, new_state=<state sensor.leaf_range_ac=unknown miles with AC miles with AC; friendly_name=leaf_range_ac @ 2022-07-12T17:28:13.704359+02:00>>, skipping template render for Template[{{ states(‘sensor.LEAF_range_ac’) }} miles with AC]
  • Template loop detected while processing event: <Event state_changed[L]: entity_id=sensor.leaf_range, old_state=<state sensor.leaf_range=unknown miles; friendly_name=leaf_range @ 2022-07-12T17:28:12.308333+02:00>, new_state=<state sensor.leaf_range=unknown miles miles; friendly_name=leaf_range @ 2022-07-12T17:28:13.709817+02:00>>, skipping template render for Template[{{ states(‘sensor.LEAF_range’) }} miles]

That is not how to post yaml.

Where can I find the guideline ?
Can you please speak clearly , i am new here

Sorry, I thought everyone was referred to it when they joined the forum. How to help us help you - or How to ask a good question

nissan_leaf:
  username: XXX
  password: XXX
  region: NE
  update_interval:
    minutes: 10
  update_interval_charging:
    minutes: 15
  update_interval_climate:
    minutes: 5
  force_miles: true
  
sensor:
  - platform: template
    sensors:
      leaf_charge_state:
        value_template: "Charging: {{ states('binary_sensor.LEAF_charging_status') }}"
      leaf_charge_message:
        value_template: "{{ states('sensor.LEAF_charge') }}% - {{ states('sensor.LEAF_range') }} miles ({{ states('sensor.LEAF_range_ac') }} with AC)"
        icon_template: "{%- if states.sensor.LEAF_charge.state >= '95' %}mdi:battery{%- elif states.sensor.LEAF_charge.state == '100' %}mdi:battery{%- elif states.sensor.LEAF_charge.state <= '15' %}mdi:battery-outline{% else %}mdi:battery-{{(states.sensor.LEAF_charge.state|float / 10)|round*10}}{%- endif %}"
      leaf_range_ac:
        value_template: "{{ states('sensor.LEAF_range_ac') }} miles with AC"
      leaf_range: 
        value_template: "{{ states('sensor.LEAF_range') }} miles"
      leaf_battery:
        unit_of_measurement: '%'
        value_template: "{{ states('sensor.LEAF_charge') }}"
        icon_template: "{%- if states.sensor.LEAF_charge.state >= '95' %}mdi:battery{%- elif states.sensor.LEAF_charge.state == '100' %}mdi:battery{%- elif states.sensor.LEAF_charge.state <= '15' %}mdi:battery-outline{% else %}mdi:battery-{{(states.sensor.LEAF_charge.state|float / 10)|round*10}}{%- endif %}"