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

Feature: notification library change to Windows APP SDK / misc. improvements&features #18

Open
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

amadeo-alex
Copy link

@amadeo-alex amadeo-alex commented Jul 24, 2023

This PR:

  • Mainly: replaces UWP.Toolkit library which was used to handle Windows Notifications with Windows APP SDK.
    • adds proper handling of notifications activated when HASS.Agent is not running
    • expands on the unfinished "user input" feature
  • changes StorageManager
    • to return unchanged URI when it starts with "file://" - notification library handles it correctly (for example file:///C:/Users/Amadeo/Desktop/temp/sumCat.jpg)
    • to use stored HA token for bearer authentication when requested resource is on the same domain as HA
  • adds an option to treat the "URI" elements of "notification action" just like Android Compantion App does - open them in the browser (default or configured one)
  • expands on the "Test Notification" so that it includes an image, buttons & input box
    • currently the image links to license free cat picture, might be worth moving it to some HASS.Agent domain
  • adds a note during onboarding regarding HA API "admin token" requirement for actionable notification functionaly (otherwise it ends up with Login attempt or request with invalid authentication from HOSTNAME (IPADDRESS). Requested URL: '/api/events/hass_agent_notifications'. (None) error in HA)
  • changes how log filename is generated (strange strings like multiple "-" characters caused it to be malformed)

Reason for the library change is the M$ recommendation when "registry issues" occur with UWP Toolkit, apparently they do not plan on tackling the issue (microsoft/microsoft-ui-xaml#5689)

Should remediate/fix following issues:

Due to Windows APP SDK shipping with it's own WebView2 instead of making it a nuget dependency (microsoft/microsoft-ui-xaml#5689), the WebView2 which we originally used needs to be wrapped in an alias.

@LAB02-Admin Windows APP SDK requires installation of an additional user facing appx package - https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/downloads. Should this be included as part of the installation application?
If it is not installed, user is prompted with following message during HASS.Agent launch:
obraz
Clicking on "Yes" redirects to the download page mentioned above.

Appx packages before and after installation:
obraz


Additional notification settings regarding URI (defaults to false to maintain backwards compatibility):
obraz

Example of notification, where clicking "Open URI" will open a site with cat pics:

service: notify.amadeo_pc
data:
  title: Test
  message: This is an actionable test message.
  data:
    actions:
      - action: "yes"
        title: "Yes"
      - action: "no"
        title: "No"
      - action: "openuri"
        title: "Open URI"
        uri: "https://www.cat-lovers-only.com"
    inputs:
      - id: testId
        text: testText
        title: testTitle

New test notification:

UsyW0r


Regarding the miscellaneous "user input", it works exactly the same as button options.
Example, this HA service call

service: notify.amadeo_pc
data:
  title: Some msg title
  message: Test msg
  data:
    image: >-
      https://smea.uw.edu/wp-content/uploads/sites/11/2017/03/CURRENTSBLOG_Cat_2.jpg
    actions:
      - action: "yes"
        title: "Yes"
      - action: "no"
        title: "No"
    inputs:
      - id: testId
        text: testText
        title: testTitle

produces following notification on my machine
obraz

If at the same time following automation is configured within HA

alias: HASS Notification test
description: ""
trigger:
  - platform: event
    event_type: hass_agent_notifications
    event_data:
      action: "yes"
condition: []
action:
  - service: notify.amadeo_pc
    data:
      message: "{{ trigger.event.data.input.testId }}"
      title: Action Response
mode: single

filling in text box with "SomeAwesomeText" and clicking "Yes", causes following new notification to appear
obraz

@LAB02-Admin this certainly would require adjustments in the documentation, I'll gladly do them but I couldn't find the repository :D

@amadeo-alex amadeo-alex changed the title Feature: notification library change to Windows APP SDK / User input support Feature: notification library change to Windows APP SDK / user input support / activation when HASS.Agent is not running Jul 24, 2023
@amadeo-alex amadeo-alex marked this pull request as ready for review July 24, 2023 17:24
@amadeo-alex
Copy link
Author

amadeo-alex commented Jul 24, 2023

On hold until LAB02-Research/HASS.Agent#278 is implemented.
Done.

@amadeo-alex
Copy link
Author

amadeo-alex commented Jul 24, 2023

Again, on hold until LAB02-Research/HASS.Agent#306 is implemented.
Done.

@amadeo-alex amadeo-alex changed the title Feature: notification library change to Windows APP SDK / user input support / activation when HASS.Agent is not running Feature: notification library change to Windows APP SDK / misc. improvements&features Jul 25, 2023
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

Successfully merging this pull request may close these issues.

1 participant