would you consider sharing the whole config ? mine is awful
Sure, what exactly are you interested in?
I started with the picture-elements card that michel72 posted in this topic.
Then I tweaked the cars range a little bit, to give it a more realistic range.
leaf_range_ac_realistic:
friendly_name: "Leaf Range AC real world"
icon_template: "mdi:speedometer"
unit_of_measurement: 'km'
value_template: "{{ (((states('sensor.leaf1stee_range_ac') | float) | multiply(0.8)) | round(0)) }}"
And I combined the current charge level with the last updated time within one sensor:
leaf_charge_and_last_updated:
friendly_name: "Laadniveau + tijd update"
value_template: "{{ states('sensor.leaf1stee_charge') }}% om {{ as_timestamp(state_attr('sensor.leaf1stee_charge', 'updated_on')) | timestamp_custom('%H:%M') }}"
I changed the picture to this one, because thats how my car looks like:
I put the cars data on the left side of the card and the charger data on the right side.
This is the whole picture-elements card:
elements:
- entity: binary_sensor.leaf1stee_charging_status
icon: 'mdi:ev-station'
style:
background-color: 'rgba(0, 0, 0, 0.3)'
bottom: 0
font-size: 16px
left: 0
line-height: 50px
padding: 0 8px
transform: initial
width: 100%
tap_action:
action: call-service
confirmation: true
service: script.leaf_charge
type: state-icon
- entity: sensor.leaf1stee_charge
icon: 'mdi:reload'
style:
bottom: 0
color: white
left: 38%
line-height: 32px
margin: 0px 0px -5px 0px
padding: 8px
transform: initial
tap_action:
action: call-service
confirmation: true
service: script.leaf_update
type: state-icon
- entity: switch.leaf1stee_climate_control
icon: 'mdi:fan'
style:
bottom: 0
color: white
line-height: 32px
margin: 5px 0px -5px 0px
padding: 8px
right: 0
transform: initial
tap_action:
action: toggle
confirmation: true
type: state-icon
- entity: binary_sensor.leaf1stee_plug_status
style:
'--paper-item-icon-color': null
left: 0
margin: 10px 10px
top: 0
type: state-icon
- entity: sensor.zappi_charge_mode
style:
font-size: 12px
color: null
line-height: 32px
margin: 17px 0px
pointer-events: none
right: 0
text-shadow: 'rgb(0, 0, 0, 0.2) 0px 0px 2px'
top: 0
transform: initial
type: state-label
- entity: sensor.zappi_evse
style:
font-size: 12px
color: null
line-height: 32px
margin: 1px 0px
pointer-events: none
right: 0
text-shadow: 'rgb(0, 0, 0, 0.2) 0px 0px 2px'
top: 0
transform: initial
type: state-label
- entity: sensor.leaf_charge_and_last_updated
style:
color: null
font-size: 12px
line-height: 32px
margin: 7px 15px
pointer-events: none
left: 0
text-shadow: 'rgb(0, 0, 0, 0.2) 0px 0px 2px'
top: 0
transform: initial
type: state-label
- entity: input_datetime.departure_datetime
style:
color: null
font-size: 12px
line-height: 32px
margin: '-15px 0px'
pointer-events: none
right: 0
text-shadow: 'rgb(0, 0, 0, 0.2) 0px 0px 2px'
top: 0
transform: initial
type: state-label
- entity: sensor.leaf_range_ac_realistic
style:
color: null
font-size: 12px
line-height: 32px
margin: '-10px 15px'
pointer-events: none
left: 0
text-shadow: 'rgb(0, 0, 0, 0.2) 0px 0px 2px'
top: 0
transform: initial
type: state-label
image: /local/images/car/nissan-leaf-gun-metallic-650x425-edit.png
type: picture-elements
The buttons outside the picture-elements card are all input_booleans for the Node Red automation, which turns my Zappi charger on and off, when I think is best for the battery pack and my wallet.
nice job thank you ! I’l try that, seems much better than mine!
I already have a nice node red integration but my picture-elements card is pretty bad!
thanks again
I tried to modify it but I am not good enough with this content. I am using a Pi with Home assistant on it. Do you think a future HA update will fix this bug?
I have not been able to locate the file for myself as well. This is the error message I got, but there is no pycarwings2 folder anywhere
ogger: homeassistant.components.nissan_leaf
Source: components/nissan_leaf/init.py:157
Integration: Nissan Leaf (documentation, issues)
First occurred: June 5, 2021, 7:19:39 AM (1 occurrences)
Last logged: June 5, 2021, 7:19:39 AM
An unknown error occurred while connecting to Nissan: <class ‘pycarwings2.pycarwings2.CarwingsError’>
Firstly you need to install ‘SSH & Web Terminal’, go to Supervisor, Add-on Store. In the section named ‘Home Assistant Community Add-ons’ you will find the ‘SSH & Web Terminal’. Install that add-on and make sure that in the info section ‘Protection mode’ is OFF, also turn on ‘Show in sidebar’
The above may require restarts, I’m not sure.
Next in the sidebar you should have ‘Terminal’
Open this up and this is where we need to access the docker.
- type
docker exec -it $(docker ps -f name=homeassistant -q) bash
- type
cd /usr/local/lib/python3.9/site-packages/pycarwings2/
- type
vi pycarwings2.py
- go down to line 125
- change to
headers={"User-Agent": ""}
- to exit and save vi use :x then enter.
This is basically @andbad instructions rehashed and in one place.
Good Luck and always back up first.
Edit: I fixed an important typo !!
Second Edit: Changed to python3.9
I got the reply for the cd command: no such file or directory: /usr/local/lib/python3.8/site-packages/pycarwings2/
Basically this was my original problem, that i was unable to find pycarwings anywhere in my system.
Odd, have you tried to cd your way in one level at a time?
cd /usr
cd local
cd lib
cd python3.9
cd site-packages
cd pycarwings2
If you get stuck on the way, type ls
and that will list the contents of the directory you’re in presently, this may show where you are going wrong.
HTH
Edited to change python3.8 to 3.9 due to Core update.
I followed it step by step, and found this:
At /usr/local/lib there is no python3.8 folder
I found the python folder elsewhere with the site-packages also, but there is no pycarwings2 in the site-packages.
/usr/lib/python3.8/site-packages
Sorry, but you MUST type in the first line … (please check out the P.S)
docker exec -it $(docker ps -f name=homeassistant -q) bash
After that, the prompt should say bash-5.0#
Good Luck
PS. Also just noticed that the ‘docker’ line that I gave you earlier had a typo, now fixed. Sorry.
Yaaay! Success! Thank you very much!
Trying the docker exec -it $(docker ps -f name=homeassistant -q) bash . But it keeps saying “bash: docker: command not found”. What do I do wrong?
Are you using the correct Terminal?
Did you follow the first part of my post here?
You should be installing this … SSH & Web Terminal
Other than that, I have no idea
Thank you so much. I used the standard SSH & Terminal, that is why it didn’t work. Now my Leaf integration is working again. Once again, thanks
Yess it worked for me. Thanks a lot for the SSH course
Strange. I did the fix and now after 2 days the Nissan Leaf integration stoped again. And after a reboot it worked again.
Sometimes happens. It’s due to Nissan server problem.
By(t)e
Thought I would add to this, after forking the brilliant work done by @Sriracha.
Here’s my forked leaf2mqtt: https://github.com/mitsumaui/leaf2mqtt
I have modified this to fix up some bugs, and add location tracking. Also provided some clarification on the documentation to configure device_tracker
/ climate
in Home-Assistant.
Feel free to feedback, although I am no expert in dart/flutter development I will do my best. I am currently trying to extend this to collect cockpit information (mileage).
Another bonus is that a docker container image is being automatically published and can be installed without building:
docker pull ghcr.io/k8s-at-home/leaf2mqtt:latest
There’s also a helm chart for those running kubernetes:
helm repo add k8s-at-home https://k8s-at-home.com/charts/
helm repo update
helm install leaf2mqtt k8s-at-home/leaf2mqtt
I had a similar problem: no python3.8 directory. However there was a directory python3.9 which contained the expected subdirectories and the file to edit.
In case other people are also suffering from no car status update, error 408.
I see there had been a recent merge.
So I decided to test it out by replacing the file in question, with the updated one from github. The file is located here in HA OS homeassistant container:
/usr/src/homeassistant/homeassistant/components/nissan_leaf/__init__.py
I haven’t driven the car yet, but forced updates no longer give me any error messages.
Just need the upstream pycarwings2 package to merge the start-up 404 error fix now…
edit: still giving me error 408.
Edit 2: It IS working, gives me 408 error from time to time, but car battery does get updated eventually.