Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SendTo] add ability to nest one SendTo command into another #5232

Open
wants to merge 2 commits into
base: mega
Choose a base branch
from

Conversation

chromoxdor
Copy link
Contributor

See here:
https://www.letscontrolit.com/forum/viewtopic.php?p=67939

I admit it is a bit of a hack and probably not the most intuitive approach, but first of all it works and it does so with the least amount of additional code.

example command: SendTo,8,'SendTo,9,"taskvalueset,5,1,|Plugin#GPIO#Pinstate#16]"'

@TD-er
Copy link
Member

TD-er commented Jan 27, 2025

This will break the 'default argument' operator.
See: https://espeasy.readthedocs.io/en/latest/Rules/Rules.html#examples

on eventvalues* do
  logentry,"Not existing eventvalue: %eventvalue10|NaN%"
endon

@TD-er
Copy link
Member

TD-er commented Jan 27, 2025

If you need to do stuff like that, I suggest you add some rule on the other node and then send an event on what to do with it.

I guess we could add some escape token at some point, but that will still lead to issues as it needs to know in advance how many 'hops' are required and thus how many levels of escape.

@chromoxdor
Copy link
Contributor Author

chromoxdor commented Jan 27, 2025

https://espeasy.readthedocs.io/en/latest/Rules/Rules.html#examples

S**t.. i totally forgot about this. Can i go with this?: §

@TD-er
Copy link
Member

TD-er commented Jan 27, 2025

https://espeasy.readthedocs.io/en/latest/Rules/Rules.html#examples

S**t.. i totally forgot about this. Can i go with this?: §

Nope, as that's a totally unintuitive character.

Better look into adding a \ to the square brackets and then let those be replaced when receiving the command via p2p

  • \[ and \]
  • \%

Maybe others too.

@chromoxdor
Copy link
Contributor Author

If you need to do stuff like that, I suggest you add some rule on the other node and then send an event on what to do with it.

true... but it is for easyfetch. Where i could simply add a button (e.g. SwitchRoom1&5G12) where 5 is the node number and 12 the GPIO. It sends then a GPIOToggle,12 and also does poll the pinstate constantly. I wouldn`t be necessary anymore to put extra code on the remote node.

@chromoxdor
Copy link
Contributor Author

chromoxdor commented Jan 27, 2025

Better look into adding a \ to the square brackets and then let those be replaced when receiving the command via p2p

I was also thinking about adding something like \ or | at the beginning of the argument to prevent parsing of the whole line...

@TD-er
Copy link
Member

TD-er commented Jan 27, 2025

Still I wonder how intuitive it is to setup as ESPEasyFetch must know about node 9 and 8 in your example.
So why not directly send it to that node via a command?

I was also thinking about adding something like \ or | at the beginning of the
argument to prevent parsing of the whole line...

A bit like a separate quote type which is then used by the parser to consider that block to be parsed already and just remove those quotes?

@chromoxdor
Copy link
Contributor Author

chromoxdor commented Jan 27, 2025

Still I wonder how intuitive it is to setup as ESPEasyFetch must know about node 9 and 8 in your example.
So why not directly send it to that node via a command?

SendTo,8,'SendTo,9,"taskvalueset,5,1,|Plugin#GPIO#Pinstate#16]"'

In this example we are on node 9 sending a gpiotoggle,16 to node 8.
Then node 9 wants to know the state of GPIO16 on node 8 in order to colour the button depending on that state.
To do this, easyfetch constantly asks node 8 in the background to send it's pinstate to node 9.
So no code is needed on node 8.
This makes easyfetch much easier to use and set up.

A bit like a separate quote type which is then used by the parser to consider that block to be parsed already and just remove those quotes?

Maybe, yes... but I realise that any other approach adds a lot more code, which I wanted to avoid to keep the changes for easyfetch as small as possible.

Edit: I am already using this on easy2ntfy since the there is no nesting necessary as there is the gateway to ask the nodes

@tonhuisman
Copy link
Contributor

We recently added an escape character to postpone variable expansion in #5097
Are you trying to solve the same challenge here?

@chromoxdor
Copy link
Contributor Author

Are you trying to solve the same challenge here?

Exactly ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants