ESP32 Classic MQTT Publisher & Home Assistant

Started by Graham, February 13, 2020, 05:58:57 PM

Previous topic - Next topic

mcsarge

Oh right, that makes sense. Running inside Docker or directly from the Pi, this would be less of an issue.
Off Grid Island in Ontario Canada (Beaverstone Bay)
Primary: Classic 150 + wbjr; 3s2p HES 270watt
Winter: SolarBoost 50 MPPT (into wbjr); 2 x Sharp NE-80EJEA 80watt
Pack: 4s2p ROLLS S6-460AGM 6V for 24V pack
Inverter/Charger: Trace DR2424
Call Sign: KG4EUF

ClassicCrazy

I got my Raspberry Pi 3B+ running - I had earlier installed Docker and some other programs on it using the Andreas Spies video about it. One of the options on the installer is HAAS IO so I ran that awhile ago.
I am still trying to figure out how to open up and use all these programs and features.
I also have Mosquito MQTT on it so I want to try to use that with the esp32 and Classic for my local network use here.
There is a lot to learn and setup.

Larry
system 1
Classic 150 , 5s3p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system 2
 5s 135w Kyocero , 3s3p 270w Kyocera  to Classic 150 ,   8s Kyocera 225w to Hawkes Bay Jakiper 48v 15kwh LiFePO4 , Outback VFX 3648 inverter
system 3
KID / Brat portable

mcsarge

Larry,

The cool thing about having the MQTT outside your network is that you will not have to poke a hole in your firewall for the app to reach into. But setting up Mosquito is super easy, just remember you need to add users.

Matt
Off Grid Island in Ontario Canada (Beaverstone Bay)
Primary: Classic 150 + wbjr; 3s2p HES 270watt
Winter: SolarBoost 50 MPPT (into wbjr); 2 x Sharp NE-80EJEA 80watt
Pack: 4s2p ROLLS S6-460AGM 6V for 24V pack
Inverter/Charger: Trace DR2424
Call Sign: KG4EUF

ClassicCrazy

ha ha - I wouldn't call any of this stuff super easy !  Maybe when I get my head wrapped around it a little bit more. At least I am out of the novice linux and raspberry pi stage so  I know what is getting talked about and how to do stuff either by ssh into pi or to vnc into it for full web interface.

Larry
system 1
Classic 150 , 5s3p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system 2
 5s 135w Kyocero , 3s3p 270w Kyocera  to Classic 150 ,   8s Kyocera 225w to Hawkes Bay Jakiper 48v 15kwh LiFePO4 , Outback VFX 3648 inverter
system 3
KID / Brat portable

ClassicCrazy

I did get Grahams esp32 code working to his Android Classic monitor using MQTT server via Matt.
But then I decided I wanted to install Mosquitto MQTT Broker on my own Raspberry Pi and use that locally so I could learn how that works and also try to do some other MQTT stuff around here maybe via node red.
So I downloaded the Andreas Spiess recommended Docker and other installer by the other Graham from South Africa  - everything installed okay - I can get Portainer to run on the pi chrome browser and Node Red too by just  going to their web interfaces.
But I have spent many nights reading up or trying to figure out the Mosquitto stuff - watched lots of videos . I  find that other  instructional videos won't work unless I start over with their naming systems from scratch.
I think everyone assumes that  everyone has some knowledge of the most confusing file naming and location and linux schemes imaginable. I admit defeat for now. It seems there is some simple step to putting a files somewhere else on the Pi to make mosquitto work but I just don't get it and nothing I have tried works. I get halfway into someones detailed video before they leave me in the dust and my eyes glaze over  and I am convinced they are just talking gibberish and having a laugh that someone out there wasted their time listening to their meaningless BS.
So thanks Graham and Matt - your explanations and your stuff works. For the rest of it I may have to wipe the pi and docker and start out fresh and not use the predownloaded method  Andreas explains because they assume I probably understand all the untold steps and I don't !
But I did put in a lot of hours trying.

Larry
system 1
Classic 150 , 5s3p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system 2
 5s 135w Kyocero , 3s3p 270w Kyocera  to Classic 150 ,   8s Kyocera 225w to Hawkes Bay Jakiper 48v 15kwh LiFePO4 , Outback VFX 3648 inverter
system 3
KID / Brat portable

Graham

