richibrics / IoTuring

Your Windows, Linux, macOS computer as MQTT and HomeAssistant integration
https://pypi.org/project/IoTuring/
GNU General Public License v3.0
70 stars 6 forks source link

Tutorial on how to set this up with Home Assistant? #94

Closed inobrevi closed 6 months ago

inobrevi commented 8 months ago

How can I set this up with Home Assistant? (I have it as a docker container or RPI)

Goal: Control Shutdown/Hibernation of Windows 10 PC.

infeeeee commented 7 months ago
  1. You need an MQTT broker. I use eclipse-mosquitto in docker, but anything should work, you can find the official list of brokers here: https://mqtt.org/software/
  2. Enable the MQTT integration in HA, and connect to your broker: https://www.home-assistant.io/integrations/mqtt
  3. Install and setup IoTuring, in the configurator menu add the HomeAssistant Warehouse, connect to the same broker. Add the Power Entity to shutdown your computer. Hibernation is not supported yet, only sleep.
  4. When you start IoTuring, your computer will show up as a new MQTT device in HA automagically
infeeeee commented 7 months ago

You can create a hibernation button with a Terminal entity. Just select Button, and add this command:

%windir%\System32\rundll32.exe powrprof.dll,SetSuspendState Hibernate

Source: https://superuser.com/questions/463646/is-there-a-command-line-tool-to-put-windows-8-to-sleep/463652#463652

inobrevi commented 7 months ago

Hi!

Thank you for the info.

I moved to Home Assistant OS to avoid integration issues. Everything works, but now I have to figure it out, how to make it work in background, without running it in command window.

infeeeee commented 7 months ago

If you use HAOS, you can install the Mosquitto broker addon: https://github.com/home-assistant/addons/blob/master/mosquitto/DOCS.md

For running in the background on windows, I recommend to run IoTuring as a service with NSSM: https://nssm.cc

inobrevi commented 7 months ago

I figured out first part.

I will let you know if I manage to make it a service :)

inobrevi commented 6 months ago

Hello!

I figured it out, but better and easier.

Basically, after configuring IoTuring, you can create a IoTuring.bat file:

@echo off
python -m IoTuring

And then run it from IoTuring_hidden.vbs script, which would run it without showing console window:

CreateObject("Wscript.Shell").Run "IoTuring.bat",0,True

Save both files in the same folder, run IoTuring_hidden.vbs and it just works. You can also add this .vbs script to autorun, but I didn't test that.