public void AfterPluginsLoaded(IAppHost appHost) { var container = appHost.GetContainer(); if (container.Exists<IpModuleManager>()) { var manager = container.Resolve<IpModuleManager>(); manager.DeviceStatusChanged += (sender, args) => { logger.DebugFormat("{0}:{1}[{2}]", args.Device.Name, args.Device.Status, args.Device.ZoneId); var settings = container.Resolve<SmartThingsSettings>(); var cb = new SmartThingsCallbacks(settings); cb.PutDeviceUpdate(args.Device); }; manager.PartitionStatusChanged += (sender, args) => { logger.DebugFormat("{0}:{1}", args.Partition.Name, args.Partition.Status); var settings = container.Resolve<SmartThingsSettings>(); var cb = new SmartThingsCallbacks(settings); cb.PutPartitionUpdate(args.Partition); }; } else { logger.Error("Cannot find Ip Module Manager to register device and partition status changes events for SmartThings"); } }
public void AfterPluginsLoaded(IAppHost appHost) { var container = appHost.GetContainer(); if (container.Exists <IpModuleManager>()) { var manager = container.Resolve <IpModuleManager>(); manager.DeviceStatusChanged += (sender, args) => { logger.DebugFormat("{0}:{1}[{2}]", args.Device.Name, args.Device.Status, args.Device.ZoneId); var settings = container.Resolve <SmartThingsSettings>(); var cb = new SmartThingsCallbacks(settings); cb.PutDeviceUpdate(args.Device); }; manager.PartitionStatusChanged += (sender, args) => { logger.DebugFormat("{0}:{1}", args.Partition.Name, args.Partition.Status); var settings = container.Resolve <SmartThingsSettings>(); var cb = new SmartThingsCallbacks(settings); cb.PutPartitionUpdate(args.Partition); }; } else { logger.Error("Cannot find Ip Module Manager to register device and partition status changes events for SmartThings"); } }
public ResponseStatus Get(SmartThingsSettingsResetRequest request) { settings.AccessToken = null; settings.Location = null; settings.ApplicationId = null; var settingsProvider = new SettingsProvider(new RoamingAppDataStorage("Paradox")); settingsProvider.SaveSettings(settings); var cb = new SmartThingsCallbacks(settings); return !cb.AuthorizationRevoke() ? new ResponseStatus("404", "Couldn't connect to ST hub") : new ResponseStatus(); }
public ResponseStatus Put(SmartThingsSettingsRequest request) { // always reset values settings.AccessToken = request.AccessToken; settings.Location = request.Location; settings.ApplicationId = request.AppId; var settingsProvider = new SettingsProvider(new RoamingAppDataStorage("Paradox")); settingsProvider.SaveSettings(settings); var cb = new SmartThingsCallbacks(settings); return !cb.Authorization() ? new ResponseStatus("404", "Couldn't connect to ST hub") : new ResponseStatus(); }
public ResponseStatus Get(SmartThingsSettingsResetRequest request) { settings.AccessToken = null; settings.Location = null; settings.ApplicationId = null; var settingsProvider = new SettingsProvider(new RoamingAppDataStorage("Paradox")); settingsProvider.SaveSettings(settings); var cb = new SmartThingsCallbacks(settings); return(!cb.AuthorizationRevoke() ? new ResponseStatus("404", "Couldn't connect to ST hub") : new ResponseStatus()); }
public ResponseStatus Put(SmartThingsSettingsRequest request) { // always reset values settings.AccessToken = request.AccessToken; settings.Location = request.Location; settings.ApplicationId = request.AppId; var settingsProvider = new SettingsProvider(new RoamingAppDataStorage("Paradox")); settingsProvider.SaveSettings(settings); var cb = new SmartThingsCallbacks(settings); return(!cb.Authorization() ? new ResponseStatus("404", "Couldn't connect to ST hub") : new ResponseStatus()); }