Put Windows to Sleep With Home Assistant

I need a Home Assistant automation to put my computer to sleep when my computer room is not occupied. This involves using OpenSSH, Psshutdown64 and Wake-on-LAN on the Windows computer and Terminal for SSH on the Home Assistant computer. It also requires Private/Public authentication to avoid requiring a password.

From William Campbell:

This is a YouTube video to setup SSH using private/public key authentication between Linux and Windows. Pssshutdown64 from Microsoft SysInternals command is needed for sleeping a Windows computer. Remaining is how to wake a computer from Home Assistant.

From ChatGPT:

1. Set Up SSH Access on the Windows Computer

Generate SSH Key Pair (if not already done):

  • On your local machine (not the Windows computer), generate an SSH key pair if you haven’t already:bashCopy codessh-keygen -t rsa -b 4096 Follow the prompts to generate the key pair. This will create id_rsa (private key) and id_rsa.pub (public key) in your ~/.ssh/ directory.

Copy Public Key to Windows Machine:

  • Copy the contents of id_rsa.pub (your public key) from your local machine.
  • Log in to your Windows machine.
  • Create a .ssh directory in your Windows user’s home directory (C:\Users\YourUsername\.ssh) if it doesn’t exist.
  • Add your public key to authorized_keys in your Windows user’s .ssh directory.
  • Ensure proper permissions are set on the .ssh directory (700) and authorized_keys file (600).

2. Install psshutdown64 on the Windows Computer

Download Sysinternals Suite:

  • Download the Sysinternals Suite which includes psshutdown64.
  • Extract the suite and locate psshutdown64.exe.

Add psshutdown64 to Path:

  • Add the directory containing psshutdown64.exe to your system’s PATH environment variable for easy execution from any directory.

3. Configure Home Assistant Automation

Home Assistant Automation Script:

  • In your Home Assistant installation, create or modify an automation YAML file (e.g., automations.yaml).

Example Automation Script:

yamlCopy code# Example: Sleep Windows Computer using SSH
- alias: 'Sleep Windows Computer'
  trigger:
    platform: state
    entity_id: binary_sensor.your_trigger_sensor  # Replace with your trigger
    to: 'on'  # Trigger when sensor turns on
  action:
    service: shell_command.sleep_windows_computer

shell_command:
  sleep_windows_computer: 'ssh -i /path/to/your/private/key user@windows-ip-or-hostname "psshutdown64.exe -d -t 0"'
  • Replace binary_sensor.your_trigger_sensor with the entity ID of the sensor that triggers this automation (e.g., a button press, motion sensor, etc.).
  • Update /path/to/your/private/key, user, and windows-ip-or-hostname with your SSH private key path, Windows username, and Windows machine IP address or hostname respectively.

4. Testing the Automation

  • Restart Home Assistant to apply the new automation.
  • Trigger the automation by activating the specified trigger (e.g., pressing a button connected to the binary sensor).
  • Home Assistant will execute the SSH command using the specified private key to connect to your Windows machine and run psshutdown64.exe to put the computer to sleep.

Ensure that SSH access is enabled and properly configured on your Windows computer for this setup to work securely. This automation assumes that your Home Assistant instance can reach your Windows machine over the network and has SSH access configured with the appropriate private key. Adjust the paths and commands as necessary based on your specific setup and environment.

RSS Feeds (for Magic Mirror)

https://feeds.npr.org/####/rss.xml

