vitotai / BrewPiLess

Use an ESP8266 to replace RPI and Arduino. Running BrewPi without Pi, therefore, BrewPi-Less
352 stars 131 forks source link

MQTT Remote Control #205

Open jbishop129 opened 4 years ago

jbishop129 commented 4 years ago

Hello, Great project!! I cannot seem to get MQTT Remote Control to work. I'm able to get it to attach to my MQTT broker and see the logging in topics as expected, both when set as Individual Topic or JSON; working, looks great. However, I cannot seem to get it to switch modes, or update fridge or beer set points via MQTT. I suspect I'm missing something in the topics I'm sending those messages. Here's my setup: ESP8266 on NodeMCU board Firmware: BrewPiLess.v3.6r3.oled.newui.4m2m.bin Might be worth noting, I'm running in Fahrenheit mode via j{"tempFormat":"F"}

Base Path: BPL01 Path for Mode: setMode path for FridgeSet: setFridge path for BeerSet: setBeer

I've tried sending any of the 0,1,2,3 payloads, or o,p,f,b payloads to topic: BPL01/setMode topic. I see the payload publish in the topic as expected when monitoring my broker, but no mode change. I've also tried prefixing the Base Path with /, and targeted the topic accordingly (/BPL01/setMode), and also tried prefixing the Path for Mode: path with a /, just in case it wasn't automatically assuming a / between the base and topic, but to no avail.

Worth mentioning, setting setpoints and modes via the web interface is working fine, and in that perspective, the PID controller is working just dandy, controlling my keezer and heating element, reporting the data back to MQTT topics, even got my iSpindel working in there too.

So with that, 2 questions: What dumbly obvious thing am I missing, and second, is there logging I can review on the device to see where I've gone wrong for myself?

Thanks!

vitotai commented 4 years ago

First of all, starting "/" is necessary. (I might add extra code to ensure that in next release.)

I ran out of ubidots credits. The only server I can test is CloudMQTT. It works great for me. Maybe, I say Maybe. Did you set "MQTT Remote Control" enabled to ON? The switch is at right most position, and sometimes I forget to check it.

jbishop129 commented 4 years ago

I tried adding the preceding / to each of the remote control endpoints, and verified the ON slider is selected, still same symptoms. I'm experiencing another issue that I now suspect is related; this is repeatable on multiple devices with the oled firmware at least - here's the steps to reproduce: In WebUI:

Workaround:

Workaround 2:

Worth reiterating: Now that I've navigated away from the Control tab, if I want to go set the temp setpoint higher/lower, or change a different mode (Beer Const, Fridge Const), I have to go thru the workarounds described above.

Hopefully not overly verbose here :) Any thoughts on this issue and if it is related to the MQTT issue?

vitotai commented 4 years ago

Please update too v4.0. It's easier for me.

The issue of "Invalid Temperature:68" has the same cause of "Not connected to controller". For some reason, the controller is not connected, and valid temperature range is not available, nor the temperature unit.

Please use chrome, open Javascript Console, and check the log.

jbishop129 commented 4 years ago

I don't find any v4.0 update, most current I find is 3.6r3; how can I upgrade?

vitotai commented 4 years ago

It's on another branch. https://github.com/vitotai/BrewPiLess/tree/4.0pre

jbishop129 commented 4 years ago

Thanks, I updated to BrewPiLess.v4.0a1.oled.newui.4m2m.bin successfully, and this resolved the UI issues described above. Unfortunately the MQTT remote control issues still persist; testing with every combination of prefixed / and not, both on the base and on the subscribed topics. Is there system logging I can look at, where it might show me something to the effect of precisely what topic it is subscribed to? Perhaps a way to see that in the serial monitor?

vitotai commented 4 years ago

What MQTT broker are you using? There are not many logs related to MQTT because it just worked without much testing.

jbishop129 commented 4 years ago

I'm using mosquitto. I run it as a container, working quite well for a few other IoT services. I'm running it without any auth requirements or TLS, so there shouldnt be any roadblocks in connectivity. I see BPL reporting all sensor data to the broker just fine, not sure why BPL doesn't seem to find the remote control cmds on the subscribe topic.

I wish there were a way to see in logging or serial monitor, exactly what topic BPL is monitoring, after applying config.

vitotai commented 4 years ago

Serial logging is enabled by adding "-DSerialDebug=true" to "build_flags". You can reference "esp8266dev" configuration.

shambolic94 commented 4 years ago

