Author Topic: ESP32 Classic MQTT Publisher & Home Assistant  (Read 1644 times)

Graham

  • Full Member
  • ***
  • Posts: 233
    • SkyeTracker
Re: ESP32 Classic MQTT Publisher & Home Assistant
« Reply #60 on: March 11, 2020, 02:44:38 PM »
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

Info should make it publish the boilerplate info

topic: /graham.a.ross@gmail.com/Workshop/stat/info

payload:
{"appVersion":"","buildDate":"20180206","deviceName":"Workshop","deviceType":"Classic","endingAmps":10.81,"hasWhizbang":true,"lastVOC":13.21,"model":"Classic 200 (rev 4)","mpptMode":11,"netVersion":"","nominalBatteryVoltage":12,"unitID":-1901764051}


I'm just about ready to check in my code for the app and the esp32
in order to support more than one classic, I'm using the Unit Name at modbus address 4210 - 4213 (default to Classic if not set in the LA)
so in the above topic i have the / dioty root topic / Unit Name / stat / info

In the app, you would configure the MQTT broker, port, user, password and root topic from dioty for example /graham.a.ross@gmail.com/
then you would add an entry in the nav bar using the Unit Name


Graham
Off-Grid Island cottage, Lac Simon QC
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

  • Jr. Member
  • **
  • Posts: 96
Re: ESP32 Classic MQTT Publisher & Home Assistant
« Reply #61 on: March 11, 2020, 03:52:24 PM »
OK,

I mis-spoke, when i get INFO or WAKE i transmit the boilerplate and the readings, and then send the readings every 5 seconds for 5 minutes. If I get a WAKE or INFO again, I transmit the boilerplate again and reset the countdown again.

Should we code the tools to automatically add the value we receive from that location on the Classic to the root? This will not be unique, however.

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: 4s4p US2200 FLA 6V for 24V pack
Inverter/Charger: Trace DR2424
Call Sign: KG4EUF

Graham

  • Full Member
  • ***
  • Posts: 233
    • SkyeTracker
Re: ESP32 Classic MQTT Publisher & Home Assistant
« Reply #62 on: March 12, 2020, 06:59:21 AM »
OK,

I mis-spoke, when i get INFO or WAKE i transmit the boilerplate and the readings, and then send the readings every 5 seconds for 5 minutes. If I get a WAKE or INFO again, I transmit the boilerplate again and reset the countdown again.

Should we code the tools to automatically add the value we receive from that location on the Classic to the root? This will not be unique, however.

Matt

The android app currently sends the wake every 58 seconds (just short of the 60 second publisher timer) to keep the readings coming every 2 seconds while the app is running, it doesn't need to get the info every 58 seconds since that data doesn't change.

Maybe it would be simpler just to add the controller name as an extra argument like --classicName <Workshop>

You can set the name at 4210 in the local app but maybe not everyone realizes that


Graham.
Off-Grid Island cottage, Lac Simon QC
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

  • Jr. Member
  • **
  • Posts: 96
Re: ESP32 Classic MQTT Publisher & Home Assistant
« Reply #63 on: March 12, 2020, 05:00:21 PM »
I can change the code on the wake/info thing, but I was thinking that when running for long periods of time the boiler plate data might need to be updated, like last VOC and mpptMode. For the python code it makes no difference, I get it all every time no matter what, i just do not publish it if it is not time.

I think anyone with multiple Classics will know to set the names different. Just let me know how you want to proceed and I will update the python code.

I ordered a 10x5 inch (64x32 pixels) RGB LED matrix panel and HUB75 adapter to run it from an ESP32 - I am going to display the SOC, Voltage and some other data on it in the main cabin so that everyone will know if the genny needs to be started. I may add a defaulted parameter so I can set the snooze time from 5 minutes to 1 minute for my installation so the data on the panel does not get too old.
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: 4s4p US2200 FLA 6V for 24V pack
Inverter/Charger: Trace DR2424
Call Sign: KG4EUF

ClassicCrazy

  • Hero Member
  • *****
  • Posts: 2393
Re: ESP32 Classic MQTT Publisher & Home Assistant
« Reply #64 on: March 12, 2020, 06:03:13 PM »
I have my two Classics named different . Looking forward to the new mutliple Classic version. 

