Neuerstellung

This commit is contained in:
Stephan Maier
2023-08-29 11:37:30 +02:00
parent c703aea7bd
commit b9eb4cf019
58 changed files with 17442 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
namespace NetDaemonInterface;
public enum AreaControlEnum
{
Bath,
Bedroom,
Corridor1stFloor,
Corridor2ndFloor,
CorridorGroundFloor,
EntranceArea,
KidsRoom,
Kitchen,
LivingRoom,
Office,
Studio,
TechnicalRoom,
TmpArea
}

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace NetDaemonInterface;
public record CallServiceDataElement
{
[JsonPropertyName("domain")]
public string? Domain { get; init; }
[JsonPropertyName("service")]
public string? Service { get; init; }
[JsonPropertyName("entity_id")]
public string? Entity { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace NetDaemonInterface;
public enum DeviceControlEnum
{
deengph001,
deengph002,
}

View File

@@ -0,0 +1,104 @@
using NetDaemonInterface;
using System;
using System.ComponentModel;
namespace NetDaemonInterface;
public class EntityEvents : ViewModelBase
{
private int clickCnt;
private System.Timers.Timer timer;
public EntityEvents()
{
Init();
}
public EntityEvents(string varName)
{
Init();
VarName = varName;
}
private void Init()
{
PropertyChanged += CounterClass_PropertyChanged;
timer = new System.Timers.Timer(500);
timer.Elapsed += Timer_Elapsed;
timer.AutoReset = false;
}
private void CounterClass_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (clickCnt == 0)
{
timer.Start();
}
trigger = false;
clickCnt++;
}
private void Timer_Elapsed(object? sender, System.Timers.ElapsedEventArgs e)
{
timer.Stop();
switch (clickCnt)
{
case 1:
if (Click is not null)
Click(this, e);
break;
case 2:
if (DoubleClick is not null)
DoubleClick(this, e);
break;
case 3:
if (TribleClick is not null)
TribleClick(this, e);
break;
}
clickCnt = 0;
}
public event EventHandler? Click;
public event EventHandler? DoubleClick;
public event EventHandler? TribleClick;
private bool trigger;
public bool Trigger
{
get { return trigger; }
set
{
if (trigger != value)
{
trigger = value;
OnPropertyChanged();
}
}
}
private string varName;
public string VarName
{
get { return varName; }
set
{
if (varName != value)
{
varName = value;
OnPropertyChanged();
timer.Stop();
clickCnt = 0;
}
}
}
}

View File

@@ -0,0 +1,6 @@
namespace NetDaemonInterface;
public interface IAreaCollection
{
IAreaControl GetArea(AreaControlEnum area);
}

View File

@@ -0,0 +1,37 @@
using NetDaemonInterface;
namespace NetDaemonInterface;
/// <summary>
/// Interface used for providing inputs/events to area's
/// </summary>
public interface IAreaControl
{
/// <summary>
/// Ein Button wurde betätigt
/// </summary>
/// <param name="ButtonSensor">Sensor, der gedrückt wurde</param>
public void ButtonPressed(string entityId, CallServiceDataElement dataElement);
/// <summary>
/// Morgendämmerung
/// </summary>
public void SunDawn();
/// <summary>
/// Sonnenaufgang
/// </summary>
public void SunRising();
/// <summary>
/// Abenddämmerung
/// </summary>
public void SunDusk();
/// <summary>
/// Sonnenuntergang
/// </summary>
public void SunSetting();
}

View File

@@ -0,0 +1,8 @@
using NetDaemonInterface;
namespace NetDaemonInterface;
public interface IDeviceCollection
{
IDeviceControl GetDevice(DeviceControlEnum area);
}

View File

@@ -0,0 +1,18 @@
using HomeAssistantGenerated;
using NetDaemonInterface;
using System.Reactive.Concurrency;
namespace NetDaemonInterface;
/// <summary>
/// Interface used for providing inputs/events to area's
/// </summary>
public interface IDeviceControl
{
/// <summary>
/// Werteänderung
/// </summary>
public void Idle(IEntities entities, IScheduler scheduler);
}

View File

@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>11.0</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\NetDaemonApps\HomeAssistantGenerated.cs" Link="HomeAssistantGenerated.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="JoySoftware.NetDaemon.AppModel" Version="23.26.0" />
<PackageReference Include="JoySoftware.NetDaemon.Client" Version="23.26.0" />
<PackageReference Include="JoySoftware.NetDaemon.Extensions.Logging" Version="23.26.0" />
<PackageReference Include="JoySoftware.NetDaemon.Extensions.Tts" Version="23.26.0" />
<PackageReference Include="JoySoftware.NetDaemon.HassModel" Version="23.26.0" />
<PackageReference Include="JoySoftware.NetDaemon.Extensions.Scheduling" Version="23.26.0" />
<PackageReference Include="JoySoftware.NetDaemon.HassModel.Integration" Version="23.26.0" />
<PackageReference Include="JoySoftware.NetDaemon.Runtime" Version="23.26.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="System.Reactive" Version="6.0.0" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetDaemonInterface;
public static class StateEnum
{
public static readonly string Press = "press";
public static readonly string TurnOn = "turn_on";
public static readonly string TurnOff = "turn_off";
}

View File

@@ -0,0 +1,45 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace NetDaemonInterface
{
public class ViewModelBase : INotifyPropertyChanged
{
/// <summary>
/// Multicast event for property change notifications.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Checks if a property already matches the desired value. Sets the property and
/// notifies listeners only when necessary.
/// </summary>
/// <typeparam name="T">Type of the property.</typeparam>
/// <param name="storage">Reference to a property with both getter and setter.</param>
/// <param name="value">Desired value for the property.</param>
/// <param name="propertyName">Name of the property used to notify listeners.This
/// value is optional and can be provided automatically when invoked from compilers that
/// support CallerMemberName.</param>
/// <returns>True if the value was changed, false if the existing value matched the
/// desired value.</returns>
protected virtual bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
{
if (object.Equals(storage, value)) return false;
storage = value;
// Log.DebugFormat("{0}.{1} = {2}", this.GetType().Name, propertyName, storage);
this.OnPropertyChanged(propertyName);
return true;
}
/// <summary>
/// Notifies listeners that a property value has changed.
/// </summary>
/// <param name="propertyName">Name of the property used to notify listeners. This
/// value is optional and can be provided automatically when invoked from compilers
/// that support <see cref="CallerMemberNameAttribute"/>.</param>
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}