PCInfoToMQTT v0.1.3

Update (2020-05-15)

See this post here for download and how to use it.


Hi, first post here!

I developed a Windows program (in C#) that communicate some information to Home Assistant using MQTT. It will send PC temperatures (using AIDA64 for now) and PC usage (in use/not in use). I also added a bidirectional communication, so you can use Home Assistant to execute pre-defined commands on your PC.

When I last searched for it, I did not find anything that suited my needs. So I wonder if there is any interest for that Windows PC-Home Assistant bridge. If positive, I might clean up the code a bit and publish it on GitHub or release the binary here with some basic user settings support.

Sorry if I posted in the wrong category, was unsure since the project is not public (yet!).
Expand the image to see everything (1 image limitation for new user).


10 Likes

I really like what you did here, however there is a project called iot link which I believe does the same thing.

Still really cool what you did though!

1 Like

Well, thanks a lot for the kind comments! I did the research some weeks prior to this project release… Mine detects if the PC is used remotely (RDP) or physically, I might add it as a PR to IOT Link if it does not support that yet and if the interest is there.

Regards,

2 Likes

That is actually pretty cool! You should add it as a PR or release as separate project (I actually don’t know if iot link has this, I haven’t started to use it yet). I just mentioned it to you as it seemed like the projects were/are very similar in what they want to achieve. That is the reason I mentioned IOT link. I would hate to see you build something really similar only to find out later that there is already a project that is maybe ahead already (and that precious time could be used to build other beautiful projects no?) XD.

But this is pretty cool imo. :+1:

Please send link where I can download this program so that I test it…

@jimz011 You are right on that for sure, good thing you told me.
@kslb I added user settings support and sent you a private message!

Very interesting project, I would like to test it too.
It could be used in a lot of different automations. For example to change slightly the color of a bulb depending on the temperature of the PC.

Exactly! Also a personal use case of mine for ‘Is PC In Use’: I use it to turn air conditioner into manual control (since it’s in the same room as the PC) as well as adjusting up the PC room brightness. I also extend the motion sensor auto-off time. Could be a light that is on/off according to PC being used or not and therefore serve as a reminder to lock your session.

You can also see easily using charts what was the max temperature of each sensor or track length of your computer session, etc.

I sent you a pm with the link and the how-to guide.
For now, the Is PC In Use sensor reports the PC as not used when it’s a remote session (my personal needs), I could add 2 distinct sensors if someone want that.

Hi, first release, download link of the latest version is at the end of the post!

First, you need to edit PCInfoToMQTT.WPF.exe.config and fill the server address/server port/username/password of your MQTT server (I use Mosquitto in HA).
I implemented another way that does not require AIDA64 for temperature reading. It uses OpenHardwareMonitor internally and therefore you need to run it as administrator to be able to get hardware sensor temperatures. It still supports AIDA64 without admin rights need, to use, just set UseAida64 to True in the config.

I also added a button in the UI to get all the MQTT topics easily.

Put the mqtt temperature sensors in sensors.yaml, my config:

- platform: mqtt
  name: 'PC CPU Temperature'
  unit_of_measurement: '°C'
  state_topic: 'home-assistant/pc/temperatures/cpu'
  
- platform: mqtt
  name: 'PC Motherboard Temperature'
  unit_of_measurement: '°C'
  state_topic: 'home-assistant/pc/temperatures/motherboard'
  
- platform: mqtt
  name: 'PC GPU Temperature'
  unit_of_measurement: '°C'
  state_topic: 'home-assistant/pc/temperatures/gpu-diode'

- platform: mqtt
  name: 'PC GPU VRM 1 Temperature'
  unit_of_measurement: '°C'
  state_topic: 'home-assistant/pc/temperatures/gpu-vrm1'
  
- platform: mqtt
  name: 'PC GPU VRM 2 Temperature'
  unit_of_measurement: '°C'
  state_topic: 'home-assistant/pc/temperatures/gpu-vrm2'

Put the mqtt is pc in use sensor in binary_sensors.yaml, my config:

- platform: mqtt
  name: 'Is PC In Use?'
  state_topic: 'home-assistant/pc/in-use'

Then in Lovelace UI (for the graph, I use this custom card: https://github.com/kalkih/mini-graph-card):

- type: entities
  title: 'Sensors'
  show_header_toggle: false
  entities:
    - entity: binary_sensor.is_pc_in_use
      secondary_info: last-changed
 

- type: custom:mini-graph-card
  name: 'PC Temperatures (24 hours)'
  entities:   
    - entity: sensor.pc_cpu_temperature
      name: 'CPU'
    - entity: sensor.pc_motherboard_temperature
      name: 'Motherboard'
    - entity: sensor.pc_gpu_temperature
      name: 'GPU'
    - entity: sensor.pc_gpu_vrm_1_temperature
      name: 'GPU VRM 1'
    - entity: sensor.pc_gpu_vrm_2_temperature
      name: 'GPU VRM 2'
  hours_to_show: 24
  hour24: true
  height: 400
  points_per_hour: 2
  show_indicator: true
  show_legend: true
  show:
    fill: false
    points: true
    labels: true 

I minimize the window to the tray using RBTray (http://rbtray.sourceforge.net), trusted light tool that just does that for any window. You can also just minimize the window or send it to another virtual desktop if that bothers you.
I could add native support for tray minimize natively later.
Let me know how it works for you guys. I can help if you have problems!

Download
PCInfoToMQTT_0.1.3.0.zip
http://www.mediafire.com/file/dtm8fwj4iyksz3q/PCInfoToMQTT_0.1.3.0.zip/file

1 Like

For me this software is not working…

Allways see the software in TaskManager, but I can not see other stuff…

So, I’m strugling, do I need to set something else or what?

@kslb got it working the same day for anyone wondering if the tool is actually working (told me in private). If anyone miss a feature or find a bug, just let me know!

There would be great option, if you can name PC, so that MQTT topics would be like:
“home-assistant/PCNAME/temperatures/intelcpu-0-temperature-0”
Or that “pc” is equal PC name, so that this can be used on multiple computers…

Searing for something like this but then with my Mac

1 Like

Can you tell the solution i am also stuck at same step

@kslb Great idea! I added a new setting called BaseTopic that you can edit in the .config file. The default value is ‘home-assistant/pc’.

@TychoWerner I will look at it, what would you need the most, is pc in use or the temperatures and which ones?

@vageesh79 Make sure you edit the .config file (PCInfoToMQTT.WPF.exe.config) to set your MQTT info: username/password/server address. Also, the errors can be seen in the Windows Event Viewer, that might help to find the problem. Also if you do not use AIDA64 for the temperatures and use the built-in temperature reader (UseAida64 is false by default in .config), you need to run it as Administrator. I will add better logging later!

Update (2020-05-15)

See this post here for download and how to use it.

Hi, this looks awesome and very useful.
The download link in above post does not currently work. Please pass me a link as I would love to try it out.

Hi there!

I uploaded again, I still use my tool and it works fine, I improved the connection part, so now it’s very reliable.

PCInfoToMQTT_0.1.3.0.zip
http://www.mediafire.com/file/dtm8fwj4iyksz3q/PCInfoToMQTT_0.1.3.0.zip/file

Update (2020-05-15)

See this post here for download and how to use it.

1 Like

Hi @kobayashi ,

I got your code working. Thanks for providing the compiled file. However, few of the temperature sensors are being picked up. I think this has to do with the way you are polling available sensors, and I was thinking if I could modify the source code to fit my needs. If you have published this to github, could you please link me to it?

Thanks.

I might publish the code, not sure yet. Do you use Aida or the built-in one? If you use the built-in one, be sure to run it as admin.

I was using the built in method. I ran it as admin, and few of the sensors were picked up. How are you finding what sensors are installed?

Also, how do I use the AIDA method? DO I just install AIDA64, and change the flag to give it a go? I tried that, but did not see any topics being published.