Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would be nice to limit "networks" via config, code tweak to blink.js:refreshData included #41

Open
philromine opened this issue Jan 5, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@philromine
Copy link

philromine commented Jan 5, 2021

Wanted to include only cameras for a specific network. Code suggested is below, five lines starting with // only show comment, enabled by adding array of desired networks names to config (if no config.networks, system works as before).

       async refreshData(force = false) {
              const ttl = force ? 0 : (this.config["camera-status-polling-seconds"] || STATUS_POLL);
              const homescreen = await this.blinkAPI.getAccountHomescreen(ttl);
              homescreen.cameras.push(...homescreen.owls);
              for (const network of homescreen.networks) {
                  network.syncModule = homescreen.sync_modules.filter(sm => sm.network_id === network.id)[0];
              }
      
              // only show items from networks listed in config
              if (this.config.networks) {
                  homescreen.networks = homescreen.networks.filter(n => this.config.networks.includes(n.name));
                  homescreen.cameras = homescreen.cameras.filter(c => homescreen.networks.map(n => n.id).includes(c.network_id));
              }
      
              if (this.networks && this.networks.size > 0) {
                  for (const n of homescreen.networks) {
                      //TODO: new networks?
                      if (this.networks.has(n.id)) this.networks.get(n.id).data = n;
                  }
                  for (const c of homescreen.cameras) {
                      //TODO: new cameras?
                      if (this.cameras.has(c.id)) this.cameras.get(c.id).data = c;
                  }
              }
              else {
                  this.networks = new Map(homescreen.networks.map(n => [n.id, new BlinkNetwork(n, this)]));
                  this.cameras = new Map(homescreen.cameras.map(c => [c.id, new BlinkCamera(c, this)]));
              }
              return homescreen;
          }
@colinbendell colinbendell added the enhancement New feature or request label Feb 21, 2021
@colinbendell
Copy link
Owner

Thanks! I'll look to integrate this in a coming version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants