LAB02-Research / HASS.Agent

Windows-based client for Home Assistant. Provides notifications, quick actions, commands, sensors and more.
https://hassagent.lab02-research.org
MIT License
1.55k stars 67 forks source link

Image display fails on dynamic URL #5

Closed brianhanifin closed 2 years ago

brianhanifin commented 2 years ago

First, this is nice. Thank you!

I would like to use this to popup a still image of the person at the front door. In my testing I found the following.

The following URL works:

http://homeassistant.local:8123/local/brian.jpg

While a dynamic URL pulled from the entity_picture attribute of a camera does not.

http://homeassistant.local:8123/api/camera_proxy/camera.doorbell?token=da875fe850053b881f2fd8636c73faf7a0fc99ec7e18feb6ee69be992bb4890a

FYI. in my script.notify_pc I use the variables: section to extract the dynamic URL.

variables:
  image: |
    {% set camera = camera %}
    {%- if camera != "" %}
      {%- set image = "http://homeassistant.local:8123" + state_attr(camera,"entity_picture") %}
    {% endif %}
    {{ image }}
LAB02-Admin commented 2 years ago

Hey Brian, thanks, glad you like it :)

I've transferred your issue to HASS.Agent, as that's where this is failing. I'll look into it and let you know!

LAB02-Admin commented 2 years ago

Looks like it's failing in two places, at least when I'm trying to reproduce this.

For starters, the script was sending an empty image variable. I had to change the variable part as following (specifically the quotes, I didn't use a camera variable):

  variables:
    image: |
      {%- set image = "http://homeassistant.local:8123" + state_attr("camera.garden","entity_picture") %}
      {{ image }}

Afterwards I did receive a working url on my pc.

Perhaps your script already works fine: you can check by looking in the HASS.Agent logs - if you installed using the installer, they'll be in %appdata%\LAB02 Research\HASS.Agent\Logs. If there are Error downloading image exceptions, the url came through. Otherwise, you need to change the script.

This still didn't show the image; HASS.Agent failed to download the image, it got confused by the dot in camera.name in the url.. Released a bugfix.

Let me know if this fixes it for you!

brianhanifin commented 2 years ago

Your update fixed it! Thank you! I love the idea of being able to see who is at the door without having to getting my phone out of my pocket when I'm at my PC!

LAB02-Admin commented 2 years ago

Great! Good to hear, that was also one of my main reasons for that function 😄

LAB02-Admin commented 2 years ago

Added your idea of using the proxy to the README file, thanks!