public static ITrigger GetHumidityUnderranTrigger(this IHumiditySensor sensor, float target, float delta) { if (sensor == null) { throw new ArgumentNullException(nameof(sensor)); } return(new SensorValueUnderranTrigger(sensor).WithTarget(target).WithDelta(delta)); }
public static ITrigger GetHumidityReachedTrigger(this IHumiditySensor sensor, float value, float delta = 5) { if (sensor == null) { throw new ArgumentNullException(nameof(sensor)); } return(new SensorValueReachedTrigger(sensor).WithTarget(value).WithDelta(delta)); }
private void SetupHumidityDependingLamp(IHumiditySensor sensor, ILamp lamp) { ITrigger trigger = sensor.GetHumidityReachedTrigger(80); IAction action = lamp.GetTurnOnAction(); trigger.Attach(action); var twitterClient = new TwitterClient(); trigger.Attach(twitterClient.GetTweetAction("Hello World")); }
private void SetupHumidityDependingOutput(IHumiditySensor sensor, IBinaryOutput output) { sensor.ValueChanged += (s, e) => { if (e.NewValue > 80.0F) { output.Write(BinaryState.High); } else { output.Write(BinaryState.Low); } }; }
public WeatherPage(IHumiditySensor humidity) { this.humidity = humidity; InitializeComponent(); this.Title = "Sample Weather App"; getWeatherBtn.Clicked += GetWeatherBtn_Clicked; //Set the default binding to a default object for now WeatherContext = new Weather(); humidity.NeedsRefresh += Humidity_NeedsRefresh; humidity.Start(); }
private void SetupDemo() { // Get the area from the controller. IArea area = this.GetArea(Room.ExampleRoom); // Get the single motion detector from the controller. IMotionDetector motionDetector = GetComponent <IMotionDetector>(); ITrigger motionDetectedTrigger = motionDetector.GetMotionDetectedTrigger(); // Get the single temperature and humidity sensor from the controller. ITemperatureSensor temperatureSensor = GetComponent <ITemperatureSensor>(); IHumiditySensor humiditySensor = GetComponent <IHumiditySensor>(); // Get the button with the specified ID from the area (not globally). IButton button = area.GetButton(ExampleRoom.Button1); ITrigger buttonTrigger = button.GetPressedShortlyTrigger(); // Get a test lamp from the area (not globally). ILamp lamp2 = area.GetLamp(ExampleRoom.Lamp2); ILamp lamp3 = area.GetLamp(ExampleRoom.Lamp3); // Integrate the twitter client if the configuration file is available. TwitterClient twitterClient; if (TwitterClientFactory.TryCreateFromDefaultConfigurationFile(out twitterClient)) { RegisterService(new TwitterClient()); IAction tweetAction = twitterClient.GetTweetAction($"Someone is here ({DateTime.Now})... @chkratky"); motionDetectedTrigger.Attach(tweetAction); buttonTrigger.Attach(tweetAction); } // An automation is "Fulfilled" per default. ////var automation = new Automation(new AutomationId("DemoAutomation")) //// .WithTrigger(motionDetectedTrigger) //// .WithActionIfConditionsFulfilled(lamp3.GetTurnOnAction()) //// .WithCondition(ConditionRelation.And, new ComponentIsInStateCondition(lamp2, BinaryStateId.Off)) //// .WithCondition(ConditionRelation.And, new NumericValueSensorHasValueGreaterThanCondition(humiditySensor, 80)); //AddAutomation(automation); SetupTelegramBot(); new PersonalAgentToApiDispatcher(this).ExposeToApi(ApiController); }
public App(IHumiditySensor humidity) { var weader = new WeatherPage(humidity); MainPage = new NavigationPage(weader); }