IOT Link - Windows Management using MQTT

[WORKGROUP\WINDOWS_10_VM][2019-06-21 16:27:48 +03:00][INFO][IOTLinkService.Service.Engine.ServiceAddonManager]: Addon Commands has subscribed to topic commands/volume/mute
[WORKGROUP\WINDOWS_10_VM][2019-06-21 16:27:48 +03:00][INFO][IOTLinkService.Service.Engine.ServiceAddonManager]: Loading addon: commands
[WORKGROUP\WINDOWS_10_VM][2019-06-21 16:27:49 +03:00][INFO][IOTLinkService.Service.Engine.ServiceAddonManager]: System monitor is activated.
[WORKGROUP\WINDOWS_10_VM][2019-06-21 16:27:49 +03:00][INFO][IOTLinkService.Service.Engine.ServiceAddonManager]: Loading addon: windowsmonitor
[WORKGROUP\WINDOWS_10_VM][2019-06-21 16:27:49 +03:00][INFO][MQTTnet.Client.MqttClient]: Connection established successfully.

It seems to have connected without a problem.

Remember to replace the iotlink/workgroup/my-computer topic prefix accordingly with your configurations.

What I understand is - WORKGROUP\WINDOWS_10_VM

And so I did:

  • platform: mqtt
    name: “WinDows 10 VM - Connected”
    state_topic: “iotlink/workgroup/windows_10_VM/lwt”
    value_template: “{{ value }}”
    payload_on: “ON”
    payload_off: “OFF”
    device_class: “connectivity”
    qos: 1

But I get an error:

what am I missing?

Hello!

Have you tried to debug it with MQTT Explorer? It is a great app to monitor MQTT messages. You can check if your VM is connected to the broker and sending messages.

https://www.microsoft.com/store/productId/9PP8SFM082WD

This is my connected binary sensor:

  - platform: mqtt
    name: "Desktop - Conectado"
    state_topic: "iotlink/workgroup/desktop/lwt"
    value_template: "{{ value }}"
    payload_on: "ON"
    payload_off: "OFF"
    device_class: "connectivity"
    qos: 1

Can you check if messages are being sent?

Thanks.

1 Like

I do not understand, you can show me your log file like mine. This name from where was taken?

Hey,

MQTT is case-sensetive, I saw you put iotlink/workgroup/windows_10_VM/lwt instead of iotlink/workgroup/windows_10_vm/lwt. May it be the case?

The name is get from here: https://gitlab.com/iotlink/iotlink/wikis/FAQ#wiki-where-do-i-find-my-domainname-and-machinename

Give it a try.

That’s how it appears

binary_sensor:
  - platform: mqtt
    name: "WinDows 10 VM - Connected"
    state_topic: "iotlink/workgroup/windows_10_vm/lwt"
    value_template: "{{ value }}"
    payload_on: "ON"
    payload_off: "OFF"
    device_class: "connectivity"
    qos: 1

  - platform: mqtt
    name: "WinDows 10 VM - Charging"
    state_topic: "iotlink/workgroup/windows_10_vm/lwt/windows-monitor/stats/power/status"
    value_template: "{{ value }}"
    payload_on: "Online"
    payload_off: "Offline"
    device_class: "plug"
    availability_topic: "iotlink/workgroup/windows_10_vm/lwt"
    payload_available: "ON"
    payload_not_available: "OFF"
    qos: 1

  - platform: mqtt
    name: "WinDows 10 VM - Battery Status"
    state_topic: "iotlink/workgroup/windows_10_vm/lwt/windows-monitor/stats/battery/status"
    value_template: "{{ value }}"
    payload_on: "Online"
    payload_off: "Offline"
    device_class: "plug"
    availability_topic: "iotlink/workgroup/windows_10_vm/lwt"
    payload_available: "ON"
    payload_not_available: "OFF"
    qos: 1

