npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hyperlink/open-window-service

v1.0.0

Published

http service that queries Open Weather API and Ecobee to answer if you should open your window for fresh air

Downloads

2

Readme

Hey Siri, should I open my window?

http service that queries Open Weather API and Ecobee to answer the question if you should open your window. Create an iOS shortcut to ask Siri if you should open your window.

Requirements

To register for an account:

  • Goto https://www.ecobee.com/developers
  • Click on Become a Developer
  • Sign in with your ecobee account
  • Agree to the terms

⚠️ The developer sign up doesn't play well with two-factor authentication turned on. If you have 2FA enabled make sure you disable it on your phone before signing up. You can always reenable it after signing up.

Open Weather Map API Account

  • Sign up for an account on: https://openweathermap.org/
  • Once confirming the sign up e-mail
  • Navigate to My API Keys
  • Copy the appId from your apps page

⚠️ App IDs takes time to get enabled so if you get an error abount an invalid app ID wait awhile.

Shortcuts app installed on your iOS Device

Download this app if you don't already have it on your phone: https://apps.apple.com/us/app/shortcuts/id1462947752

Installation

Clone repo or npm install

npm install -g @hyperlink/open-window-service

Get token to access ecobee

This step is a bit manual unfortunately. I didn't take any time to make this easy because is a one time taks. You're all setup once you get your refresh_token.

Login to Ecobee account

Once Ecobee developer account is registered login to your account and click Developer link to create an app. Fill out Application Name, Application Summary and make note of the API key. This key is what you would use in place for ECOBEE_CLIENT_ID environment variable

Make an http GET to https://api.ecobee.com/authorize?client_id=<your client ID>&response_type=ecobeePin&scope=smartWrite

that gives you a response:

{
    "ecobeePin": "XXXX-ABCD",
    "code": "<code needed for next request>",
    "interval": 5,
    "expires_in": 900,
    "scope": "openid,offline_access,smartWrite"
}

Then make a http POST to https://api.ecobee.com/token?grant_type=refresh_token&code=<code from above>&client_id=<your client ID>

To get the follow result.

{
    "access_token": "<really long string>",
    "token_type": "Bearer",
    "refresh_token": "<refresh_token>",
    "expires_in": 3600,
    "scope": "openid,smartWrite,offline_access"
}

ECOBEE_REFRESH_TOKEN should be the refresh_token result.

Get app ID from Open Weather

Set the app ID to WEATHER_APP_ID

Start the service

You can create a script to launch this or use PM2.

module.exports = {
  apps: [{
    name: 'Open Window Service',
    exec_mode: 'fork',
    instances: 1,
    script: 'src/index.ts',
    time: true,
    watch: 'src',
    env: {
      WEATHER_APP_ID: '<YOUR APP ID>',
      ECOBEE_REFRESH_TOKEN: '<YOUR TOKEN>',
      ECOBEE_CLIENT_ID: '<YOUR CLIENT ID>',
      // port the endpoint it's going to be on
      PORT: 3000
    }
  }]
};