Create a “camera” for screenshots in HASS.AGENT
Home Assistant Configuration
Currently HASS.AGENT does not provide a way to easily create a screen shot camera entity, but it is possible as follows
Create a Powershell script
$Path = "\\HOMEASSISTANT\config\www" # Make sure that the directory to keep screenshots has been created, otherwise create it If (!(test-path $path)) { New-Item -ItemType Directory -Force -Path $path } Add-Type -AssemblyName System.Windows.Forms $screen = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds # Get the current screen resolution $image = New-Object System.Drawing.Bitmap($screen.Width, $screen.Height) # Create a graphic object $graphic = [System.Drawing.Graphics]::FromImage($image) $point = New-Object System.Drawing.Point(0, 0) $graphic.CopyFromScreen($point, $point, $image.Size); $cursorBounds = New-Object System.Drawing.Rectangle([System.Windows.Forms.Cursor]::Position, [System.Windows.Forms.Cursor]::Current.Size) # Get a screenshot [System.Windows.Forms.Cursors]::Default.Draw($graphic, $cursorBounds) # $screen_file = "$Path\" + $env:computername + "_" + $env:username + "_" + "$((get-date).tostring('yyyy.MM.dd-HH.mm.ss')).png" $screen_file = "$Path\" + $env:computername + "-screenshot.png" # Save the screenshot as a PNG file $image.Save($screen_file, [System.Drawing.Imaging.ImageFormat]::Png)
You might need to change the path. Note it assumes you have the SAMBA plugin enabled on your Homeassistance instance.
Next add this script as a command in HASS.Agent
Now go into Home Assistant and Integrations and add a Generic Camera pointing it as the file using the full url. e.g
http://homeassistant.local:8123/local/EBONY-VIII-screenshot.png
with your computer name where EBONY-VIII is.
Finally set up a simple automation to update the screen shot as often as you want. With a condition to check the PC is on.
This camera can be displayed with the standard Picture Entity Card.
alias: Screenshot Ebony description: '' trigger: - platform: time_pattern minutes: /2 condition: - condition: state entity_id: switch.ebony_viii state: 'on' action: - service: button.press data: {} target: entity_id: button.ebony_take_screenshot mode: single