sensor:

  - platform: mqtt
    name: "WinDows 10 VM - Idle Time"
    state_topic: "iotlink/workgroup/windows_10_vm/lwt/windows-monitor/stats/idle-time/my_user"
    unit_of_measurement: 'seconds'
    icon: mdi:timer
    value_template: "{{ value }}"
    availability_topic: "iotlink/workgroup/windows_10_vm/lwt"
    payload_available: "ON"
    payload_not_available: "OFF"
    qos: 1

  - platform: mqtt
    name: "WinDows 10 VM - CPU Usage"
    state_topic: "iotlink/workgroup/windows_10_vm/lwt/windows-monitor/stats/cpu"
    unit_of_measurement: '%'
    icon: mdi:speedometer
    value_template: "{{ value }}"
    availability_topic: "iotlink/workgroup/windows_10_vm/lwt"
    payload_available: "ON"
    payload_not_available: "OFF"
    qos: 1

  - platform: mqtt
    name: "WinDows 10 VM - RAM Usage"
    state_topic: "iotlink/workgroup/windows_10_vm/lwt/windows-monitor/stats/memory/usage"
    unit_of_measurement: '%'
    icon: mdi:memory
    value_template: "{{ value }}"
    availability_topic: "iotlink/workgroup/windows_10_vm/lwt"
    payload_available: "ON"
    payload_not_available: "OFF"
    qos: 1

  - platform: mqtt
    name: "WinDows 10 VM - RAM Available"
    state_topic: "iotlink/workgroup/windows_10_vm/lwt/windows-monitor/stats/memory/available"
    unit_of_measurement: 'MB'
    icon: mdi:memory
    value_template: "{{ value }}"
    availability_topic: "iotlink/workgroup/windows_10_vm/lwt"
    payload_available: "ON"
    payload_not_available: "OFF"
    qos: 1

  - platform: mqtt
    name: "WinDows 10 VM - RAM Used"
    state_topic: "iotlink/workgroup/windows_10_vm/lwt/windows-monitor/stats/memory/used"
    unit_of_measurement: 'MB'
    icon: mdi:memory
    value_template: "{{ value }}"
    availability_topic: "iotlink/workgroup/windows_10_vm/lwt"
    payload_available: "ON"
    payload_not_available: "OFF"
    qos: 1

  - platform: mqtt
    name: "WinDows 10 VM - RAM Total"
    state_topic: "iotlink/workgroup/windows_10_vm/lwt/windows-monitor/stats/memory/total"
    unit_of_measurement: 'MB'
    icon: mdi:memory
    value_template: "{{ value }}"
    availability_topic: "iotlink/workgroup/windows_10_vm/lwt"
    payload_available: "ON"
    payload_not_available: "OFF"
    qos: 1

  - platform: mqtt
    name: "WinDows 10 VM - Remaining Battery"
    state_topic: "iotlink/workgroup/windows_10_vm/lwt/windows-monitor/stats/battery/remaining-percent"
    unit_of_measurement: '%'
    device_class: battery
    value_template: "{{ value }}"
    availability_topic: "iotlink/workgroup/windows_10_vm/lwt"
    payload_available: "ON"
    payload_not_available: "OFF"
    qos: 1

  - platform: mqtt
    name: "WinDows 10 VM - Remaining Battery Time"
    state_topic: "iotlink/workgroup/windows_10_vm/lwt/windows-monitor/stats/battery/remaining-time"
    unit_of_measurement: 'minutes'
    icon: mdi:timer
    value_template: "{{ ( value | float / 60 ) | int }}"
    availability_topic: "iotlink/workgroup/windows_10_vm/lwt"
    payload_available: "ON"
    payload_not_available: "OFF"
    qos: 1

  - platform: mqtt
    name: "WinDows 10 VM - Predicted Lifetime"
    state_topic: "iotlink/workgroup/windows_10_vm/lwt/windows-monitor/stats/battery/full-lifetime"
    unit_of_measurement: 'minutes'
    icon: mdi:timer
    value_template: "{{ ( value | float / 60 ) | int }}"
    availability_topic: "iotlink/workgroup/windows_10_vm/lwt"
    payload_available: "ON"
    payload_not_available: "OFF"
    qos: 1

  - platform: mqtt
    name: "WinDows 10 VM - HDD Usage (C)"
    state_topic: "iotlink/workgroup/windows_10_vm/lwt/windows-monitor/stats/hard-drive/c/drive-usage"
    unit_of_measurement: '%'
    icon: mdi:chart-donut
    value_template: "{{ value }}"
    availability_topic: "iotlink/workgroup/windows_10_vm/lwt"
    payload_available: "ON"
    payload_not_available: "OFF"
    qos: 1

  - platform: mqtt
    name: "WinDows 10 VM - HDD Total Size (C)"
    state_topic: "iotlink/workgroup/windows_10_vm/lwt/windows-monitor/stats/hard-drive/c/total-size"
    unit_of_measurement: 'MB'
    icon: mdi:harddisk
    value_template: "{{ value }}"
    availability_topic: "iotlink/workgroup/windows_10_vm/lwt"
    payload_available: "ON"
    payload_not_available: "OFF"
    qos: 1

  - platform: mqtt
    name: "WinDows 10 VM - HDD Total Free Space (C)"
    state_topic: "iotlink/workgroup/windows_10_vm/lwt/windows-monitor/stats/hard-drive/c/total-free-space"
    unit_of_measurement: 'MB'
    icon: mdi:harddisk
    value_template: "{{ value }}"
    availability_topic: "iotlink/workgroup/windows_10_vm/lwt"
    payload_available: "ON"
    payload_not_available: "OFF"
    qos: 1

  - platform: mqtt
    name: "WinDows 10 VM - HDD Free Space (C)"
    state_topic: "iotlink/workgroup/windows_10_vm/lwt/windows-monitor/stats/hard-drive/c/available-free-space"
    unit_of_measurement: 'MB'
    icon: mdi:harddisk
    value_template: "{{ value }}"
    availability_topic: "iotlink/workgroup/windows_10_vm/lwt"
    payload_available: "ON"
    payload_not_available: "OFF"
    qos: 1

  - platform: mqtt
    name: "WinDows 10 VM - HDD Used Space (C)"
    state_topic: "iotlink/workgroup/windows_10_vm/lwt/windows-monitor/stats/hard-drive/c/used-space"
    unit_of_measurement: 'MB'
    icon: mdi:harddisk
    value_template: "{{ value }}"
    availability_topic: "iotlink/workgroup/windows_10_vm/lwt"
    payload_available: "ON"
    payload_not_available: "OFF"
    qos: 1

  - platform: mqtt
    name: "WinDows 10 VM - HDD Format (C)"
    state_topic: "iotlink/workgroup/windows_10_vm/lwt/windows-monitor/stats/hard-drive/c/drive-format"
    unit_of_measurement: ''
    icon: mdi:harddisk
    value_template: "{{ value }}"
    availability_topic: "iotlink/workgroup/windows_10_vm/lwt"
    payload_available: "ON"
    payload_not_available: "OFF"
    qos: 1

  - platform: mqtt
    name: "WinDows 10 VM - HDD Label (C)"
    state_topic: "iotlink/workgroup/windows_10_vm/lwt/windows-monitor/stats/hard-drive/c/volume-label"
    unit_of_measurement: ''
    icon: mdi:harddisk
    value_template: "{{ value }}"
    availability_topic: "iotlink/workgroup/windows_10_vm/lwt"
    payload_available: "ON"
    payload_not_available: "OFF"
    qos: 1

