[Module]Nissan Leaf 2

Python and python framework

Moderator: leecollings

Post Reply
User avatar
breizhcat
Posts: 16
Joined: Tuesday 07 July 2020 17:51
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: France
Contact:

[Module]Nissan Leaf 2

Post by breizhcat »

Hello,

After some search on web, I have found an API and a Python package to allow me to get informations from my car (Nissan Leaf 2). You only need to have a account on Nissan+You

Therefore, I tried to make my own plugin. My repo for my module https://github.com/BreizhCat/DomoticzNissanLeaf.

It's my first module so I'm sure that my code need to be enhanced. But today, it works as expected for my needs.

Sorry, the readme is only in french today but once you will have installed the plugin 6 devices will appear:
  • Battery Level (%)
  • Range without AC (km)
  • Range with AC (km)
  • Distance drove ( :!: divider has to be managed manually)
  • Car state (plugged or not)
  • Swtich to refresh data manually
Image

If you find bug or if you have any idea please share in this topic. I will have a look.:mrgreen:

In the meantime enjoy ;)

PS: Sorry for my english hope it's not too bad!
wimw1953
Posts: 5
Joined: Tuesday 14 June 2022 11:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: [Module]Nissan Leaf 2

Post by wimw1953 »

Hello

Thnaks for your work. But I have small problem maybe I am doing something wrong. The plugin is not working it gives the following message in the log.

2022-06-14 11:00:13.262 Error: CPlugin:PyDomoticz_Log, illegal operation, Plugin has not started yet.
2022-06-14 11:00:13.285 Error: (leaf) Failed to initialize Options dictionary for Hardware/Unit combination (51:6): Only "string" type dictionary entries supported, but entry has type "int"

Thanks a lot in advance. I have a brandnew leaf 2022 e+. In the Netherlands. In other apps I have to give World as region. But this choice cannot be made in the menu of the app.

Wim Westendorp
josemi
Posts: 31
Joined: Thursday 08 March 2018 16:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: [Module]Nissan Leaf 2

Post by josemi »

I have just configured your plugin, and it is working fine for me. Leaf Y2019.
Thank you for your great work and for sharing.
wimw1953
Posts: 5
Joined: Tuesday 14 June 2022 11:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: [Module]Nissan Leaf 2

Post by wimw1953 »

josemi wrote: Wednesday 22 June 2022 7:35 I have just configured your plugin, and it is working fine for me. Leaf Y2019.
Thank you for your great work and for sharing.
That gives some hope. Can you tell what steps you have done to get it working. (for me there is an error code) (I sent the previous post)
josemi
Posts: 31
Joined: Thursday 08 March 2018 16:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: [Module]Nissan Leaf 2

Post by josemi »

wimw1953 wrote: Wednesday 22 June 2022 13:23
josemi wrote: Wednesday 22 June 2022 7:35 I have just configured your plugin, and it is working fine for me. Leaf Y2019.
Thank you for your great work and for sharing.
That gives some hope. Can you tell what steps you have done to get it working. (for me there is an error code) (I sent the previous post)
I did git pull only, as regular user.
It could be that your Leaf has changed the api, I know that in may 2019 Nissan Leaf changed the app from NissanConnect EV to NissanConnect Services.
But I do not know.

Regards
User avatar
breizhcat
Posts: 16
Joined: Tuesday 07 July 2020 17:51
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: France
Contact:

Re: [Module]Nissan Leaf 2

Post by breizhcat »

Hello

Are you in Europe? Because it seems that the API has changed for US and my plugin is not working anymore for US/CA.

Thanks

[EDIT] I have read again your message and I found my answer alone :) Sorry. Can you enable log and copy/paste the result?
wimw1953
Posts: 5
Joined: Tuesday 14 June 2022 11:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: [Module]Nissan Leaf 2

Post by wimw1953 »

Good morning

Futher research brings me to the follwing.

The plugin is partially working. I added the plug in and it seems to function properly. I can choose the type Nissan Leaf and add my login user/pw. The only thing is that the values are not stored. Opening after saving shows an empty type field and empty values for user/pw.

screen shows zero values of the nissan leaf items.

The log file shows the error code as in my first reply.

Thanks Wim

I did fresh install of domoticz on a other pi

see my next post
Last edited by wimw1953 on Wednesday 29 June 2022 11:03, edited 3 times in total.
josemi
Posts: 31
Joined: Thursday 08 March 2018 16:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: [Module]Nissan Leaf 2

Post by josemi »

Should 'Refresh Data' work?
It is not refreshing for me, but Distances, Percentage and Plug are refreshed every 1 hour.

Icons for Driven and Battery (Percentage) are not shown in floorplan, but it does in Devices.
Would yo know why?
Image

How could I get history json file for uploading to LeafPy?

Thank you
wimw1953
Posts: 5
Joined: Tuesday 14 June 2022 11:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: [Module]Nissan Leaf 2

Post by wimw1953 »

Hello

In advance on my first post I did some research what could be wrong.

1) I found you have prepare domoticz for python plugins. (https://www.domoticz.com/wiki/Using_Python_plugins)

2) Finding the right version of python for all subsystems is hard. For my expirimental system I use python 3.9

3) There is an issue with crypto.cipher (see previous post) (https://exerror.com/importerror-no-modu ... to-cipher/)

4) install python leafpy

The result now is that after registration of the hardware domoticz gets somewhere in a loop. When you try to open the devices it says loading...
(that message looks like frozen)

Who can help me in taking the next step to get the app running.

The crashlog gives the following
gdb: warning: Couldn't determine a path for the index cache directory.
ptrace: Proces bestaat niet.
/home/pi/domoticz/583: Bestand of map bestaat niet.
No threads.

Main thread:
No stack.
The program is not being run.
josemi
Posts: 31
Joined: Thursday 08 March 2018 16:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: [Module]Nissan Leaf 2

Post by josemi »

Hi
I have modified the onHeartbeat, because it was running every hour, but it was executed every 10 seconds the minute number 0 of every hour.
I process the plugin not only in minute 0, but also 15, 30, 45.

if (_time.minute in [0,15,30,45] and _time.second < 10):


Image


Besides, I have translated some sentences if you want to update the repo:

https://github.com/josemi73/DomoticzNis ... /plugin.py

Regards and thank you for your work.
wimw1953
Posts: 5
Joined: Tuesday 14 June 2022 11:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: [Module]Nissan Leaf 2

Post by wimw1953 »

Thanks

I have chosen another solution. I installed docker and used yp87/leaf2mqtt (built image). It works perfect! At the specified intervals data is reported to MQTT and in this way easy to send to Domoticz.


succes!
User avatar
breizhcat
Posts: 16
Joined: Tuesday 07 July 2020 17:51
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: France
Contact:

Re: [Module]Nissan Leaf 2

Post by breizhcat »

Hello !

@josemi:
I take into account your changes in my branch and I also add a new device to provide cabin temp.

@wimw1953:
I tried this repo but I'm in Europe and it seems that it doesn't work for me.

Thanks
ricvee
Posts: 32
Joined: Wednesday 13 May 2015 9:05
Target OS: Linux
Domoticz version: Stable
Location: Netherlands
Contact:

Re: [Module]Nissan Leaf 2

Post by ricvee »

@breizhcat:
I use your plugin:https://github.com/BreizhCat/DomoticzNissanLeaf
It was working fine for a couple of weeks, until yesterday....
There were no changes, but it stopped, and the only thing in the domoticz logs is this:
Error: CPlugin:PyDomoticz_Log, illegal operation, Plugin has not started yet.

How can I fix this?

Thanks in advance.
Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 1 guest