Nodered and ewpe-smart-mqtt

Hi there!

Very noob question, I'm trying to use my air conditioner with MQTT broker in nodered, but have no idea how to configure it to just send a setting.

According to the readme, I need to address a topic, in mqtt out, but have no idea how exactly it needs to look like, if lets say I want to inject a power-on and temp unit together.

Could someone share an example?

I started as it suggested in the readme, so the topic is ewpe-smart in the mqtt broker.

THX!

Looks like you first have to determine the device id;

inject node -> mqtt out (properly configured for your broker)
in the inject node, set topic to ewpe-smart/devices/list

mqtt-in node (select the same broker), set topic to ewpe-smart/# -> debug node

Deploy, click the inject node, watch the debug output, it will show you the device id (i would hope)

To turn it on/set temp:

inject node, set topic to ewpe-smart/{deviceId}/set, payload to json {"Pow": 1, "SetTem": 24}-> mqtt out
change the device id from the initial debug output

eg

Thanks for your quick answer, I can not even get devices list...

Most useful tool for mqtt i found is mqtt explorer, then you can see what is actually being published on the broker, this makes it also easy to determine what values are available and you can immediately see the device id (if the device is publishing).

Finally I was able to tinker it to work with the inject node. Thanks for your help, at the end, didnt need the mqtt explorer!

Last question, I've never used JSON as a function.

I don't want to "inject" the action ("pow":0 etc etc), I would like to use a function node, which will be triggered by something (like daytime, after 22:00, shut off etc).

So the question is how does a JSON look like in a function node so that mqtt understands it the same way?

in a function node, something like this:

topic = 'ewpe-smart/deviceId/set'
return {topic:topic, payload:{"Pow": 1, "SetTem": 24}};

mqtt requires the topic (if not set in the mqtt node itself)

note that the inject could be helpful for your needs, as it can schedule to inject at a specific time as well

Yes, and now the fun thing starts. You can bring in a lot of other nice conditions when to turn on/off and what temperature to set

  • house is empty & the home alarm system is armed
  • presence detection, you just arrived or left home (most likely overkill)
  • vacation mode, you and your family is away for a period
  • electricity costs, might be cheaper avoiding peak hours if possible
    etc etc

Thank you very much bakman2 :slight_smile:

Well, I already configured my tv, hue lights, and pc to shut off if i left home, now I only need to add some nodes :slight_smile: But yeah, its actually fun, and comfortable as fk :smiley:

I'm a bit stuck, I don't know if you can also help me out with this.

I set up a scene, look the following:

Basically, first part gets current temperature, every 5 minutes, it converts from kelvin to c, than rounds it, and creates a global value, namely TempValue, again, as a global value.

2nd part is looping every 5 minutes, and sets diff strongness of cooling for 3 diff temperatures.

Ofc the problem is, that it literally sets the air conditioner every 5 minutes, making it "BEEP" every 5 minutes.

So I guess the cleverest thing would be, if I could achieve that it only sends MQTT to the air conditioner, IF the global value (named TempValue) changes.

BTW, every "inject" node at the start of each flow, will be diff, I think I will make the temperature part a !start one, its not that much of calculations, it can start as nodered starts, and just keep going.

In the Air cond. part, I will make join (joao) message recieving flow starters, based on my connection to my wifi with my phone (tasker on android-- > if im connected, send message to nodered, and it starts the air conditioning flow, thats similar to what I do with my lights).

How could I achieve a flow, that starts ONLY if it got the join (joao) messsage, AND the global value changed?

Thank you guys!

well look at the RBE node - it will only send output if the input is a different value.

Can i suggest two things here

  1. Give your variables memorable names - TempValue - will confuse you no end in about six months !! Maybe something like TargetAirconTemperature or CurrentAirconTemperature etc

  2. Read the intro at the top of the forum about how to paste a flow into the system so we can actually see what it is doing (rather than a graphic shot)

  3. I would use the RBE node to only trigger on changes to the variable

Craig

Thanks for the reply man, but the TempValue is only the value I get from openwathermap, if I will use a temp sensor (which i just might some time), I can name that temperature value TempSensorValue, so it's ok.

I can import the flow no problem.

So once again, I have 3 distinct value ranges I want the AC to react to
between 21-25, 26-30, 31-35 celsiuses.

I want the flow to continue ONLY if it reaches 21, or 26, or 31, but do NOTHING (dont send mqtt push) if its still within their own respected ranges.

flowsac.json (18.5 KB)

The RBE node will not help you much in this case. It will send the value even for smallest changes so you will notice no difference. So what I suggest is that you write the filtering in the previous function node you already have in place. Hint: use a javascript switch statement

And then you need to save what "range" you are in so that when the next temperature value arrives, you have something to compare with. If you are still in the same range, don't send a command. Hint: use context to save the range variable

I would suggest using the smooth node - and average it over (say 10) readings - this will stop hystersis and should mean you will not be jumping around

So feed the incoming temp into a smooth node, then from there into a switch node - have the switch node test on the ranges you are interested in and send that out to RBE nodes. Have a look at the below