Larry
system one
Classic 150 , 5s4p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system two
Classic 150 ,5s 135 watt Kyocero , 16s Calb 100AH LiFePO4 , Outback VFX 3648 inverter
system three
Midnite KID MPPT 24 DC in to  12 volt AGM batterie

Graham

  • Full Member
  • ***
  • Posts: 233
    • SkyeTracker
Re: ESP32 Classic MQTT Publisher & Home Assistant
« Reply #65 on: March 18, 2020, 01:19:06 PM »
I have my two Classics named different . Looking forward to the new mutliple Classic version. 

Larry

I have an updated version (app-release-3.0.1.apk) on google drive https://drive.google.com/drive/folders/1S2BWLFn_nU0NmxXmyhJaz97h0K1_OY6B

if you are using the Python implementation of the publisher, you can simply run two docker images, one for each controller.
get the latest from https://github.com/graham22/ClassicMQTT goto code/python and build the new docker image
docker build -t classic_mqtt .

here is an example (replace the classic <IP> mqtt_root, mqtt_user, mqtt_pass)

docker run -d classic_mqtt --classic 192.168.86.37 --classic_port 502 --classic_name Cabin --mqtt mqtt.dioty.co --mqtt_root /graham.a.ross@gmail.com/ --mqtt_user graham.a.ross@gmail.com --mqtt_pass XXXXXXX
docker run -d classic_mqtt --classic 192.168.86.32 --classic_port 502 --classic_name Workshop --mqtt mqtt.dioty.co --mqtt_root /graham.a.ross@gmail.com/ --mqtt_user graham.a.ross@gmail.com --mqtt_pass XXXXXX

Then setup the android app in MQTT mode with the MQTT broker, port, user, passwd, root topic
Add "Cabin" and "Workshop" to the nav bar

You should be able to switch back to MODBUS mode and set the classics IP as usual, hopefully I didn't break anything...

the pros;
can access the classics info from the internet without port forwarding if you setup a cloud based broker (dioty.co, Azure etc)
can use more than one app at the same time.
can be used with Home Assistant, NodeRed, or any other MQTT subscriber

cons
Day, Hour logs and Calendar view not available in MQTT mode



let me know how you do

Graham
Off-Grid Island cottage, Lac Simon QC
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

  • Hero Member
  • *****
  • Posts: 2393
Re: ESP32 Classic MQTT Publisher & Home Assistant
« Reply #66 on: March 18, 2020, 02:35:32 PM »
Thanks Graham - I will give this a try later on today or tomorrow.

Larry
system one
Classic 150 , 5s4p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system two
Classic 150 ,5s 135 watt Kyocero , 16s Calb 100AH LiFePO4 , Outback VFX 3648 inverter
system three
Midnite KID MPPT 24 DC in to  12 volt AGM batterie

ClassicCrazy

  • Hero Member
  • *****
  • Posts: 2393
Re: ESP32 Classic MQTT Publisher & Home Assistant
« Reply #67 on: March 20, 2020, 01:00:33 AM »
Graham ,
I followed  your instructions and  I have it all installed on Raspberry Pi using mosquitto and on my android phone .
Both my Classics show up and I can switch between the two and they both have data .
I like that the Messages info shows Aux - I used MNGP to turn AUX 1 on and it instantly showed up in the Messages info. 
It is night so not much happening with them now - but  I will look tomorrow to see the charging action.
I am surprised this all worked just the way it was supposed to first time I gave it a go - your instructions were good.
Thanks
 Larry
system one
Classic 150 , 5s4p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system two
Classic 150 ,5s 135 watt Kyocero , 16s Calb 100AH LiFePO4 , Outback VFX 3648 inverter
system three
Midnite KID MPPT 24 DC in to  12 volt AGM batterie

mcsarge

  • Jr. Member
  • **
  • Posts: 96
Re: ESP32 Classic MQTT Publisher & Home Assistant
« Reply #68 on: March 20, 2020, 08:17:08 AM »
Well, we did test it! :-) but I do not have 2 Classics so...

