Canvia digital picture frame - REST API request to integrate into HA

Hy home assistant ninjas,

I own a Canvia Picture Frame from the initial kickstarter campaign. The canvia is a similar device like the meural from Netgear which has a custom integration. The Canvia unfortunatelly has not. I want to integrate the canvia into HA.

I was able to reverse engineer some of the REST API calls … and I must admit I am new to this level of coding.

However … I can already select next/prev picture with these calls:

rest:
  - scan_interval: 360
    resource: http://canvia.ip/commands/get-current-image
    sensor:
      - name: Canvia Title
        value_template: "{{ value_json.title }}"

rest_command:
  canvia_next:
    url: http://canvia.ip/commands/next
    method: POST
  canvia_previous:
    url: http://canvia.ip/commands/previous
    method: POST

Additionally with postman I am able to toggle a setting (show plate with picture information).


Via postman works like a charm. Howerver with HA yaml it does not work.

  # none/partial/full
  canvia_overlay_mode:
    url: http://canvia.ip/commands/overlay-mode
    method: POST
    payload: '{"mode":"{{ mode }}"}' # none/full/partial

and the respective service call

service: rest_command.canvia_overlay_mode
data:
  mode: none

the display mode won’t turn off. I would appretiate some hints how to get this going.

I tried a similar approach for toggling the screen on/off via a REST switch without success.

switch:
  - platform: rest
    name: "Canvia"
    resource: http://canvia.ip/commands/do_sleep
    state_resource: http://canvia.ip/commands/do_sleep
    body_on: '{ "do_sleep": "false" }'
    body_off: '{ "do_sleep": "true" }'
    is_on_template: '{{ value_json.do_sleep == "false" }}'
    headers:
      Content-Type: application/json

I suspect the content length header … bc if I turn this off in postman … the call from postman is not successful either.

I dont know enough yet to further debug this and hope someone in the community has more knowledge and could help out.

At the end I would like to see a custom component similar like the one available for Meural.

Regards.
Ralf

Integrating a device like the Canvia Picture Frame into Home Assistant (HA) can be an exciting but challenging task, especially when you’re new to this level of coding. Since you’ve successfully reverse-engineered some of the REST API calls for the Canvia Picture Frame, you’re already on the right track. To integrate it into HA, you’ll need to create a custom component or use existing HA functionalities like RESTful commands or scripts. Here’s a basic guideline on how you can proceed:

  1. Understand the REST API: Ensure you have a good understanding of the REST API calls for the Canvia Picture Frame, including the endpoints for different actions (like next/previous picture), the required request method (GET, POST, etc.), and any necessary headers or payload.
  2. Test the API Calls: Before integrating with HA, test the API calls independently using tools like Postman or a Python script to ensure they work as expected.
  3. Create RESTful Commands in HA: HA has support for creating RESTful commands. You can define these commands in your configuration.yaml or through the UI under Configuration → Scripts. Here’s an example of how you might set up a REST command for the next picture:

Hello Ralf,

I go the same target and tried out you code. For me the following code worked out:

rest_command:
  canvia_next:
    url: "http://canvia.ip/commands/next"
    method: POST
  canvia_previous:
    url: "http://canvia.ip/commands/previous"
    method: POST
  canvia_flush_queue:
    url: "http://canvia.ip/commands/flush_queue"
    method: POST
  canvia_sleep:
    url: "http://canvia.ip/commands/do_sleep"
    method: POST
    content_type: "application/x-www-form-urlencoded"
    payload: "do_sleep=true"
  canvia_wakeup:
    url: "http://canvia.ip/commands/do_sleep"
    method: POST
    content_type: "application/x-www-form-urlencoded"
    payload: "do_sleep=false"
  canvia_overlay_full:
    url: "http://canvia.ip/commands/overlay-mode"
    method: POST
    content_type: "application/x-www-form-urlencoded"
    payload: "mode=full"
  canvia_overlay_none:
    url: "http://canvia.ip/commands/overlay-mode"
    method: POST
    content_type: "application/x-www-form-urlencoded"
    payload: "mode=none"
  canvia_overlay_partial:
    url: "http://canvia.ip/commands/overlay-mode"
    method: POST
    content_type: "application/x-www-form-urlencoded"
    payload: "mode=partial"

Instead of postman I’m working with PacketSender.
So check your content type, that it is fitting to your payload.

Reverse-engineering for the win :slight_smile:

I’m also new to HA, so feedback is welcome.

Hope it works for you too.

Best regards