Start a new topic

MQTT: can read but not write?

 I'm trying to use MQTT to control our OpenEVSE unit. I have successfully set up an MQTT broker, set the EVSE to publish to it, and written a Python client app that receives the messages published by the EVSE. It works great! 


However, when I use the same connection to attempt to publish (send a message) to the EVSE, my message doesn't have any effect. I don't know whether I've published to the wrong topic, or misformed the payload, or what. My Python client reports that the message has a valid message id, and the return code from the publish call indicates no error.


I attached a working Python sample. With line 14 uncommented, the code listens (reads) forever and just echoes what it receives. With line 14 commented and 15 uncommented, I hope to restart the EVSE but that doesn't work. 


Any comments or suggestions would be appreciated. I feel like this is probably something really simple, but I can't see it.

py

To follow up on this, here's what I've tried.

I have root access on my dev server. I configured my mosquitto broker to log everything, and I can see that the broker received subscribe requests from the EVSE, for instance --

1783176208: Received SUBSCRIBE from openevse-5864
1783176208:     openevse/restart (QoS 0)
1783176208: openevse-5864 0 openevse/restart
1783176208: Sending SUBACK to openevse-5864

I can also confirm via the mosquitto logs that my published messages are getting sent to the EVSE, for example --

1783377116: Received PUBLISH from auto-1D4EFA72-BD8B-9D86-ED8E-6541D9419BDB (d0, q0, r0, m0, 'openevse/restart', ... (18 bytes))
1783377116: Sending PUBLISH to openevse-5864 (d0, q0, r0, m0, 'openevse/restart', ... (18 bytes))

I've tried all sorts of different variations on the restart message format. I've also tried a variety of RAPI commands over MQTT, including commands to change the color of the backlight. I can see that they're all published to the EVSE, but none of them seem to have any effect. It's as if all of the function calls in mqtt.cpp have been replaced by calls to noop(). 



 

Yes, I'm using the MQTT commands documented at that page. 

 That document is indeed more readable than other doc I've discovered, so thanks for that. 

I forgot I could use mosquitto_pub, and that was a useful reminder. What I learned is that I can restart the gateway through MQTT, but not the EVSE. In other words, this works --

mosquitto_pub -h localhost -t 'openevse/restart' -m '{"device":"gateway"}'

This doesn't seem to so anything --

mosquitto_pub -h localhost -t 'openevse/restart' -m '{"device":"evse"}'

I see the same via my Python code. Restarting the gateway via MQTT suceeds, attempting to restart the EVSE has no effect.

Maybe I misunderstand what restarting "evse" is supposed to do in this context. I see in the .cpp code that it calls _monitor.restart(). Is the monitor an internal process that has no effect on the display of the unit? I expected 'restart evse' to restart the entire unit, a soft boot parallel to a hard boot (power off/power on). Maybe the problem is with my expectation, and not with the command.

Side note: these commands also succeed for me, which is great because they're on the critical path to what I want to accomplish --

mosquitto_pub -h localhost -t 'openevse/override/set' -m '{"state":"disabled"}'

mosquitto_pub -h localhost -t 'openevse/override/set' -m '{"state":"active"}'

restart

gateway = WiFi module

evse = safety controller


Whole station would be gateway + evse

Great, thanks! 

Login or Signup to post a comment