|
|
@ -10,6 +10,7 @@ namespace hass_workstation_service.Domain.Sensors
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class NamedWindowSensor : AbstractSensor
|
|
|
|
public class NamedWindowSensor : AbstractSensor
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
public override string Domain => "binary_sensor";
|
|
|
|
public string WindowName { get; protected set; }
|
|
|
|
public string WindowName { get; protected set; }
|
|
|
|
public NamedWindowSensor(MqttPublisher publisher, string windowName, string name = "NamedWindow", int? updateInterval = 10, Guid id = default) : base(publisher, name ?? "NamedWindow", updateInterval ?? 10, id)
|
|
|
|
public NamedWindowSensor(MqttPublisher publisher, string windowName, string name = "NamedWindow", int? updateInterval = 10, Guid id = default) : base(publisher, name ?? "NamedWindow", updateInterval ?? 10, id)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -24,15 +25,14 @@ namespace hass_workstation_service.Domain.Sensors
|
|
|
|
Unique_id = this.Id.ToString(),
|
|
|
|
Unique_id = this.Id.ToString(),
|
|
|
|
Device = this.Publisher.DeviceConfigModel,
|
|
|
|
Device = this.Publisher.DeviceConfigModel,
|
|
|
|
State_topic = $"homeassistant/{this.Domain}/{Publisher.DeviceConfigModel.Name}/{this.Name}/state",
|
|
|
|
State_topic = $"homeassistant/{this.Domain}/{Publisher.DeviceConfigModel.Name}/{this.Name}/state",
|
|
|
|
Icon = "mdi:window-maximize",
|
|
|
|
Availability_topic = $"homeassistant/sensor/{Publisher.DeviceConfigModel.Name}/availability"
|
|
|
|
Availability_topic = $"homeassistant/{this.Domain}/{Publisher.DeviceConfigModel.Name}/availability"
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override string GetState()
|
|
|
|
public override string GetState()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var windowNames = GetOpenWindows().Values;
|
|
|
|
var windowNames = GetOpenWindows().Values;
|
|
|
|
return windowNames.Any(v => v.Contains(this.WindowName, StringComparison.OrdinalIgnoreCase)) ? "True" : "False";
|
|
|
|
return windowNames.Any(v => v.Contains(this.WindowName, StringComparison.OrdinalIgnoreCase)) ? "ON" : "OFF";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|