ESP32 Classic MQTT Publisher & Home Assistant

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

Previous topic - Next topic

Graham

Matt,
I posted a pull request on my ClassicMQTT github page for you to review,
I want to add a "will" so that the android app can detect when the publisher goes offline so it can clear the gauges

https://github.com/graham22/ClassicMQTT/pull/6
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: ClassicCrazy on March 07, 2020, 10:46:43 AM
Matt ,
I don't have a firewall - but my android is still not connecting
I set the Grahams Classic Monitoring to
Mqtt subscriber
Mqtt broker host name to the router ip address that the pi has which is 192.168.3.29
mqtt broker port to 1883

I used the same mqtt user and passwords and root topic as you had in examples.

But I still don't connect with android.

Do I have to edit the mqtt host file  somewhere ?- - it says 127.0.0.1 is default in the code file
Also wondering if I should start out fresh again in case those extra copies of pymod and mosquitto I installed outside of docker are messing anything up ?

Larry

Larry,
have you tried using the MQTT.fx tool see if the data is being published

you can subscribe to "ClassicMQTT/#" to get all messages
you can also publish a "WAKE" command to get the publisher to send readings


Graham.


https://mqttfx.jensd.de/index.php/download
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

ClassicCrazy

Matt
Should this .env file have another entry for mqtt broker address ?
Guess I could try it and see what happens

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

Quote from: Graham on March 07, 2020, 11:01:59 AM
Quote from: ClassicCrazy on March 07, 2020, 10:46:43 AM
Matt ,
I don't have a firewall - but my android is still not connecting
I set the Grahams Classic Monitoring to
Mqtt subscriber
Mqtt broker host name to the router ip address that the pi has which is 192.168.3.29
mqtt broker port to 1883

I used the same mqtt user and passwords and root topic as you had in examples.

But I still don't connect with android.

Do I have to edit the mqtt host file  somewhere ?- - it says 127.0.0.1 is default in the code file
Also wondering if I should start out fresh again in case those extra copies of pymod and mosquitto I installed outside of docker are messing anything up ?

Larry

Larry,
have you tried using the MQTT.fx tool see if the data is being published

you can subscribe to "ClassicMQTT/#" to get all messages
you can also publish a "WAKE" command to get the publisher to send readings


Graham.


https://mqttfx.jensd.de/index.php/download

I will give that tool a try Graham

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

#49
I think adding that MQTT broker line with my router ip address to the .env file did the trick because now the Android connected up and is reading all the data .

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,

When the tool is started in the compose file, I pass in "mosquitto" for the --mqtt parameter that should specify the virtual hostname mosquitto in the compose file. Not sure why it would not find it living there. If you add a parameter to the .env file, I would not use it unless you add that to the command.

If you zip up your Python directory and send it to me I can take a better look matthew dot c dot sargent at gmail etc.

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

BTW,

I have been using MQTT Explorer and it works well for me.

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: mcsarge on March 07, 2020, 02:53:05 PM
BTW,

I have been using MQTT Explorer and it works well for me.

Matt

I just got the MQTT Explorer running and connected.
I did not have success with the MQTT FX tool

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 just tested  - when the Pi is connected to Classic and publishing to the Classic Android app - if I connect up to the Classic using the Midnite Local Status app - that app will connect and take over and the Android app looses its data. As soon as I close the Midnite Local Status app - the Android app responds right away with the data from the Classic again.

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

This is expected behavior because the Python program connects to the modbus port, gets the data, and then disconnects every 5 seconds or 5 minutes. The localapp connects to the modbus port and then doesn't disconnect until you stop running the program
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: mcsarge on March 09, 2020, 07:29:44 AM
This is expected behavior because the Python program connects to the modbus port, gets the data, and then disconnects every 5 seconds or 5 minutes. The localapp connects to the modbus port and then doesn't disconnect until you stop running the program

I like how this works - no problems when I want to connect on Midnite Local app .

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 updated the tool to use timeloop - a great library for timed executions and such. I have also re-written the readme totally to describe the 3 wys to install the tool. I will start a pull-request.

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

Oops, I edited the Wiki on your repo, so the wiki does not match the code until you do the Pull. Sorry.
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 March 10, 2020, 03:53:53 PM
Graham,

I have updated the tool to use timeloop - a great library for timed executions and such. I have also re-written the readme totally to describe the 3 wys to install the tool. I will start a pull-request.

Matt

Ok, I'll look for the pull request

I added a page in the wiki for the python version, it's just a copy of your readme for now but we should add some context at some point

also working on an update to the android subscriber so it can support more than one controller
I removed publisher mode because android would terminate the app when the device has no user interaction.

we'll have to add an extra field for the controller name in both the ESP and Python version

the MQTT topic is made up with
1 a root topic, with dioty, you have to use /youremail@mail.com/  , can be anything for mosquito as long as the root topic in the android settings and the publisher match
2 the controller name, so   /youremail@mail.com/MainController/ for dioty , in the app you would enter the controller name from the + when the nav bar is out (just like the classic's IP or URI)

I'll post the updated apk to google drive after a bit of testing

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

Awesome,

Can you give me the exact steps that you are using with "WAKE" and "INFO" - right now i am treating them the same, if I get either one, I reset the 5 minute countdown timer so that the every 5 seconds will continue.

Add the use of the "mac address" in the info screen <- It could also be used in the classic root, as it is unique to every Classic as is the unitid.

In the App, it appears that each page awaits the next message received every 5 seconds to populate, can you store all the data from each publish and then use that data to paint each screen as it is needed? That way when you flip from screen to screen, you do not have to wait for a message to come in to see the data.

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