Sorry to hear your having some frustration with the setup
I would just install home assistant on the Raspberry PI and use the add-on store within the hassio/dashboard to install Node-Red and the mosquito broker. The HassIO image comes pre-configured with everything you need like docker etc...

The Mosquito broker is in the "Official add-ons" repository and NodeRed is in the "Community Add-ons" repository

https://www.home-assistant.io/getting-started/


Graham.
Off-Grid Island cottage, Lac Simon QC Canada
370 Ahrs @ 24V (4 8L16 batteries)
4 x 250watt panels on dual axis trackers http://tinyurl.com/hfpkgr5
Classic 150, Whizbang Jr.
Android Monitor: http://tinyurl.com/lomzq3s

mcsarge

Hello Fellows.

I am attempting to read from the Classic registers starting at 16385, I would like to read the app_rev and the net_rev. When I try to read those over the MODBUS I get an error. Any suggestions? That register number is alot higher than the others, so maybe it is just not there?

Matt
Off Grid Island in Ontario Canada (Beaverstone Bay)
Primary: Classic 150 + wbjr; 3s2p HES 270watt
Winter: SolarBoost 50 MPPT (into wbjr); 2 x Sharp NE-80EJEA 80watt
Pack: 4s2p ROLLS S6-460AGM 6V for 24V pack
Inverter/Charger: Trace DR2424
Call Sign: KG4EUF

ClassicCrazy

Quote from: Graham on February 26, 2020, 07:46:07 AM
Sorry to hear your having some frustration with the setup
I would just install home assistant on the Raspberry PI and use the add-on store within the hassio/dashboard to install Node-Red and the mosquito broker. The HassIO image comes pre-configured with everything you need like docker etc...

The Mosquito broker is in the "Official add-ons" repository and NodeRed is in the "Community Add-ons" repository

https://www.home-assistant.io/getting-started/

Graham.

Thanks Graham- I will give that a try !  I didn't realize it was something ready to go as a flash and maybe when i tried it before I was doing it on top of other install .

Larry
system 1
Classic 150 , 5s3p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system 2
 5s 135w Kyocero , 3s3p 270w Kyocera  to Classic 150 ,   8s Kyocera 225w to Hawkes Bay Jakiper 48v 15kwh LiFePO4 , Outback VFX 3648 inverter
system 3
KID / Brat portable

mcsarge

Graham,

I have been able to collect the MAC address and I can send it on in the "info" package - do you have an identifier that I should use to send it to the app, or are you not yet gathering that? If you have not done it yet, I am using the identifier in the JSON of "mac".

I can add similar code the ESP32 code if you want.

Matt
Off Grid Island in Ontario Canada (Beaverstone Bay)
Primary: Classic 150 + wbjr; 3s2p HES 270watt
Winter: SolarBoost 50 MPPT (into wbjr); 2 x Sharp NE-80EJEA 80watt
Pack: 4s2p ROLLS S6-460AGM 6V for 24V pack
Inverter/Charger: Trace DR2424
Call Sign: KG4EUF

Graham

Quote from: mcsarge on February 26, 2020, 11:03:38 AM
Hello Fellows.

I am attempting to read from the Classic registers starting at 16385, I would like to read the app_rev and the net_rev. When I try to read those over the MODBUS I get an error. Any suggestions? That register number is alot higher than the others, so maybe it is just not there?

Matt

I have a modbus tool I wrote a few years ago that might be useful, it's a bit buggy but gets the job done
https://github.com/graham22/ModbusTool

It includes a master & Slave app, you can connect to the classic using the master, once you read some registers, you can export the data and load it into the slave app to emulate the classic then you can manually change some register values to see how it affects the android app or MQTT publisher...

Attached is a snip of the Modbus Master having read 4 bytes at 16386 from the classic


Graham.
Off-Grid Island cottage, Lac Simon QC Canada
370 Ahrs @ 24V (4 8L16 batteries)
4 x 250watt panels on dual axis trackers http://tinyurl.com/hfpkgr5
Classic 150, Whizbang Jr.
Android Monitor: http://tinyurl.com/lomzq3s

Graham

Quote from: mcsarge on February 26, 2020, 01:45:27 PM
Graham,

I have been able to collect the MAC address and I can send it on in the "info" package - do you have an identifier that I should use to send it to the app, or are you not yet gathering that? If you have not done it yet, I am using the identifier in the JSON of "mac".