[{"id":"807888c6.ed5a78","type":"inject","z":"4988251a.07771c","name":"Imaginary Temperature","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"21","payloadType":"num","x":240,"y":80,"wires":[["6cb9b920.48c1f8"]]},{"id":"71e6163e.dd4528","type":"inject","z":"4988251a.07771c","name":"Imaginary Temperature","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"21","payloadType":"num","x":240,"y":180,"wires":[["6cb9b920.48c1f8"]]},{"id":"9285636b.25636","type":"inject","z":"4988251a.07771c","name":"Imaginary Temperature","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"21","payloadType":"num","x":240,"y":120,"wires":[["6cb9b920.48c1f8"]]},{"id":"6cb9b920.48c1f8","type":"smooth","z":"4988251a.07771c","name":"Average Temp","property":"payload","action":"mean","count":"10","round":"0","mult":"single","reduce":false,"x":550,"y":120,"wires":[["4851bcde.92eed4"]]},{"id":"4851bcde.92eed4","type":"switch","z":"4988251a.07771c","name":"test for range","property":"payload","propertyType":"msg","rules":[{"t":"btwn","v":"21","vt":"num","v2":"25","v2t":"num"},{"t":"btwn","v":"26","vt":"num","v2":"30","v2t":"num"},{"t":"btwn","v":"27","vt":"num","v2":"31","v2t":"num"}],"checkall":"true","repair":false,"outputs":3,"x":800,"y":120,"wires":[["4c35c53a.24312c"],["662581ab.5079b"],["e916ccec.bff"]]},{"id":"4c35c53a.24312c","type":"change","z":"4988251a.07771c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1050,"y":100,"wires":[["f214e6fa.5dc348"]]},{"id":"662581ab.5079b","type":"change","z":"4988251a.07771c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1060,"y":160,"wires":[["f214e6fa.5dc348"]]},{"id":"e916ccec.bff","type":"change","z":"4988251a.07771c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1060,"y":220,"wires":[["f214e6fa.5dc348"]]},{"id":"f214e6fa.5dc348","type":"rbe","z":"4988251a.07771c","name":"send on change","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":1310,"y":140,"wires":[[]]}]

Craig

Thanks for the suggestion of the smooth node, taking an avarage, but thats no good, not by logical thinking...
I've set temperature getting to get it every 5 minutes.
This smooth node gets 10 value in an hour.
If temperature doesn't change, than it gets lets say, 10 times 27 degrees.
If it was 27 degrees BEFORE the 10 times, it still sends the mqtt to the ac for no reason, since the temp didnt change
It actually would only delay everything

Maybe something like this

[{"id":"5d5764c0.ddc3ec","type":"inject","z":"846d7832.3348c8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":1040,"wires":[["ba5e4729.ec9608"]]},{"id":"ba5e4729.ec9608","type":"random","z":"846d7832.3348c8","name":"","low":"15","high":"40","inte":"true","property":"payload","x":310,"y":1040,"wires":[["24ebfcb.8d90504","c3ed07e8.9a5728"]]},{"id":"24ebfcb.8d90504","type":"switch","z":"846d7832.3348c8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"21","vt":"num"},{"t":"lt","v":"26","vt":"num"},{"t":"lt","v":"31","vt":"num"},{"t":"lt","v":"36","vt":"num"},{"t":"else"}],"checkall":"false","repair":false,"outputs":5,"x":170,"y":1200,"wires":[["3751ee54.1dabc2"],["9de35c4c.4a0de"],["d1ad55e2.d351d8"],["dcc149b8.2c88b8"],["2e1c1adf.393426"]]},{"id":"c3ed07e8.9a5728","type":"debug","z":"846d7832.3348c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":570,"y":1040,"wires":[]},{"id":"9de35c4c.4a0de","type":"change","z":"846d7832.3348c8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"low","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":1160,"wires":[["ef39cce1.39875"]]},{"id":"d1ad55e2.d351d8","type":"change","z":"846d7832.3348c8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"medium","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":1200,"wires":[["ef39cce1.39875"]]},{"id":"dcc149b8.2c88b8","type":"change","z":"846d7832.3348c8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"high","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":1240,"wires":[["ef39cce1.39875"]]},{"id":"3751ee54.1dabc2","type":"change","z":"846d7832.3348c8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"very low","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":1120,"wires":[["ef39cce1.39875"]]},{"id":"2e1c1adf.393426","type":"change","z":"846d7832.3348c8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"very high","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":1280,"wires":[["ef39cce1.39875"]]},{"id":"ef39cce1.39875","type":"rbe","z":"846d7832.3348c8","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":570,"y":1120,"wires":[["6af50dd3.46b394"]]},{"id":"6af50dd3.46b394","type":"debug","z":"846d7832.3348c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":1180,"wires":[]}]

Yeah this is what I was thinking about, to group them by the ranges, than the rbe can distinct and stop the flow, if it's not in a different range.
This is ofc working, but doesn't consider what happens, if I turn on the AC after a long time, and the temp matches the range it was before.

So what I need to do, is create a seperate flow, without looping, just a 1time startup loop, which is the same without the rbe, that runs, turns accordingly the ac. But at the same time, when that flow starts, another starts with the rbe, and with the loop.

This way, it surely starts, then only does the loop with the rbe, and only changes if value is different.

Just in case I will upload this scene of flows, in case others would like to look at it.

I'm controlling it with Join recieve for flow starts: It sends "turnon" message from my phone when it connects to home wifi, and "turnoff" when I disconnect from wifi and I'm outside of Autolocation Geofence Home, just in case I'm still home, but wifi doesn't work.
Also, it sends a Join message to my phone whenever it changes AC settings (low to high or anything), which triggers a short speaker readout with google voice "AC set to low/medium/high".

flowacv1.json (23.1 KB)

Nope not quite - with the RBE node it would not send anything to the AC because the value being passed to it had not changed - thats why i put the change nodes in there based on the range - but you are correct this is to maintain temperature - not when you first turn on and try to reach a temperature

Craig