For what it's worth, I also run the BPL in Fahrenheit mode and have the exact same issue as the OP getting the "not connected to controller" and "invalid temperature" errors. The same workarounds work for me. In addition, I've discovered that if I re-enter the command for switching to Fahrenheit on the testcmd page, I can adjust temps for a short time without getting the error message.

Not sure if it's related, but I've also found that entry of OG and SG seems broken in Fahrenheit mode. I've found that to get "Gravity Data" to correctly display my OG or SG, I need to input a temperature of 138 degrees. I'm guessing it's not coincidental that 138°F = 59°C

I am running BrewPiLess.v4.0a1.thorrax.newui.4m2m.

shambolic94 commented 4 years ago

One more thing I forgot, which further suggests that this is an issue with fahrenheit mode: If I input a beer constant of "20," it will successfully set the BPL to 20°F (although I still get a "not connected to controller" error first).

So, in other words, it refuses to set a beer temp of 68°F (or other temps in that range) without using one of the various workarounds, but will happily set a beer temp of 20°F with no need for workarounds.

vitotai commented 4 years ago

The DEFAULT temperature unit and ranges are in Celsius. Setting temperature out of ranges will be rejected. If the browser does not connect to BPL correctly, which is the root cause as I mentioned, DEFAULT settings are applied.

Open the Javascript console to see what happens.

shambolic94 commented 4 years ago

Here is what the Javascript console shows when I navigate to the control.htm page:

image

vitotai commented 4 years ago

It is a bug revealed by timing issue. Will update later. (I need to study my code first.)

Update: just push updated 4.0a2.

shambolic94 commented 4 years ago

That seemed to fix it. Thanks!!

jbishop129 commented 4 years ago

+1 for the BrewPiLess.v4.0a2.oled.newui.4m2m.bin having fixed the described workarounds for setting the fridge setpoints, thanks!! Updating mode or setpoints via MQTT issue still persists. @shambolic94 any chance you use MQTT, and have the ability to test remote control functionality? If so and if working for you, I'd love to know precisely what your config is, and the topic(s) you publish to, controlling the BPL

vitotai commented 4 years ago

I've said that I used ubidots.com as illustrated in the document. Now I can only test on cloudmqtt.com.

shambolic94 commented 4 years ago

jbishop129, I have used ubidots in the past on previous builds and it worked great. I think I just followed the instructions in the documentation on github and it worked on first try. Just tried to re-enable it, and have found that the "submit" button on the logging screen in BPL no longer works. Console produces this error:
image

jbishop129 commented 4 years ago

@shambolic94 thanks for the feedback, and I also see this newly reported bug. I thought it was just me, but I noticed all MQTT settings are blanked out in the config, and submitting just zeros them all out again. MQTT is still reporting to the msg topics as I had it configured before the latest update, but it seems the ability to update has broken, and your console screenshot seems to show the culprit.

On Thu, Dec 26, 2019 at 8:06 AM shambolic94 notifications@github.com wrote:

jbishop129, I have used ubidots in the past on previous builds and it worked great. I think I just followed the instructions in the documentation on github and it worked on first try. Just tried to re-enable it, and have found that the "submit" button on the logging screen in BPL no longer works. Console produces this error: [image: image] https://user-images.githubusercontent.com/51866975/71480459-1e62fb80-27c7-11ea-81fa-bc0b26ec7b00.png

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/vitotai/BrewPiLess/issues/205?email_source=notifications&email_token=AGWTNKNGR5P2F5H7KM2YODLQ2TCABA5CNFSM4JY73Z42YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHVV4YI#issuecomment-569073249, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGWTNKL2ZNQM66XHE7PSNHDQ2TCABANCNFSM4JY73Z4Q .

vitotai commented 4 years ago

It seems like I messed up. Will fix when I have time.

Update: please try again.

konradmt commented 3 years ago

@jbishop129 Were you able to get temp updated via MQTT?

I have the same setup as you, except I'm using BPL 4.1: D1Mini 8266, MQTT running as a container inside HA.

I can change temps via web interface. When I send a MQTT message to change the temp, it gets reverted to what I set in the web interface.

jacyker commented 3 years ago

@konradmt Currently, control by MQTT does not work (stopped working after one of the "recent" 4+ updates). Eg. the sent temperature or mode goes to the MQTT channel, but after a while it is "overwritten" by the temperature or mode set by the WWW. I have recently reported: https://github.com/vitotai/BrewPiLess/issues/284

jalim commented 1 year ago

I haven't had any luck publishing commands via MQTT to Brewpiless, has this issue ever been resolved?