just the first one needs the “/lwt” part, the other ones you need to strip it off the state_topic and keep on the availability_topic, eg:

  - platform: mqtt
    name: "WinDows 10 VM - Charging"
    state_topic: "iotlink/workgroup/windows_10_vm/windows-monitor/stats/power/status"
    value_template: "{{ value }}"
    payload_on: "Online"
    payload_off: "Offline"
    device_class: "plug"
    availability_topic: "iotlink/workgroup/windows_10_vm/lwt"
    payload_available: "ON"
    payload_not_available: "OFF"
    qos: 1

Thanks, works.

WinDows 10 Vm - HDD Used Space Š

Can you change the code that it will display in gb? For example 39.5 gb

My design

11 Likes

Hi there

I have a strange problem.

When i run mosquitto_sub -v -h 10.0.0.130 -p 1883 -t '#' on my raspberry pi to see what messages are being send i keep getting:
iotlink/workgroup/server/lwt ON
Immediately followed by:
iotlink/workgroup/server/lwt OFF

I get information about harddrives, cpu and all that, but HA does not show anything because it thinks the system is off :frowning:

Any clue what i can do?

I am running 1.1.3

Have you changed retain settings?

This is probably because you have one retained message in the same topic.

You can try cleaning it by shutting off IOTLink and then using home assistant mqtt.publish service with the following data

