update UI and readme for idleTime sensor

pull/10/head
sleevezipper 4 years ago
parent 662c05ade5
commit dfc8d6cdf3

@ -103,6 +103,10 @@ which results in `4008` for my PC.
You can use [WMI Explorer](https://github.com/vinaypamnani/wmie2/tree/v2.0.0.2) to find see what data is available.
### IdleTime
This sensor returns the amount of seconds the workstation has been idle for. It starts counting the moment you stop typing or moving your mouse.
### Dummy
This sensor spits out a random number every second. Useful for testing, maybe you'll find some other use for it.

@ -139,6 +139,13 @@ namespace UserInterface.Views
item.ShowWindowNameInput = true;
item.UpdateInterval = 5;
break;
case AvailableSensors.IdleTimeSensor:
item.Description = "This sensor returns the amount of seconds the workstation has been idle for. ";
item.MoreInfoLink = "https://github.com/sleevezipper/hass-workstation-service#idletime";
item.ShowQueryInput = false;
item.ShowWindowNameInput = false;
item.UpdateInterval = 5;
break;
default:
item.Description = null;
item.MoreInfoLink = null;

@ -1,21 +1,13 @@
using hass_workstation_service.Communication;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using HWND = System.IntPtr;
namespace hass_workstation_service.Domain.Sensors
{
public class IdleTimeSensor : AbstractSensor
{
public IdleTimeSensor(MqttPublisher publisher, int? updateInterval = 10, string name = "IdleTime", Guid id = default) : base(publisher, name ?? "IdleTime", updateInterval ?? 10, id)
{
}
public IdleTimeSensor(MqttPublisher publisher, int? updateInterval = 10, string name = "IdleTime", Guid id = default) : base(publisher, name ?? "IdleTime", updateInterval ?? 10, id){}
public override AutoDiscoveryConfigModel GetAutoDiscoveryConfig()
{
@ -24,14 +16,13 @@ namespace hass_workstation_service.Domain.Sensors
Name = this.Name,
Unique_id = this.Id.ToString(),
Device = this.Publisher.DeviceConfigModel,
State_topic = $"homeassistant/sensor/{this.Name}/state",
State_topic = $"homeassistant/sensor/{Publisher.DeviceConfigModel.Name}/{this.Name}/state",
Icon = "mdi:window-maximize",
});
}
public override string GetState()
{
return GetLastInputTime().ToString();
}

Loading…
Cancel
Save