sleevezipper / hass-workstation-service

Provide useful sensors and services from your workstation to Home Assistant.
Apache License 2.0
617 stars 53 forks source link

Feature Request: Send Windows Notification #50

Open felix-schreib opened 3 years ago

felix-schreib commented 3 years ago

Hi, it would be pretty cool if you could send notifications to Windows 10 (similar to IOT Link) Me idea is that you could make an automation which would notify the user if eg. the door is open for 5min. Rightnow I have them send via telegram but id rather have them in the Windows 10 Notifications. Thanks

sleevezipper commented 3 years ago

Hi! Thanks for creating an issue.

I spent some time on this before and couldn't get into work without without some big changes. Would it be a problem for you it was implemented outside of the Windows 10 notification center?

felix-schreib commented 3 years ago

As a workaround I just came up with a customcommand msg * "Hello World" This basically accomplishes what I want, but the notification itself doesn`t "look" that nice so I thought the notification center would be nice. But if that is a big effort its definitely not a big issue to have it in some other way or outside of the notification center.

vidvisionify commented 3 years ago

I haven't gotten around to it, but I did wonder if this could be done with a combination of customcommand and AutoHotKey https://www.autohotkey.com/docs/commands/TrayTip.htm

sleevezipper commented 3 years ago

As a workaround I just came up with a customcommand msg * "Hello World"

That's actually pretty cool!

@vidvisionify I'm not sure if AutoHotKey can be called from the outside but it would be a nice workaround.

mdrichardson commented 3 years ago

As an addendum to this, it would be great if you could selectively set persistent notifications and/or always-on-top. My personal use case is that my wife and I share an office. I'd like to install this on both of our machines and have a small persistent notification when she's in a meeting and/or headphones are in use.

I could see others using something like this to create some kind of small monitoring dashboard.

MrKuenning commented 3 years ago

As an addendum to this, it would be great if you could selectively set persistent notifications and/or always-on-top. My personal use case is that my wife and I share an office. I'd like to install this on both of our machines and have a small persistent notification when she's in a meeting and/or headphones are in use.

I could see others using something like this to create some kind of small monitoring dashboard.

My solution to this was to create an automation that captures the current status of a light in a scene and then change that light to red while my webcam is on and restore the scene when my camera turns off. In my case its just one of the ceiling lights in the corner of the room. It works great as an "ON AIR" for anyone else. And the scenes help put everything back when I am done.

I use the same method to set my lighting correct for meetings while my camera is on. Such as my nano lights being too bright behind me. It then restores once my webcam is turned off.

thelefty commented 3 years ago

This would be an incredibly useful feature. My use case would be a little different. Sometimes my wife is trying to get a hold of me and I have my headphones on and don't look at my phone. A windows notifications would be awesome. Or even notifications in general - like someone at the door.

fabsenet commented 3 years ago

we have a home theater pc running windows and I see 2 use cases around our children watching stuff there. both would need some kind of overlay. "it is 9 o'clock, please turn off!" or "you used up your watchtime, please turn off"

it would need to be floating over the browser (youtube/netflix/...) obviously.

HeedfulCrayon commented 3 years ago

There is a module in powershell called Burnt-Toast that does windows notifications easily... Once powershell commands are supported, you could do something with that

ghost commented 3 years ago

I haven't gotten around to it, but I did wonder if this could be done with a combination of customcommand and AutoHotKey https://www.autohotkey.com/docs/commands/TrayTip.htm

This will show a balloon system tray tip notification for three seconds that disappears, but this will not retain the message in the Windows action center or allow for images in the balloon tray tip. This also won't queue messages properly, so tray tips fired in succession while one is open may be lost (haven't quite figured that one out yet). This also only shows messages you've prewritten in the autohotkey script, so isn't good for dynamic values. This is good to say something is off or on or was triggered.

TrayTip,Home Assistant,Front Door Open, 3, 17
Sleep 3000   ; Let it display for 3 seconds.
HideTrayTip()

; Copy this function into your script to use it.
HideTrayTip() {
    TrayTip  ; Attempt to hide it the normal way.
    if SubStr(A_OSVersion,1,3) = "10." {
        Menu Tray, NoIcon
        Sleep 200  ; It may be necessary to adjust this sleep.
        Menu Tray, Icon
    }
}

traytip

ImaBadCoder commented 3 years ago

I definitely vote this up!

mkono87 commented 3 years ago

I vote yes!!

ohhai-kthxbai commented 2 years ago

Can images be passed via HASS Workstation? Could those then be passed onto other powershell modules such as burnt toast which could then create the toast notifications? I'm thinking of HA passing doorbell camera images to be displayed when the doorbell is pressed. This is what burnt toast can do with images, apparently:

example from burnt toast

ghost commented 2 years ago

Here's a method I use for showing Frigate images from HAS on Windows using Hass Workstation Service and Autohotkey.

This would work for any image on your Home Assistant box (or other local web server or local disk on Windows) that is accessible using a static URL/path.

Install Autohotkey, go to C:\Users\Public\Documents\AHK Scripts\ and make a file "Frigate Person Image Popup.ahk" with the content;

UrlDownloadToFile, http://192.168.1.30:5000/api/nameofyourfrigatecamera/person/best.jpg?crop=1, %TEMP%/frigateperson.jpg ; saves an image from my frigate HAS camera to my current windows user temp directory
SplashImage, %TEMP%/frigateperson.jpg, b x0 y0 fs18, ; shows image in upper left corner of screen
Sleep, 1500 ; keeps the image there for 1.5 seconds
SplashImage, Off ; removes the image

Then I add a CustomCommand in Hass Workstation Service with the name "Desktop Frigate Person Image Popup" and the command being the path to the .AHK file I made above; "C:\Users\Public\Documents\AHK Scripts\Frigate Person Image Popup.ahk"

hws frigate

Last, in HAS, I make an automation to trigger the above Hass Workstation Service switch when Frigate detects a person on a camera;

alias: Frigate Desktop Notifications (AHK)
description: ''
trigger:
  - platform: mqtt
    topic: frigate/events
condition:
  - condition: template
    value_template: '{{ trigger.payload_json[''after''][''label''] == ''person'' }}'
action:
  - service: switch.toggle
    target:
      entity_id: switch.desktop_frigate_person_image_popup
mode: single

Can also make the switch visible in your HAS UI so you can turn it off and on when not desired (example, when playing a videogame or something); has switch

Autohotkey has an incredibly small footprint and only runs on demand (no background service), so I've settled on this solution for now. Since this only shows the image, you may combine this code with the Autohotkey Tooltip method to have both image and tooltip text.

HeedfulCrayon commented 2 years ago

@ohhai-kthxbai to use an image in burnt toast, you can just use the URL to the image, like a camera snapshot image. I actually have set mine up to do that https://community.home-assistant.io/t/hass-workstation-service-turn-your-pc-or-laptop-into-a-bunch-of-sensors/263344/50?u=heedfulcrayon

amaisano commented 2 years ago

FWIW I ended up just using IOT Link. It was quite easy as an HA service:

service: mqtt.publish
data:
  topic: iotlink/workgroup/{{ host }}/commands/notify
  payload: '{ title: "Home Assistant", message: ''{{ message }}'' }'
arekkusudesu commented 2 years ago

@amaisano I was also using IOTLink but the project has not been updated in a long time so I decided to switch to Hass Workstation. The problem with IOTLink (or I guess any service sending toast notifications) is that some of them run as svchost.exe, which is the case I believe for IOTLink. And it's a bit difficult to change settings for notifications coming from services, if you want for example to give them High Priority if you want these to show even when you are using an application in Full Screen (like a video game or a movie).

After trying a few methods I ended using a tool called Notifu and simply send a Toast notification via notifu64.exe /m "This is a Test" /p "Simple Notification" and since it's a separate application, I can easily set it's priority to High in Windows.