{
  "topic": "iotlink/workgroup/server/lwt",
  "payload": "",
  "qos": 1,
  "retain": true
}

Hi Alexandre, thanks for the quick answer.

I don’t think i changed the retain setting. It pretty much just the examples from your website.

No i just get OFF followed by ON, and now it keeps repeating?

I have the following configuration.yaml on the server being monitored:

mqtt:
  tcp:
    enabled: true
    hostname: 10.0.0.130
    port: 1883
    secure: false
  websocket:
    enabled: false
    uri: 
    secure: false
  messages:
    qos: 1
    retain: false
  lwt:
    enabled: true
    qos: 1
    retain: true
    connectMsg: "ON"
    disconnectMsg: "OFF"
  clientId: server
  prefix: iotlink
  cleanSession: true

logging:
  enabled: true
  level: 4
addons:
  enabled: true
  globalTopics:
    - homeassistant/#

On the HA server i have this configuration.yaml, i removed all not MQTT things to make it shorter, and also only showed a few of the sensors, I have 6 harddrives in my server so it’s quite big.

mqtt:
  client_id: Server
  broker: 10.0.0.130
  port: 1883

binary_sensor:
  - platform: mqtt
    name: "My Computer - Connected"
    state_topic: "iotlink/workgroup/server/lwt"
    value_template: "{{ value }}"
    payload_on: "ON"
    payload_off: "OFF"
    device_class: "connectivity"
    qos: 1

sensor:
  - platform: yr
  - platform: mqtt
    name: "Server - Idle Time"
    state_topic: "iotlink/workgroup/server/windows-monitor/stats/idle-time/my_user"
    unit_of_measurement: 'seconds'
    icon: mdi:timer
    value_template: "{{ value }}"
    availability_topic: "iotlink/workgroup/server/lwt"
    payload_available: "ON"
    payload_not_available: "OFF"
    qos: 1

  - platform: mqtt
    name: "Server - CPU Usage"
    state_topic: "iotlink/workgroup/server/windows-monitor/stats/cpu"
    unit_of_measurement: '%'
    icon: mdi:speedometer
    value_template: "{{ value }}"
    availability_topic: "iotlink/workgroup/server/lwt"
    payload_available: "ON"
    payload_not_available: "OFF"
    qos: 1

I can’t see anything wrong with your configuration.

Only what might be an issue is that you removed the credentials part of mqtt configuration. If you don’t use, just leave it blank

mqtt:
  credentials:
    username: 
    password: 

Can you check your logs and see if there is anything there?

Hi Alexandre

Thanks again, that actually did the trick :slight_smile:

Everything seems to be working now.

Hi @alexslx and @Schneider,
Thanks for the Great Work (made me abendon my own MqttClient).
I’m Trying to add my own Addon and for some reason can find The interface to impliment (yes,
working with Dot.Net 4.7.2 and add the referrence needed to IOTLinkApi).
My goal is to add little Mqtt Monitor that allows me to to monitor all the Mqtt messages,
and one more is to create TTS service that can be used to Send alerts to my pc Speakers.
Can you help me with it?

Thanks

Hi Abeksis

Would you please share how you made that good looking design?

I specially like the way you show disk/ram/cpu data :slight_smile:

https://gist.github.com/abeksis/510e0c35ec5669f1d8c6338e184192b9

Hi @alexslx

How often does your system send the information?

The WindowsMonitor config.yaml is the standard one like this:

monitors:
  CPU:
    enabled: true
    interval: 10
    cacheable: false
    
  Memory:
    enabled: true
    interval: 10
    cacheable: false

(removed some to shorten it)

But i can see now MQTT messages are being received by the broker, and the numbers don’t change.

Is the ‘interval in seconds’ ?

Thanks a lot @abeksis :slight_smile:

1 Like