Trying to call Epaper HA service from Node-Red, getting error

I know this is probably something simple but I’m stuck.

I’ve installed the HACS OpenEpaper add-on GitHub - jonasniesner/open_epaper_link_homeassistant: Home assistant Integration for the OpenEPaperLink project

I’m trying to call the service from Node-red using call service using web socket.

Calling the service from the HA dev page works:
Screenshot 2023-12-10 at 12.05.56 PM
Calling it from Node-Red doesn’t, here’s the code.

Screenshot 2023-12-10 at 12.08.00 PM

In the Node Red debug, I see:
“TypeError: string indices must be integers, not ‘str’”

In the HA log, I see:

File “/config/custom_components/open_epaper_link/imagegen.py”, line 94, in customimage

_LOGGER.info("type: " + element[“type”])

" ~~~~~~~^^^^^^^^"
TypeError: string indices must be integers, not ‘str’

What am I doing wrong?

Try running your working yaml through a yaml to json converter. Payload looks to be an array of objects not just an object.

This is kind of so obvious I must be missing something, however

your YAML has x, y and size as a number
your JSON has x, y, and size as a string (“40” is a string, 40 is a number)

your error message says (paraphrase)

Type Error - things that you are sending as strings should be integers

“rotate”: 90 must be working, why not try

“x”: 0,
“y”: 0,
“size”: 40

and yes, as Kermit says, payload is an array of objects.

https://onlineyamltools.com/convert-yaml-to-json

YAML works out that anything starting with a number is a number, otherwise it must be a string - thus 40 ends up as a number but a40 ends up as a string, and hence YAML does not need quotes around strings (unless you actually want 40 to be a string)

That’s got it!
The array was the silly thing I’d missed.
I ran the demo code through the YAML to JSON converter and that showed where should have gone.
Thank you!

A different error, but I’m really struggling to make OpenEpaperLink work in Node-RED.

Example calls that I make via HA’s Developer Tools / Services work just as expected. But I’m getting some kind of strange error when using the same data and Call Service in Node-RED.

Looking into HA log files, it looks like the entity_id for the target tag is getting truncated somehow to only the first character. The same thing happens even when I externally populate the required fields in a function node and send that message to the Call Service node instead.

@skywise - would you be able to post a screenshot of how you populated the Call Service node for your project? I just want to make sure I’m not missing something obvious.

Update - posting for anyone who stumbles across this in a search.

Well, versus any other call service that I’ve used, this is really weird.

But here’s the working config (This was for the Lines4 demo and uses that demo data too):

For entities, the target tag needs to be specified (something like “open_epaper_link.0000021f7dd43b16”). But you also need to specify a mystery entity that’s actually the AP display itself (similar format as the target tag).

I have no why it works this way in Node-RED. The AP display does not need to be specified in HA when using the Developer Tools / Services form. But it does in Node-RED. Like I said, really weird.

But now it works I can move on to more fun stuff!