public RollerShutter( ActuatorId id, IBinaryOutput powerOutput, IBinaryOutput directionOutput, IHttpRequestController httpApiController, ILogger logger, IHomeAutomationTimer timer) : base(id, httpApiController, logger) { if (id == null) { throw new ArgumentNullException(nameof(id)); } if (powerOutput == null) { throw new ArgumentNullException(nameof(powerOutput)); } if (directionOutput == null) { throw new ArgumentNullException(nameof(directionOutput)); } _powerGpioPin = powerOutput; _directionGpioPin = directionOutput; _timer = timer; timer.Tick += (s, e) => UpdatePosition(e); base.Settings = new RollerShutterSettings(id, logger); }
public RollerShutter( string id, IBinaryOutput powerOutput, IBinaryOutput directionOutput, TimeSpan autoOffTimeout, int maxPosition, IHttpRequestController httpApiController, INotificationHandler notificationHandler, IHomeAutomationTimer timer) : base(id, httpApiController, notificationHandler) { if (id == null) throw new ArgumentNullException(nameof(id)); if (powerOutput == null) throw new ArgumentNullException(nameof(powerOutput)); if (directionOutput == null) throw new ArgumentNullException(nameof(directionOutput)); _powerGpioPin = powerOutput; _directionGpioPin = directionOutput; _autoOffTimeout = autoOffTimeout; _positionMax = maxPosition; _timer = timer; //TODO: StartMoveUp(); timer.Tick += (s, e) => UpdatePosition(e); }
protected CCToolsBoardBase(DeviceId id, IPortExpanderDriver portExpanderDriver, IHttpRequestController httpApi, ILogger logger) { if (id == null) { throw new ArgumentNullException(nameof(id)); } if (portExpanderDriver == null) { throw new ArgumentNullException(nameof(portExpanderDriver)); } if (httpApi == null) { throw new ArgumentNullException(nameof(httpApi)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } Id = id; _portExpanderDriver = portExpanderDriver; _committedState = new byte[portExpanderDriver.StateSize]; _state = new byte[portExpanderDriver.StateSize]; _httpApi = httpApi; _logger = logger; ExposeToApi(); }
public BinaryStateOutputActuator(string id, IBinaryOutput output, IHttpRequestController httpRequestController, INotificationHandler notificationHandler) : base(id, httpRequestController, notificationHandler) { if (output == null) throw new ArgumentNullException(nameof(output)); _output = output; SetStateInternal(BinaryActuatorState.Off, new ForceUpdateStateParameter()); }
public HSPE16InputOnly(DeviceId id, I2CSlaveAddress address, II2CBus i2cBus, IHttpRequestController httpApi, ILogger logger) : base(id, new MAX7311Driver(address, i2cBus), httpApi, logger) { byte[] setupAsInputs = { 0x06, 0xFF, 0xFF }; i2cBus.Execute(address, b => b.Write(setupAsInputs)); FetchState(); }
public ConditionalOnAutomation(AutomationId id, IHomeAutomationTimer timer, IHttpRequestController httpApiController, ILogger logger) : base(id, timer, httpApiController, logger) { WithAutoTrigger(TimeSpan.FromMinutes(1)); WithActionIfFulfilled(TurnOn); WithActionIfNotFulfilled(TurnOff); }
public LogicalBinaryStateOutputActuator(string id, IHttpRequestController httpApiController, INotificationHandler notificationHandler, IHomeAutomationTimer timer) : base( id, httpApiController, notificationHandler) { if (timer == null) throw new ArgumentNullException(nameof(timer)); _timer = timer; }
public IOBoardManager(IHttpRequestController httpApiController, INotificationHandler notificationHandler) { if (httpApiController == null) throw new ArgumentNullException(nameof(httpApiController)); if (notificationHandler == null) throw new ArgumentNullException(nameof(notificationHandler)); _httpApiController = httpApiController; _notificationHandler = notificationHandler; }
public HSREL5(DeviceId id, I2CSlaveAddress i2CAddress, II2CBus bus, IHttpRequestController httpApi, ILogger logger) : base(id, new PCF8574Driver(i2CAddress, bus), httpApi, logger) { // Ensure that all relays are off by default. The first 5 ports are hardware inverted! The other ports are not inverted but the // connected relays are inverted. SetState(new byte[] { 0xFF }); CommitChanges(true); }
public ActuatorHistory(IActuator actuator, IHttpRequestController apiRequestController, ILogger logger) { _actuator = actuator; _logger = logger; _filename = Path.Combine(ApplicationData.Current.LocalFolder.Path, "Actuators", actuator.Id.Value, "History.csv"); apiRequestController.HandleGet($"statistics/{actuator.Id}").Using(HandleApiGet); }
public HumiditySensor(string id, ISingleValueSensor sensor, IHttpRequestController httpApiController, INotificationHandler notificationHandler) : base(id, httpApiController, notificationHandler) { if (sensor == null) throw new ArgumentNullException(nameof(sensor)); sensor.ValueChanged += (s, e) => UpdateValue(e.NewValue); }
public LPD433MHzSignalSender(I2CHardwareBridge.I2CHardwareBridge i2CHardwareBridge, byte pin, IHttpRequestController httpApiController) { if (i2CHardwareBridge == null) throw new ArgumentNullException(nameof(i2CHardwareBridge)); if (httpApiController == null) throw new ArgumentNullException(nameof(httpApiController)); _i2CHardwareBridge = i2CHardwareBridge; _pin = pin; httpApiController.Handle(HttpMethod.Post, "433MHz").WithRequiredJsonBody().Using(ApiPost); }
public void InitializeHttpApi() { _httpServer = new HttpServer(); HttpRequestDispatcher httpRequestDispatcher = new HttpRequestDispatcher(_httpServer); _apiController = httpRequestDispatcher.GetController("api"); _apiController.Handle(HttpMethod.Get, "read").Using(HandleApiRead); _apiController.Handle(HttpMethod.Post, "write").Using(HandleApiWrite); _httpServer.StartAsync(80).Wait(); }
public Button(string id, IBinaryInput input, IHttpRequestController httpApiController, INotificationHandler notificationHandler, IHomeAutomationTimer timer) : base(id, httpApiController, notificationHandler) { if (id == null) throw new ArgumentNullException(nameof(id)); if (input == null) throw new ArgumentNullException(nameof(input)); timer.Tick += CheckForTimeout; input.StateChanged += HandleInputStateChanged; }
public void ExposeToApi(IHttpRequestController httpApiController) { if (httpApiController == null) { throw new ArgumentNullException(nameof(httpApiController)); } httpApiController.HandleGet("trace").Using(HandleApiGet); }
public RollerShutterButtons(string id, IBinaryInput upInput, IBinaryInput downInput, IHttpRequestController httpRequestController, INotificationHandler notificationHandler, IHomeAutomationTimer timer) : base(id, httpRequestController, notificationHandler) { if (upInput == null) throw new ArgumentNullException(nameof(upInput)); if (downInput == null) throw new ArgumentNullException(nameof(downInput)); Up = new Button(id + "-up", upInput, httpRequestController, notificationHandler, timer); Down = new Button(id + "-down", downInput, httpRequestController, notificationHandler, timer); }
public TurnOnAndOffAutomation(AutomationId id, IHomeAutomationTimer timer, IHttpRequestController httpApiController, ILogger logger) : base(id) { _timer = timer; WithOnDuration(TimeSpan.FromMinutes(1)); Settings = new AutomationSettings(id, httpApiController, logger); }
protected BinaryStateOutputActuator(ActuatorId id, IBinaryOutput output, IHttpRequestController httpApiController, ILogger logger) : base(id, httpApiController, logger) { if (output == null) { throw new ArgumentNullException(nameof(output)); } _output = output; }
protected ActuatorBase(string id, IHttpRequestController httpApiController, INotificationHandler notificationHandler) { if (id == null) throw new ArgumentNullException(nameof(id)); if (httpApiController == null) throw new ArgumentNullException(nameof(httpApiController)); if (notificationHandler == null) throw new ArgumentNullException(nameof(notificationHandler)); Id = id; NotificationHandler = notificationHandler; HttpApiController = httpApiController; ExposeToApi(); }
public MotionDetector(string id, IBinaryInput input, IHomeAutomationTimer timer, IHttpRequestController httpApiController, INotificationHandler notificationHandler) : base(id, httpApiController, notificationHandler) { if (input == null) throw new ArgumentNullException(nameof(input)); input.StateChanged += (s, e) => HandleInputStateChanged(e); IsEnabledChanged += (s, e) => { HandleIsEnabledStateChanged(timer, notificationHandler); }; }
public TemperatureSensor(ActuatorId id, ISingleValueSensor sensor, IHttpRequestController api, ILogger logger) : base(id, api, logger) { if (sensor == null) { throw new ArgumentNullException(nameof(sensor)); } sensor.ValueChanged += (s, e) => SetValueInternal(e.NewValue); // TODO: Add delta to settings. Settings = new ActuatorSettings(id, logger); }
public LogicalBinaryStateOutputActuator(ActuatorId id, IHttpRequestController apiController, ILogger logger, IHomeAutomationTimer timer) : base( id, apiController, logger) { if (timer == null) { throw new ArgumentNullException(nameof(timer)); } _timer = timer; Settings = new ActuatorSettings(id, logger); }
public Automation(AutomationId id, IHomeAutomationTimer timer, IHttpRequestController httpApiController, ILogger logger) : base(id) { if (timer == null) { throw new ArgumentNullException(nameof(timer)); } Timer = timer; _conditionsValidator = new ConditionsValidator(Conditions); Settings = new AutomationSettings(id, httpApiController, logger); }
public OpenWeatherMapWeatherStationHttpApiDispatcher(OpenWeatherMapWeatherStation weatherStation, IHttpRequestController httpApiController) { if (weatherStation == null) { throw new ArgumentNullException(nameof(weatherStation)); } if (httpApiController == null) { throw new ArgumentNullException(nameof(httpApiController)); } _weatherStation = weatherStation; _httpApiController = httpApiController; }
public AutomationSettings(AutomationId automationId, IHttpRequestController httpApiController, ILogger logger) : base(GenerateFilename(automationId), logger) { if (httpApiController == null) { throw new ArgumentNullException(nameof(httpApiController)); } AutomationId = automationId; IsEnabled = new Setting <bool>(true); AppSettings = new Setting <JsonObject>(new JsonObject()); new AutomationSettingsHttpApiDispatcher(this, httpApiController).ExposeToApi(); }
public HealthMonitor(GpioPin statusLed, IHomeAutomationTimer timer, IHttpRequestController httpApiController) { if (timer == null) throw new ArgumentNullException(nameof(timer)); if (httpApiController == null) throw new ArgumentNullException(nameof(httpApiController)); _statusLed = statusLed; if (statusLed != null) { _ledTimeout.Start(TimeSpan.FromMilliseconds(1)); } timer.Tick += Tick; httpApiController.Handle(HttpMethod.Get, "health").Using(c => c.Response.Body = new JsonBody(ApiGet())); httpApiController.Handle(HttpMethod.Post, "health").WithSegment("reset").Using(c => ResetStatistics()); }
public Button(ActuatorId id, IBinaryInput input, IHttpRequestController api, ILogger logger, IHomeAutomationTimer timer) : base(id, api, logger) { if (id == null) { throw new ArgumentNullException(nameof(id)); } if (input == null) { throw new ArgumentNullException(nameof(input)); } timer.Tick += CheckForTimeout; input.StateChanged += HandleInputStateChanged; }
public RollerShutterAutomationSettings(AutomationId automationId, IHttpRequestController httpApiController, ILogger logger) : base(automationId, httpApiController, logger) { DoNotOpenBeforeIsEnabled = new Setting <bool>(false); DoNotOpenBeforeTime = new Setting <TimeSpan>(TimeSpan.Parse("07:15")); AutoCloseIfTooHotIsEnabled = new Setting <bool>(false); AutoCloseIfTooHotTemperaure = new Setting <float>(25); DoNotOpenIfTooColdIsEnabled = new Setting <bool>(false); DoNotOpenIfTooColdTemperature = new Setting <float>(2); OpenOnSunriseOffset = new Setting <TimeSpan>(TimeSpan.FromMinutes(-30)); CloseOnSunsetOffset = new Setting <TimeSpan>(TimeSpan.FromMinutes(30)); }
public SettingsContainerHttpApiDispatcher(TSettings settingsContainerContainer, string relativeUri, IHttpRequestController httpApiController) { if (settingsContainerContainer == null) { throw new ArgumentNullException(nameof(settingsContainerContainer)); } if (httpApiController == null) { throw new ArgumentNullException(nameof(httpApiController)); } _settingsContainer = settingsContainerContainer; _httpApiController = httpApiController; _relativeUri = relativeUri; }
public Home(IHomeAutomationTimer timer, HealthMonitor healthMonitor, IWeatherStation weatherStation, IHttpRequestController httpApiController, INotificationHandler notificationHandler) { if (timer == null) throw new ArgumentNullException(nameof(timer)); if (httpApiController == null) throw new ArgumentNullException(nameof(httpApiController)); if (notificationHandler == null) throw new ArgumentNullException(nameof(notificationHandler)); Timer = timer; _healthMonitor = healthMonitor; WeatherStation = weatherStation; HttpApiController = httpApiController; NotificationHandler = notificationHandler; httpApiController.Handle(HttpMethod.Get, "configuration").Using(c => c.Response.Body = new JsonBody(GetConfigurationAsJSON())); httpApiController.Handle(HttpMethod.Get, "status").Using(HandleStatusRequest); httpApiController.Handle(HttpMethod.Get, "health").Using(c => c.Response.Body = new JsonBody(_healthMonitor.ApiGet())); }
public RollerShutterButtons(ActuatorId id, IBinaryInput upInput, IBinaryInput downInput, IHttpRequestController httpApiController, ILogger logger, IHomeAutomationTimer timer) : base(id, httpApiController, logger) { if (upInput == null) { throw new ArgumentNullException(nameof(upInput)); } if (downInput == null) { throw new ArgumentNullException(nameof(downInput)); } Up = new Button(new ActuatorId(id + "-up"), upInput, httpApiController, logger, timer); Down = new Button(new ActuatorId(id + "-down"), downInput, httpApiController, logger, timer); Settings = new ActuatorSettings(id, logger); }
public CsvHistory(ILogger logger, IHttpRequestController apiRequestController) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (apiRequestController == null) { throw new ArgumentNullException(nameof(apiRequestController)); } _logger = logger; _apiRequestController = apiRequestController; _filename = Path.Combine(ApplicationData.Current.LocalFolder.Path, "History.csv"); Task.Factory.StartNew(async() => await WritePendingEntries(), TaskCreationOptions.LongRunning); }
public OWMWeatherStation(double lat, double lon, string appId, IHomeAutomationTimer timer, IHttpRequestController httpApiController, INotificationHandler notificationHandler) { if (timer == null) throw new ArgumentNullException(nameof(timer)); if (httpApiController == null) throw new ArgumentNullException(nameof(httpApiController)); if (notificationHandler == null) throw new ArgumentNullException(nameof(notificationHandler)); Temperature = _temperature; Humidity = _humidity; _notificationHandler = notificationHandler; _weatherDataSourceUrl = new Uri(string.Format("http://api.openweathermap.org/data/2.5/weather?lat={0}&lon={1}&APPID={2}&units=metric", lat, lon, appId)); httpApiController.Handle(HttpMethod.Get, "weatherStation").Using(c => c.Response.Body = new JsonBody(ApiGet())); httpApiController.Handle(HttpMethod.Post, "weatherStation").WithRequiredJsonBody().Using(c => ApiPost(c.Request)); LoadPersistedValues(); timer.Every(TimeSpan.FromMinutes(2.5)).Do(Update); }
public WeatherStationSituationSensor(ActuatorId id, IHttpRequestController httpApiController, ILogger logger) : base(id, httpApiController, logger) { if (id == null) { throw new ArgumentNullException(nameof(id)); } if (httpApiController == null) { throw new ArgumentNullException(nameof(httpApiController)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } Settings = new ActuatorSettings(id, logger); }
protected ActuatorBase(ActuatorId id, IHttpRequestController httpApiController, ILogger logger) { if (id == null) { throw new ArgumentNullException(nameof(id)); } if (httpApiController == null) { throw new ArgumentNullException(nameof(httpApiController)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } Id = id; Logger = logger; HttpApiController = httpApiController; }
public CCToolsBoardController(IController controller, II2CBus i2cBus, IHttpRequestController httpApi, ILogger log) { if (i2cBus == null) { throw new ArgumentNullException(nameof(i2cBus)); } if (controller == null) { throw new ArgumentNullException(nameof(controller)); } if (httpApi == null) { throw new ArgumentNullException(nameof(httpApi)); } _controller = controller; _i2CBus = i2cBus; _httpApi = httpApi; _log = log; }
public OpenWeatherMapWeatherStation(DeviceId id, IHomeAutomationTimer timer, IHttpRequestController httpApiController, ILogger logger) { if (id == null) { throw new ArgumentNullException(nameof(id)); } if (timer == null) { throw new ArgumentNullException(nameof(timer)); } if (httpApiController == null) { throw new ArgumentNullException(nameof(httpApiController)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } _temperature = new WeatherStationTemperatureSensor(new ActuatorId("WeatherStation.Temperature"), httpApiController, logger); TemperatureSensor = _temperature; _humidity = new WeatherStationHumiditySensor(new ActuatorId("WeatherStation.Humidity"), httpApiController, logger); HumiditySensor = _humidity; _situation = new WeatherStationSituationSensor(new ActuatorId("WeatherStation.Situation"), httpApiController, logger); SituationSensor = _situation; Id = id; _timer = timer; _logger = logger; LoadPersistedValues(); Task.Factory.StartNew(async() => await FetchWeahterData(), CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default); new OpenWeatherMapWeatherStationHttpApiDispatcher(this, httpApiController).ExposeToApi(); }
public HealthMonitor(IBinaryOutput statusLed, IHomeAutomationTimer timer, IHttpRequestController httpApiController) { if (timer == null) { throw new ArgumentNullException(nameof(timer)); } if (httpApiController == null) { throw new ArgumentNullException(nameof(httpApiController)); } _statusLed = statusLed; _timer = timer; _startedDate = _timer.CurrentDateTime; if (statusLed != null) { _ledTimeout.Start(TimeSpan.FromMilliseconds(1)); } timer.Tick += Tick; httpApiController.HandleGet("health").Using(HandleApiGet); httpApiController.HandlePost("health/reset").Using(c => ResetStatistics()); }
public WeatherStationTemperatureSensor(ActuatorId id, IHttpRequestController api, ILogger logger) : base(id, api, logger) { Settings = new ActuatorSettings(id, logger); }
public Lamp(ActuatorId id, IBinaryOutput output, IHttpRequestController request, ILogger logger) : base(id, output, request, logger) { Settings = new ActuatorSettings(id, logger); }
public RollerShutterAutomation(AutomationId id, IHomeAutomationTimer timer, IWeatherStation weatherStation, IHttpRequestController httpApiController, IActuatorController actuatorController, ILogger logger) : base(id) { if (timer == null) { throw new ArgumentNullException(nameof(timer)); } if (weatherStation == null) { throw new ArgumentNullException(nameof(weatherStation)); } if (actuatorController == null) { throw new ArgumentNullException(nameof(actuatorController)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } _timer = timer; _weatherStation = weatherStation; _actuatorController = actuatorController; _logger = logger; Settings = new RollerShutterAutomationSettings(id, httpApiController, logger); }
public StateMachine(string id, IHttpRequestController httpApiController, INotificationHandler notificationHandler) : base(id, httpApiController, notificationHandler) { }
protected BinaryStateOutputActuatorBase(ActuatorId id, IHttpRequestController httpApiController, ILogger logger) : base(id, httpApiController, logger) { }
protected SingleValueSensorBase(string id, IHttpRequestController httpApiController, INotificationHandler notificationHandler) : base(id, httpApiController, notificationHandler) { }
public Window(string id, IHttpRequestController httpApiController, INotificationHandler notificationHandler) : base(id, httpApiController, notificationHandler) { }
public VirtualButton(string id, IHttpRequestController httpApiController, INotificationHandler notificationHandler) : base(id, httpApiController, notificationHandler) { }
public VirtualButtonGroup(ActuatorId id, IHttpRequestController httpApiController, ILogger logger) : base(id, httpApiController, logger) { Settings = new ActuatorSettings(id, logger); }
public Lamp(string id, IBinaryOutput output, IHttpRequestController httpRequestController, INotificationHandler notificationHandler) : base(id, output, httpRequestController, notificationHandler) { }