MQTT whirlpool control

Hello,

i want to control my whirlpool with mqtt and this project

I need 3 types of channels. 1. Read out value. I managed that. 2. value control and the current display. it can be controlled, but it does not read out the current value of the device, it only remembers what is controlled in openhab. 3. Set a value and display the current one. I can’t do that at all.
the mqtt commands are available at WiFi-remote-for-Bestway-Lay-Z-SPA/Build-instructions-Bestway-WiFi-remote.pdf at master · visualapproach/WiFi-remote-for-Bestway-Lay-Z-SPA · GitHub
described. can someone tell me how I can create this in the GUI?

Do you have a tool like mqtt.fx or mqtt spy? Just to get real data…

Yes. The string from e.g. “message” is:

{“CONTENT”:“STATES”,“LCK”:1,“PWR”:1,“UNT”:1,“AIR”:0,“GRN”:0,“RED”:0,“FLT”:1,“TGT”:30,“TMP”:24,“CH1”:32,“CH2”:50,“CH3”:52,“HJT”:1}

So you can get all informations to different Items by using JSONPATH transformation (i.e. define one channel with stateTopic BW_2.0.0/message

You need to build a Number Item for each value, then connect the Items to the channel and add a profile JSONPATH transformation with the key word, e.g. $.AIR for the bubbles.
You could also use the JSONPATH transformation within the channel, but you have to create more channels with the same stateTopic then.

{
    "CONTENT": "STATES",
    "LCK": 1,
    "PWR": 1,
    "UNT": 1,
    "AIR": 0,
    "GRN": 0,
    "RED": 0,
    "FLT": 1,
    "TGT": 30,
    "TMP": 24,
    "CH1": 32,
    "CH2": 50,
    "CH3": 52,
    "HJT": 1
}

HJT is not mentioned in the documentation.
This is the input part.:slight_smile:
For commands, I think it will be necessary to build a rule to create the JSON object.

The commands look a little tricky here. What I would do for BUBBLES, for example:

  • Create a Channel with the following settings:
    • Identifier: sSpaBubbles
    • Label: Spa Bubbles
    • Channel type: On/Off Switch
    • MQTT State Topic: BW_2.0.0/message
    • MQTT Command Topic: BW_2.0.0/command
    • Custom On/Open Value: 1
    • Custom Off/Closed Value: 0
    • Incoming Value Transformation: JSONPATH:$.AIR
    • Outgoing Value Format: {"CMD":2,"VALUE":%s,"XTIME":0,"INTERVAL":0}
The above, but in YAML in the UI
channels:
  - id: sSpaBubbles
    channelTypeUID: mqtt:switch
    label: Spa Bubbles
    description: ""
    configuration:
      commandTopic: BW_2.0.0/command
      formatBeforePublish: '{"CMD":2,"VALUE":%s,"XTIME":0,"INTERVAL":0}'
      stateTopic: BW_2.0.0/message
      transformationPattern: JSONPATH:$.AIR
      off: "0"
      on: "1"

The %s in the Outgoing Value Format is automatically filled in with ON or OFF once linked to a switch, and this is in turn transformed to either 1 or 0 respectively.

Note that it’s not quite clear to me whether CMD and VALUE and XTIME and INTERVAL need the double quote marks around it - the documentation doesn’t specify, but because the message string includes double quotes around the keys I’ve done the same!

You then link the Channel to an Switch Item of your creation.

With this:

  • When you flick the openHAB switch, openHAB will send the following to BW_2.0.0/command when flicking the switch ON:
{"CMD":2,"VALUE":1,"XTIME":0,"INTERVAL":0}

image

  • When you flick the openHAB switch, openHAB will send the following to BW_2.0.0/command when flicking the switch OFF:
{"CMD":2,"VALUE":0,"XTIME":0,"INTERVAL":0}

image

  • When your device sends the message, the openHAB switch will be updated with the current state of the air bubbles through the AIR value in the message.

This should get you going for now!

wow, thank you both! i’m testing this tonight after work. how can I then e.g. set a certain temperature?

EDIT: Now it works. I change the row in the code format “formatBeforePublish:” and now it looks like this:

But how can I send commands with numbers to set the temperature?

Now I tested your, but it sends only 1 or 0 to the MQTT device with this settings (I tested it with the pump):

As you’ve found, you used the wrong field for the JSON string.

It works now =) see the post further up.

The only thing missing now is to set the temperature with a number

Temperature is essentially the same deal, except use a Number Channel and Number Item instead. How you represent the Number Item in the UI is then up to you - maybe a slider?

Setting the temperature was really easy. Worked exactly like that. MANY THANKS. And yes, I installed it with a slider =)

I have one last think (I hope :D). The heater has two on states, RED for heating and GRN for standby, if the temperature is below the set temperature. How can I set this in “Incoming Value Transformation” ?

Edit: The absolute best where if the state is RED, the switch color is red and when the state us GRN the switch shows green =)

You will want a Switch Channel and Switch Item. Setup and configuration is the same as you’ve done before, but also add GRN into Custom Off/Closed Value and RED into Custom On/Open Value in the Switch Channel configuration.

I would recommend checking the documentation as you should now understand the basics of setting up MQTT stuff in openHAB.

This would be configured in whatever user interface you’re using. Check the documentation here.

I think you don’t understand what I want. GRN and RED are both on states. The documentation links are not helpful. I read that before I post here the first time, but I don’t unterstand it…. That’s the reason I asking for help here :frowning:
I use the basic ui.

You said:

which is as close as your going to get for ON and OFF. You also said:

which suggests you want a switch.

What I described is how to set this up with a Switch, as asked.

OK, perhaps try to explain it more clearly. Good luck!

Comment; multistate switch devices (off/low/med/high style) can be represented in openHAB as String type Items, where the string state is a selection of values.
An alternative is to represent by Number type (0-3 in our example) and MAP is a useful transformation to give numbers meaning.