I can add similar code the ESP32 code if you want.

Matt

unfortunately the android subscriber is not expecting the mac address in the ChargeControllerTransfer.java class.

the MQTT version of the android app needs some re-factoring since it currently can only handle one classic

here is my todo list for the app

1. remove the MQTT publisher code since it makes more sense to use a Rpi or a esp32 for this
2. move the root topic setting out of the config and put it into the nav bar + so you can add more than one just like adding an IP address/port in the regular app version
3. Update the info transfer to include the missing data

#2 is the most difficult since the app would have to subscribe to multiple root topics to sum the values used in the system view...


Graham.

Off-Grid Island cottage, Lac Simon QC Canada
370 Ahrs @ 24V (4 8L16 batteries)
4 x 250watt panels on dual axis trackers http://tinyurl.com/hfpkgr5
Classic 150, Whizbang Jr.
Android Monitor: http://tinyurl.com/lomzq3s

mcsarge

OK,

I was able to get the app_rev and net_rev read - I looked at your code in the Classic Android App and noticed you were reading not at 16384 but at the location of the 2 values you are interested in. Once I did that I could collect the values no problem.

I now have the code running on my Pi on the island pumping data to an MQTT on azure.

It seems to work on my copy of the Android app...

Matt
Off Grid Island in Ontario Canada (Beaverstone Bay)
Primary: Classic 150 + wbjr; 3s2p HES 270watt
Winter: SolarBoost 50 MPPT (into wbjr); 2 x Sharp NE-80EJEA 80watt
Pack: 4s2p ROLLS S6-460AGM 6V for 24V pack
Inverter/Charger: Trace DR2424
Call Sign: KG4EUF

mcsarge

OK,

I created a pull request so you can grab the python version.

It requires python3, pymodbus and paho-mqtt.

Matt
Off Grid Island in Ontario Canada (Beaverstone Bay)
Primary: Classic 150 + wbjr; 3s2p HES 270watt
Winter: SolarBoost 50 MPPT (into wbjr); 2 x Sharp NE-80EJEA 80watt
Pack: 4s2p ROLLS S6-460AGM 6V for 24V pack
Inverter/Charger: Trace DR2424
Call Sign: KG4EUF

mcsarge

Give me a little more time on this, I am working out some issues with when mqtt disconnects and reconnects.
Off Grid Island in Ontario Canada (Beaverstone Bay)
Primary: Classic 150 + wbjr; 3s2p HES 270watt
Winter: SolarBoost 50 MPPT (into wbjr); 2 x Sharp NE-80EJEA 80watt
Pack: 4s2p ROLLS S6-460AGM 6V for 24V pack
Inverter/Charger: Trace DR2424
Call Sign: KG4EUF

ClassicCrazy

I did get the Home Assistant flashed on the Raspberry Pi here.
I made some progress but very slow progress figuring out Home Assistant  and it isn't for lack of spending time watching tutorials.
Biggest issues I find
They have made so many changes to Home Assistant that none of the old tutorials make a lot of sense with new versions.
Some of the things have been renamed to make it even more confusing. For example the add on File Editor used to be called Configurator .
Many of the detailed instructions don't work - for example I installed add on Mosquitto Broker and followed the steps - but they show a screen in the install or setup for configuring it - but that setup screen just does not ever show up.
I tried adding custom cards to the UI- sort of - watched tutorials but some of those guys don't show a blown up screen of what they are doing and go so fast and are working with the old version , etc . 
Nothing I try ever seems to work - such as just paste something to the Yaml config but then it has all kinds of errors showing up - spacing , indents , this, that, and the other thing ! 
This Home Assistant program just is not intuitive - maybe some day it will be.
I think I will go back to trying to figure out Node Red - at least that program isn't all over the map like Home Assistant.
But as I said before - if I was just doing the basic project in this forum topic- getting an Esp32 programmed and publishing to MQTT broker and then using Android with Classic Monitoring  app to subscribe to that and display the Classic data - yes got that done and that works !

Larry

system 1
Classic 150 , 5s3p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system 2
 5s 135w Kyocero , 3s3p 270w Kyocera  to Classic 150 ,   8s Kyocera 225w to Hawkes Bay Jakiper 48v 15kwh LiFePO4 , Outback VFX 3648 inverter
system 3
KID / Brat portable