GithubHelp home page GithubHelp logo

coko7 / somfy-home-controller Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 252 KB

Simple Node app to automatically control your Somfy shutters based on your local day cycle.

License: MIT License

JavaScript 94.76% Shell 5.24%
cli home-automation shutters somfy tahoma tahoma-api

somfy-home-controller's Introduction

๐Ÿ  somfy-home-controller

Simple Node app to automatically control your Somfy shutters based on your local day cycle.

๐Ÿงฐ Requirements

Make sure you have Node.js v16.18.0 installed. This project uses Import Assertions and when I tested with Node v16.14.0 it did not work, so I had to upgrade to v16.18.0.

I am not a Node expert so maybe there is a cleaner way to handle JSON file import within an ES6 module but this is working for now.

๐Ÿ› ๏ธ Setup

  1. Clone the repository and open it cd somfy-home-controller
  2. Add a new file shc-config.json at the project root:
{
  "somfyUrl": "ha101-1.overkiz.com",
  "pod": "XXXX-XXXX-XXXX",
  "port": 8443,
  "gatewaySuffix": "home",
  "token": "PUT_YOUR_SUPER_SECRET_TOKEN_HERE",
  "location": {
    "latitude": 0.0,
    "longitude": 0.0,
    "altitude": 0,
    "timezone": "Europe/Paris"
  },
  "devices": [
    {
      "protocol": "io",
      "id": "shutter_kitchen",
      "name": "Volet Cuisine",
      "url": "io://XXXX-XXXX-XXXX//1111111"
    },
    {
      "protocol": "io",
      "id": "shutter_kitchen_door",
      "name": "Volet Porte Cuisine",
      "url": "io://XXXX-XXXX-XXXX//2222222"
    },
    {
      "protocol": "io",
      "id": "shutter_room",
      "name": "Volet Chambre",
      "url": "io://XXXX-XXXX-XXXX/3333333"
    }
  ]
}
  1. Set the pod and token to link to your local Tahoma API

  2. Fill in the location data with (altitude and timezone are optional). But timezone is not supported yet anyway...

  3. Setup the devices you want to control automatically. Only shutters are supported.

  4. Once your config file is all set, you can test the script with npm start. But if you want to have this script running all day, you might want to use actual libraries such as pm2 or forever. In case you are using pm2, you can start the script in background like this:

    pm2 start npm --name "my-somfy-home-controller" -- start 

๐Ÿ’ป Command Line Interface

It is also possible to use a CLI to manually interact with the Tahoma box. To launch the CLI, simply enter npm run cli in your shell. Here is what the latest version of the CLI looks like:

image

If you want full control over a device, you should control it via the device mode.

You can enter device mode by typing load <id> in the general CLI. The <id> refers to the combination of digits after the gateway pin in the device URL.

๐Ÿ“š Resources

somfy-home-controller's People

Contributors

coko7 avatar riceeter avatar

Watchers

 avatar

somfy-home-controller's Issues

Add more logs

It would be useful to have the following logs:

  • When the script starts for the first time, log the time of the next event (open shutters if before sunrise, close shutters if before sunset)
  • After each event, log the time of the next event (time of open / close)

Add unit tests

Add unit tests for testing whether certain actions are executed at the right time of the day.
External lib such as Jest can be used.

Use suncalc npm package to get sunrise/sunset

Thanks to ChatGPT, it appears that there was already a package for getting sun positions based on latitude, longitude and timestamp all along!

It is the suncalc package by mourner: https://www.npmjs.com/package/suncalc

Very easy to use and good enough documentation too.

The next step is to replace the current implementation to use this package instead of reading sun positions from a prefetched CSV file. The times are relatively the same as the ones in the CSV, but they should be even more accurate as you can provide the exact latitude, longitude and altitude as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.