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

[Question] How to pass new line in a service variable? #31

Open
marek-vrana opened this issue Aug 22, 2023 · 0 comments
Open

[Question] How to pass new line in a service variable? #31

marek-vrana opened this issue Aug 22, 2023 · 0 comments

Comments

@marek-vrana
Copy link

when I declare custom service in esphome like this:

- service: send_command
  variables:
    cmd: string
  then:
    - lambda: "id(nspanel).send_custom_command(cmd.c_str());"

I'm able to pass new line in description {{'\r\n'}}

service: esphome.nspanel_send_command
data:
  cmd: >-
    entityUpdateDetail~id~~65535~~3840~~61440~{{'\r\n'}}Description~52457~0~3~~52457

Now I'd like to define a new service, so that a new line can be included in the passed variable:

- service: notify_fullscreen
  variables:
    description: string
  then:
    - lambda: |-
          id(nspanel).send_custom_command("pageType~popupNotify");
          std::string cmd = "entityUpdateDetail~id~~65535~~3840~~61440~" + description + "~52457~0~3~~52457";
          id(nspanel).send_custom_command(cmd.c_str());

My idea is to call it like this:

service: esphome.nspanel_notify_fullscreen
data:
  description: "{{'\r\n'}}Description"

But that either ignores a new line or shows the escaped characters.

Can anyone help me out finding a proper syntax for it? Workarounds, e.g. replace with another string, are also appreciated. It's driving me nuts, can't figure it out.

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

No branches or pull requests

1 participant