You might also notice that the MAC address is populated correctly and the Negative Amp Hours on "Capacity" is now displayed. It was not working on the MQTT version.

Matt

Graham ,
I followed  your instructions and  I have it all installed on Raspberry Pi using mosquitto and on my android phone .
Both my Classics show up and I can switch between the two and they both have data .
I like that the Messages info shows Aux - I used MNGP to turn AUX 1 on and it instantly showed up in the Messages info. 
It is night so not much happening with them now - but  I will look tomorrow to see the charging action.
I am surprised this all worked just the way it was supposed to first time I gave it a go - your instructions were good.
Thanks
 Larry
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: 4s4p US2200 FLA 6V for 24V pack
Inverter/Charger: Trace DR2424
Call Sign: KG4EUF

Graham

  • Full Member
  • ***
  • Posts: 233
    • SkyeTracker
Re: ESP32 Classic MQTT Publisher & Home Assistant
« Reply #69 on: March 20, 2020, 08:42:52 AM »
Graham ,
I followed  your instructions and  I have it all installed on Raspberry Pi using mosquitto and on my android phone .
Both my Classics show up and I can switch between the two and they both have data .
I like that the Messages info shows Aux - I used MNGP to turn AUX 1 on and it instantly showed up in the Messages info. 
It is night so not much happening with them now - but  I will look tomorrow to see the charging action.
I am surprised this all worked just the way it was supposed to first time I gave it a go - your instructions were good.
Thanks
 Larry

thanks for helping with the testing of the app
I've been running the publisher on both the ESP version and the Python implementation running in a docker image on linux both posting to the dioty.co broker for a few days without issue.

if both your classics feed one battery bank, you can now enable "system view" when in MQTT mode.
As you know, if you use a cloud based broker, the app can access the classic's data from anywhere on the internet when in MQTT mode,
you can also switch back to MODBUS mode when your device is on your local network to get the calendar information and to upload to PVOutput.

I have started a wiki on github for the project at https://github.com/graham22/ClassicMQTT/wiki that has public edit enabled, if you or anyone else would like to add more details, please go ahead.

I have version 3.0.2 on google drive https://drive.google.com/drive/folders/1S2BWLFn_nU0NmxXmyhJaz97h0K1_OY6B with a few minor fixes.
I will not be posting this version of the app to google play since the setup might be beyond the scope of the average user.


Graham.
Off-Grid Island cottage, Lac Simon QC
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

  • Hero Member
  • *****
  • Posts: 2393
Re: ESP32 Classic MQTT Publisher & Home Assistant
« Reply #70 on: March 20, 2020, 12:50:33 PM »
Graham -
I just tried out System View - that is really nice feature and saves a lot of trouble flipping back and forth between controllers to see the total.
I may give the dioty server a try again - I did not have any luck with it when I first started on this.
My question about that is - do I have to change the settings in just the android app or do I have to redo the docker also ?
I set it up in docker just as you had said but I put in my mosquitto password - so should I run that again but with my dioty info ?
I am a bit confused about the difference between the Modbus and MQTT  settings in the Android app .

I just installed the latest Classic Monitor 3.02 and all is good here  - it kept all my previous settings.

Larry

« Last Edit: March 20, 2020, 01:06:36 PM by ClassicCrazy »
system one
Classic 150 , 5s4p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system two
Classic 150 ,5s 135 watt Kyocero , 16s Calb 100AH LiFePO4 , Outback VFX 3648 inverter
system three
Midnite KID MPPT 24 DC in to  12 volt AGM batterie

ClassicCrazy

  • Hero Member
  • *****
  • Posts: 2393
Re: ESP32 Classic MQTT Publisher & Home Assistant
« Reply #71 on: March 20, 2020, 01:02:37 PM »
Well, we did test it! :-) but I do not have 2 Classics so...

You might also notice that the MAC address is populated correctly and the Negative Amp Hours on "Capacity" is now displayed. It was not working on the MQTT version.

Matt

