Rule acting on serial input

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
ostheer
New user
Posts: 2
Joined: 30 Apr 2020, 00:54

Rule acting on serial input

#1 Post by ostheer » 30 Apr 2020, 01:09

Hey all,

Shortly, my goal is to publish an MQTT message from my nodeMCU running ESPeasy upon receiving a message on the serial RX pin (from an Arduino). I'm attempting to do this by configuring a rule on the ESPeasy.
I've looked in these forums and in the official documentation(s), but I haven't been able to find the answer.

Closest forum post I could find was https://www.letscontrolit.com/forum/vie ... php?t=5478, but it doesn't explain fully how to get it running.
They use this rule:

Code: Select all

On Serial#myname do
publish home/ESP07/Alarm,[Serial#myname]
Endon
The documentation on https://espeasy.readthedocs.io/en/lates ... Rules.html says:

Code: Select all

on !Serial#T1018* do
  TaskValueSet 2,1,{strtol:16:{substring:13:15:%eventvalue%}}.{strtol:16:{substring:15:17:%eventvalue%}}*100/255
endon
but it isn't defined what "T1018" is.

I tried all possible combinations of turning on/off the serial server, different "on" statements, different serial input commands/messages, but to no avail. No MQTT messages are being published. (As a sanity check, the rules and mqtt config do work when I use an example rule with a timer).

Can anyone give me some basic steps I need to take to get this to work?
In particular, I have the following questions:
  • How should I formulate my "on" statement (and what does it syntactically mean)?
  • Should I turn on the Serial Server ("plugin")?
  • How/where is the serial communication set up (baud rate, stop bits, etc.)?
Thanks in advance!
Ostheer
Last edited by ostheer on 30 Apr 2020, 10:44, edited 1 time in total.

User avatar
ThomasB
Normal user
Posts: 1065
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Rule acting on serial input

#2 Post by ThomasB » 30 Apr 2020, 05:16

but it isn't defined what "T1018" is.
"T1018" is the leading characters of a serial message string that was sent to ser2net from a boiler controller. It's just a user's example that somehow found it's way into the Rule's documentation. Unfortunately the wording is very confusing to the casual reader due to poor editing.

But you don't need to use ser2net to pass values from the serial port to MQTT. Instead, a Dummy Device value can be set by the serial port and the Dummy's value can be used by your rules. See this discussion: https://www.letscontrolit.com/forum/vie ... php?t=6443

Keep in mind that if the Arduino is connected to the serial port then it can send any valid system command to ESPEasy. Here is the list of supported commands: https://www.letscontrolit.com/wiki/inde ... _Reference

- Thomas

User avatar
ostheer
New user
Posts: 2
Joined: 30 Apr 2020, 00:54

Re: Rule acting on serial input

#3 Post by ostheer » 05 May 2020, 12:53

Hey Thomas,

Thanks for your reply. I sort of get what you mean, I think. However, I don't see any evidence of any rules triggering when I send serial data containing the appropriate keyword.
Luckily, your final point revealed that what I want can indeed be achieved much simpler, just sending "publish X" from the Arduino directly. Thanks! Somehow I overlooked that command, though I had used the same approach to control a servo before.

Ostheer

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 138 guests