コード例 #1
0
ファイル: AudioZonesViewModel.cs プロジェクト: tig/Premise
 private void AddLight(string location) {
     var o = new PremiseObject(location);
     o.AddPropertyAsync("Name", PremiseProperty.PremiseType.TypeText);
     o.AddPropertyAsync("Description",  PremiseProperty.PremiseType.TypeText);
     o.AddPropertyAsync("Mute", PremiseProperty.PremiseType.TypeBoolean, true);
     o.AddPropertyAsync("Volume", PremiseProperty.PremiseType.TypePercent, true);
     AudioZones.Add(o);
 }
コード例 #2
0
ファイル: LightsViewModel.cs プロジェクト: tig/Premise
 private void AddLight(string location) {
     var o = new PremiseObject(location);
     o.AddPropertyAsync("Name", PremiseProperty.PremiseType.TypeText);
     o.AddPropertyAsync("Description",  PremiseProperty.PremiseType.TypeText);
     o.AddPropertyAsync("PowerState", PremiseProperty.PremiseType.TypeBoolean, true);
     if (!location.Contains("Fluorescent") && !location.Contains("Flourescent") && !location.Contains("Fan"))
         o.AddPropertyAsync("Brightness", PremiseProperty.PremiseType.TypePercent, true);
     Lights.Add(o);
 }
コード例 #3
0
ファイル: GarageDoorsViewModel.cs プロジェクト: tig/Premise
        /// <summary>
        /// Creates and adds a few ItemViewModel objects into the Items collection.
        /// </summary>
        public async void LoadData() {
            if (PremiseServer.Instance.Connected && GDOItems.Count > 0) return;

            IsDataLoaded = false;
            GDOItems.Clear();
            await PremiseServer.Instance.StartSubscriptionsAsync(new StreamSocketPremiseSocket());
            var o = new PremiseObject("sys://Home/Upstairs/Garage/East Garage Door");
            o.AddPropertyAsync("Description", "Lower East Garage", PremiseProperty.PremiseType.TypeText);
            o.AddPropertyAsync("GarageDoorOpened", PremiseProperty.PremiseType.TypeBoolean, true);
            o.AddPropertyAsync("Trigger", PremiseProperty.PremiseType.TypeBoolean);
            GDOItems.Add(o);

            o = new PremiseObject("sys://Home/Upstairs/Garage/West Garage Door");
            o.AddPropertyAsync("Description", "Lower West Garage", PremiseProperty.PremiseType.TypeText);
            o.AddPropertyAsync("GarageDoorOpened", PremiseProperty.PremiseType.TypeBoolean, true);
            o.AddPropertyAsync("Trigger", PremiseProperty.PremiseType.TypeBoolean);
            GDOItems.Add(o);

            o = new PremiseObject("sys://Home/Upper Garage/East Garage Door");
            o.AddPropertyAsync("Description", "Upper East Garage", PremiseProperty.PremiseType.TypeText);
            o.AddPropertyAsync("GarageDoorOpened", PremiseProperty.PremiseType.TypeBoolean, true);
            o.AddPropertyAsync("Trigger", PremiseProperty.PremiseType.TypeBoolean);
            GDOItems.Add(o);

            o = new PremiseObject("sys://Home/Upper Garage/Center Garage Door");
            o.AddPropertyAsync("Description", "Upper Center Garage", PremiseProperty.PremiseType.TypeText);
            o.AddPropertyAsync("GarageDoorOpened", PremiseProperty.PremiseType.TypeBoolean, true);
            o.AddPropertyAsync("Trigger", PremiseProperty.PremiseType.TypeBoolean);
            GDOItems.Add(o);

            o = new PremiseObject("sys://Home/Upper Garage/West Garage Door");
            o.AddPropertyAsync("Description", "Upper West Garage", PremiseProperty.PremiseType.TypeText);
            o.AddPropertyAsync("GarageDoorOpened", PremiseProperty.PremiseType.TypeBoolean, true);
            o.AddPropertyAsync("Trigger", PremiseProperty.PremiseType.TypeBoolean);
            GDOItems.Add(o);

            LightsOff = new PremiseObject("sys://Home/Admin/All House Scenes/Upper Garage Off");
            LightsOff.AddPropertyAsync("DisplayName", "Upper Garage Lights Off", PremiseProperty.PremiseType.TypeText, true);
            LightsOff.AddPropertyAsync("Status", PremiseProperty.PremiseType.TypeBoolean, true);
            LightsOff.AddPropertyAsync("Trigger", PremiseProperty.PremiseType.TypeBoolean);

            GDOPower = new PremiseObject("sys://Home/Admin/Garage Door Power");
            GDOPower.AddPropertyAsync("DisplayName", "GDO Power", PremiseProperty.PremiseType.TypeText, true); 
            GDOPower.AddPropertyAsync("State", PremiseProperty.PremiseType.TypeBoolean, true);

            IsDataLoaded = true;
        }
コード例 #4
0
ファイル: MainViewModel.cs プロジェクト: tig/Premise
 public MainViewModel() {
     Server.PropertyChanged += (sender, args) => {
         if (args.PropertyName == "Connected") {
             Debug.WriteLine("Connected: {0}", Server.Connected);
             if (PremiseServer.Instance.Connected) {
                 Home = new PremiseObject("sys://Home");
                 Home.AddPropertyAsync("DisplayName", PremiseProperty.PremiseType.TypeText, true);
             }
             else {
                 
             }
         }
         Connected = PremiseServer.Instance.Connected;
     };
     this.Items = new ObservableCollection<PremiseObject>();
 }