home-assistant / home-assistant-js-websocket

:aerial_tramway: JavaScript websocket client for Home Assistant

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Raw message possible to read media image?

RonnyWinkler opened this issue · comments

Hi,
I tried to use the raw message to retrieve the media thumbnail for a media player entity.

connection.sendMessagePromise(
  {
    "id": 19,
    "type": "media_player_thumbnail",
    "key": this.entityId
  }
)

I got only an error message "unknown command" as result.
Isn't it possible to use the messages from this documentation?
https://developers.home-assistant.io/docs/api/websocket#fetching-media-player-thumbnails
Or am I doing something wrong (parameters)?

A simple ping was also not working with this function. But there is a dedicated function for the connection to send a ping message.
Is a dedicated function also needed for media thumbnails?

Thanks for any hint.
Ronny

That method was removed as it was blocking the whole websocket, hurting performance.

Your method of calling is correct, although you should drop the message ID, it's automatically handled for you.

Thanks for your answer. I tried again with the sendMessagePromise function but got an error again.

Function call:
let result = await this._connection.sendMessagePromise(message);

Parameter:

        {
            "type": "media_player_thumbnail",
            "key": this.entityId
        }

Result:
grafik

The entity itself has image references.
grafik

Is the function dependent on the entity/integration and the entity/integration must support the image reading? Or is that a core functionality.

That method was removed as it was blocking the whole websocket, hurting performance.

Oh, did you mean the "type": "media_player_thumbnail" was removed completely from HA side? Or just the wrapper function in the npm module?

I figured out that the media player has an attribute with local image URL, that can be used to read the image via http using the HA server IP:port.
I'll go this way :)