Graham ,
I followed  your instructions and  I have it all installed on Raspberry Pi using mosquitto and on my android phone .
Both my Classics show up and I can switch between the two and they both have data .
I like that the Messages info shows Aux - I used MNGP to turn AUX 1 on and it instantly showed up in the Messages info. 
It is night so not much happening with them now - but  I will look tomorrow to see the charging action.
I am surprised this all worked just the way it was supposed to first time I gave it a go - your instructions were good.
Thanks
 Larry

Thanks Matt - I noticed now that you mentioned it . This app has improved in a big way !
Your  collaboration with Graham  is much appreciated by me and I am sure everyone .

Larry

Larry
system one
Classic 150 , 5s4p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system two
Classic 150 ,5s 135 watt Kyocero , 16s Calb 100AH LiFePO4 , Outback VFX 3648 inverter
system three
Midnite KID MPPT 24 DC in to  12 volt AGM batterie

Graham

  • Full Member
  • ***
  • Posts: 233
    • SkyeTracker
Re: ESP32 Classic MQTT Publisher & Home Assistant
« Reply #72 on: March 20, 2020, 01:27:02 PM »
Graham -
I just tried out System View - that is really nice feature and saves a lot of trouble flipping back and forth between controllers to see the total.
I may give the dioty server a try again - I did not have any luck with it when I first started on this.
My question about that is - do I have to change the settings in just the android app or do I have to redo the docker also ?
I set it up in docker just as you had said but I put in my mosquitto password - so should I run that again but with my dioty info ?
I am a bit confused about the difference between the Modbus and MQTT  settings in the Android app .

I just installed the latest Classic Monitor 3.02 and all is good here  - it kept all my previous settings.

Larry

Yes both the Android app and the docker parameters must match.
You will need to stop your existing docker image with
docker ps 
docker stop <CONTAINER_ID>

(or just reboot the raspberry pi)

then run it with the dioty parameters you got from their confirmation email when you registered for the service.

here is an example of my parameters ;

docker run -d classic_mqtt --classic 192.168.86.32 --classic_port 502 --classic_name Workshop --mqtt mqtt.dioty.co --mqtt_root /graham.a.ross@gmail.com/ --mqtt_user graham.a.ross@gmail.com --mqtt_pass XXXXXX

Set the same parameters in the android app settings for MQTT mode with the MQTT broker, User, Password and Root topic (including the slashes)
then add an entry in the nav bar using the name you have for the --classic_name parameter (Workshop in my case).

You can switch the app back to regular MODBUS mode where it will connect directly to your classic if you are on your local network as the current google play version 2.5.8 does.
The nav bar will switch to display the modbus connections you have instead of the MQTT names.

You will notice that when you hit the + on the nav bar in modbus mode, the dialog asks you for a port & IP/URI of the classic, when it's in MQTT mode, the add dialog just asks you for the name.

Graham
« Last Edit: March 20, 2020, 01:41:21 PM by Graham »
Off-Grid Island cottage, Lac Simon QC
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

  • Hero Member
  • *****
  • Posts: 2393
Re: ESP32 Classic MQTT Publisher & Home Assistant
« Reply #73 on: March 20, 2020, 02:38:37 PM »
I will give it a try later and see how it goes.

Larry
system one
Classic 150 , 5s4p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system two
Classic 150 ,5s 135 watt Kyocero , 16s Calb 100AH LiFePO4 , Outback VFX 3648 inverter
system three
Midnite KID MPPT 24 DC in to  12 volt AGM batterie

ClassicCrazy

  • Hero Member
  • *****
  • Posts: 2393
Re: ESP32 Classic MQTT Publisher & Home Assistant
« Reply #74 on: March 31, 2020, 12:55:00 PM »
Graham and Matt have worked out the bugs and the newest Beta Android Classic Monitoring  app is monitoring both of my Classics in follow me mode - the app can switch between getting the data directly from Modbus or you can switch it to monitor MQTT from either a Raspberry Pi or Esp32 ( though I think Esp32 only does one Classic but the Pi can monitor both at same time )
See the project  here for more details - new github address
https://github.com/ClassicDIY

Larry 
system one
Classic 150 , 5s4p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system two
Classic 150 ,5s 135 watt Kyocero , 16s Calb 100AH LiFePO4 , Outback VFX 3648 inverter
system three
Midnite KID MPPT 24 DC in to  12 volt AGM batterie