mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-07 00:35:07 +00:00
feat: move MC into Essentials
In order to solve some dependency issues that keep cropping up, MC should be moved back into the Essentials repo and loaded automatically on startup. This will allow for all plugins that use the MC Messengers library to use the same version without fear of overwriting a dll due to loading of plugin libraries.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using Newtonsoft.Json;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
|
||||
using System;
|
||||
|
||||
namespace PepperDash.Essentials.AppServer.Messengers
|
||||
{
|
||||
public class IHumiditySensorMessenger : MessengerBase
|
||||
{
|
||||
private readonly IHumiditySensor device;
|
||||
|
||||
public IHumiditySensorMessenger(string key, IHumiditySensor device, string messagePath)
|
||||
: base(key, messagePath, device as Device)
|
||||
{
|
||||
this.device = device;
|
||||
}
|
||||
|
||||
protected override void RegisterActions()
|
||||
{
|
||||
base.RegisterActions();
|
||||
|
||||
AddAction("/fullStatus", (id, content) => SendFullStatus());
|
||||
|
||||
device.HumidityFeedback.OutputChange += new EventHandler<Core.FeedbackEventArgs>((o, a) => SendFullStatus());
|
||||
}
|
||||
|
||||
private void SendFullStatus()
|
||||
{
|
||||
var state = new IHumiditySensorStateMessage
|
||||
{
|
||||
Humidity = string.Format("{0}%", device.HumidityFeedback.UShortValue)
|
||||
};
|
||||
|
||||
PostStatusMessage(state);
|
||||
}
|
||||
}
|
||||
|
||||
public class IHumiditySensorStateMessage : DeviceStateMessageBase
|
||||
{
|
||||
[JsonProperty("humidity")]
|
||||
public string Humidity { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user