Searching on that, I’ve generated the following list. Keep in mind that some are archived and not updated, some seem abandoned; most over number 2000 are empty, but included for completion’s sake.

 ####	Title
 1001	News
 1002	News
 1003	National
 1004	World
 1005	Summer Reading 2006
 1006	Business
 1007	Science
 1008	Culture
 1009	Middle East
 1010	Archived Topic: Iraq
 1011	Election 2004
 1012	Politics
 1013	Education
 1014	Politics
 1015	Race
 1016	Religion
 1017	Economy
 1018	Your Money
 1019	Technology
 1020	Media
 1023	Radio Expeditions
 1024	Research News
 1025	Environment
 1026	Space
 1027	Health Care
 1028	On Aging
 1029	Mental Health
 1030	Children's Health
 1031	Global Health
 1032	Books
 1033	Author Interviews
 1034	Book Reviews
 1039	Music
 1040	In Performance
 1045	Movies
 1046	Performing Arts
 1047	Art & Design
 1048	Pop Culture
 1051	Diversions
 1052	Humor & Fun
 1053	Food
 1054	Gardening
 1055	Sports
 1056	World Story of the Day
 1057	Opinion
 1059	Analysis
 1061	From Our Listeners
 1062	Obituaries
 1064	Summer Reading 2006: Excerpts
 1065	Holidays
 1066	Your Health
 1067	Election 2006
 1068	Summer Reading 2006: Cookbooks
 1070	Law
 1071	Summer Olympics '04
 1072	Democratic Convention 2004
 1073	Republican Convention 2004
 1074	Lost & Found Sound
 1076	Low-Wage America
 1077	The Second Term
 1078	The Impact of War
 1081	Indian Ocean Tsunami 2004-05
 1083	Social Security Debate
 1084	Summer Reading 2005
 1085	Summer Reading: Fiction
 1086	Summer Reading: Kids
 1087	Summer Reading: Cooking
 1088	Summer
 1089	Summer Reading: Nonfiction
 1090	Story of the Day
 1092	Winter Olympics '06
 1093	Katrina & Beyond
 1095	Business Story of the Day
 1096	Holiday Story of the Day
 1097	Holiday Books 2005
 1098	Holiday Music 2005
 1099	Holiday Food 2005
 1100	World Cup 2006
 1101	Archived Topic: Israeli-Palestinian Coverage
 1102	Election 2008
 1103	Studio Sessions
 1104	Music Reviews
 1105	Music Interviews
 1106	Music News
 1107	Music Lists
 1108	New Music
 1109	Concerts
 1110	Music Videos
 1111	Election 2008: Issues
 1112	Election 2008: Voting Groups
 1113	Election 2008: Money, Media & Influence
 1114	Election 2008: Congressional & State Races
 1115	Election 2008: On the Campaign Trail
 1116	Sen. Hillary Clinton (D-NY)
 1117	Sen. Barack Obama (D-IL)
 1118	Sen. John McCain (R-AZ)
 1119	Sen. Joseph Biden (D-DE)
 1120	Gov. Sarah Palin
 1121	Election 2008: Voting Problems
 1122	National Security
 1124	Europe
 1125	Asia
 1126	Africa
 1127	Latin America
 1128	Health
 1131	Energy
 1132	Animals
 1133	On Disabilities
 1134	Fitness & Nutrition
 1135	Medical Treatments
 1136	History
 1137	Movie Interviews
 1138	Television
 1139	Recipes
 1141	Fine Art
 1142	Architecture
 1143	Photography
 1144	Theater
 1145	Dance
 1146	Strange News
 1149	Archived Topic: Afghanistan
 1150	Investigations
 1151	Music Quizzes
 1161	Book News & Features
 1162	Impact
 1163	TV Reviews
 1164	Family
 1165	Weather
 1166	Perspective
 1167	Climate
 2000	Arts
 2001	Design
 2002	Fashion & Beauty
 2003	Food
 2004	Books
 2005	Performing Arts
 2006	Visual Arts
 2007	Business
 2008	Business News
 2009	Careers
 2010	Investing
 2011	Management & Marketing
 2012	Shopping
 2013	Comedy
 2014	Education
 2015	Education Technology
 2016	Higher Education
 2017	K-12
 2018	Language Courses
 2019	Training
 2020	Leisure
 2021	Automotive
 2022	Aviation
 2023	Hobbies
 2024	Other Games
 2025	Video Games
 2026	Government
 2027	Local
 2028	National
 2029	Non-Profit
 2030	Regional
 2031	Health & Fitness
 2032	Alternative Health
 2033	Fitness & Nutrition
 2034	Self-Help
 2035	Sexuality
 2036	Kids & Family
 2037	Music
 2038	News
 2039	Religion & Spirituality
 2040	Buddhism
 2041	Christianity
 2042	Hinduism
 2043	Islam
 2044	Judaism
 2045	Other
 2046	Spirituality
 2047	Science
 2048	Medicine
 2049	Natural Sciences
 2050	Social Sciences
 2051	Society & Culture
 2052	History
 2053	Personal Journals
 2054	Philosophy
 2055	Places & Travel
 2056	Sports
 2057	Amateur
 2058	College & High School
 2059	Outdoor
 2060	Professional
 2061	Technology
 2062	Gadgets
 2063	Tech News
 2064	Podcasting
 2065	Software How-To
 2066	TV & Film
 2067	Fiction
 2068	History
 2069	True Crime
 2070	Drama
 2071	Science Fiction
 2072	Comedy Fiction
 2073	Management
 2074	Marketing
 2075	Improv
 2076	Comedy Interviews
 2077	Standup
 2078	Language Learning
 2079	How To
 2080	Self Improvement
 2081	Courses
 2082	Crafts
 2083	Games
 2084	Home & Garden
 2085	Animation & Manga
 2086	Fitness
 2087	Nutrition
 2088	Mental Health
 2089	Education for Kids
 2090	Stories for Kids
 2091	Parenting
 2092	Pets & Animals
 2093	Music Commentary
 2094	Music History
 2095	Music Interviews
 2096	Daily News
 2097	Politics
 2098	Sports News
 2099	News Commentary
 2100	Entertainment News
 2101	Religion
 2102	Mathematics
 2103	Nature
 2104	Astronomy
 2105	Chemistry
 2106	Earth Sciences
 2107	Life Sciences
 2108	Physics
 2109	Documentary
 2110	Relationships
 2111	Soccer
 2112	Football
 2113	Basketball
 2114	Baseball
 2115	Hockey
 2116	Running
 2117	Rugby
 2118	Golf
 2119	Cricket
 2120	Wrestling
 2121	Tennis
 2122	Volleyball
 2123	Swimming
 2124	Fantasy Sports
 2125	Fantasy
 2126	TV Reviews
 2127	After Shows
 2128	Film Reviews
 2129	Film History
 2130	Film Interviews
 2131	Entrepreneurship
 2132	Medicine

Home Assistant Kitchen Kiosk

Magic Mirror made a really nice kitchen kiosk but it’s time to move on. I installed Raspbian on an old Raspberry Pi 2 and followed a nice tutorial at PiMyLifeUp to set up the kiosk using the Chromium browser. The browser will rotate through a set of web pages on a schedule. In this case it will be my Home Assistant pages.

I stumbled across a Magic Mirror forum post of a build by a non-programmer that used some modules, some custom modules, and a Google Calendar API written by ChatGPT. Very interesting! Installation begins with this.

Back to my kiosk, SSH is a good remote interface but a GUI would help. Real VNC Viewer is the old standby, but I’ll try Microsoft Remote Desktop too.