BrewPiLess icon indicating copy to clipboard operation
BrewPiLess copied to clipboard

MQTT Remote Control

Open jbishop129 opened this issue 5 years ago • 24 comments

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!

jbishop129 avatar Dec 10 '19 15:12 jbishop129

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.

vitotai avatar Dec 11 '19 01:12 vitotai

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:

  • Go to Control tab
    • select either Beer Const, Fridge Const tabs
    • enter a temperature set point, for example 68 (reminder: I'm running in Fahrenheit mode)
    • click Apply
    • Error! I get a pop-up: Not connected to controller
    • second popup: Invalid Temperature:68

Workaround:

  • Go to Beer Profile tab
  • Apply whatever profile is in there, doesn't seem to matter what it is
  • Error! same pop-up: Not connected to controller
  • second pop-up asking for Original Gravity, defaulted to 1.0.
    • click either OK, just Go or Set OG, and Go !! Without changing to any other tab in the UI, staying on the Control tab !!
  • Now go to either Beer Const or Fridge Const
  • The 68 temp I tried to set earlier is already populated
  • Click Apply -- Success! Navigating back to the Graph tab, i see it is in the desired mode, at the right temp setpoint, and the controller does its' job properly from there.

Workaround 2:

  • Same as above, but set the mode to Off
  • When clicking Apply in the Off mode, it pops up the same: Not connected to controller, however it does actually set the mode to Off successfully regardless of this msg.
  • Now I can navigate to either Beer Const or Fridge Const, set a temp, and successfully apply it. Again, you must not navigate out of the Control section of the UI after setting Off mode and before applying a temp in Beer/Fridge Const modes, or it wont take.

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?

jbishop129 avatar Dec 11 '19 14:12 jbishop129

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.

vitotai avatar Dec 12 '19 02:12 vitotai

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

jbishop129 avatar Dec 12 '19 14:12 jbishop129

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

vitotai avatar Dec 12 '19 14:12 vitotai

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?

jbishop129 avatar Dec 12 '19 16:12 jbishop129

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

vitotai avatar Dec 13 '19 15:12 vitotai

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.

jbishop129 avatar Dec 13 '19 15:12 jbishop129

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

vitotai avatar Dec 13 '19 16:12 vitotai

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 avatar Dec 14 '19 20:12 shambolic94

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.

shambolic94 avatar Dec 14 '19 20:12 shambolic94

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.

vitotai avatar Dec 18 '19 01:12 vitotai

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

image

shambolic94 avatar Dec 18 '19 01:12 shambolic94

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

Update: just push updated 4.0a2.

vitotai avatar Dec 18 '19 02:12 vitotai

That seemed to fix it. Thanks!!

shambolic94 avatar Dec 19 '19 04:12 shambolic94

+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

jbishop129 avatar Dec 20 '19 22:12 jbishop129

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

vitotai avatar Dec 23 '19 04:12 vitotai

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

shambolic94 avatar Dec 26 '19 15:12 shambolic94

@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 [email protected] 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 .

jbishop129 avatar Dec 26 '19 15:12 jbishop129

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

Update: please try again.

vitotai avatar Dec 27 '19 09:12 vitotai

@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.

konradmt avatar Jan 18 '21 04:01 konradmt

@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

jacyker avatar Jan 18 '21 06:01 jacyker

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

jalim avatar May 20 '23 06:05 jalim