Giter Site home page Giter Site logo

smart's Introduction

Smart Attenuation Boilerplate

Purpose

The smart attenuation server is designed to run 27/4 using foreverit takes data from the Met Office RSS feed and searches it for data relating to Yellow and Red warnings for Rain.

Installing and running

git clone https://github.com/wilburforce83/smart.git then; cd smart then; npm install

Parameters for each project

You will need to set the paramters for each project you can do this in any IDE, or if you are on linux you can just cd lib, sudo nano globals.js

// Variables

  client_company: "test FM team", // client name of FM company
  rss: "https://www.metoffice.gov.uk/public/data/PWSCache/WarningsRSS/Region/UK.xml",
  location: "London ", // as per MET OFFICE RSS feed IMPORTANT!!! If location is London add a space before " to avoid londonderry triggering a false positive.
  warnings: "rain", // Type of event
  frequency: "15", // in minutes

to run; cd smart then, npm start

Work to be completed still

The daemon will need to be installed on a raspberry pi, and the npm module relay-raspberry will need installing:

once on the rpi and the repo is set up and installed is installed you will need install relay-raspberry:

npm i relay-raspberry

https://www.npmjs.com/search?q=relay

You will need to inject the code for the relay into the trigger function, triggering an attached relay. You will need it to stay powered until the warning clears:

An example enabling the relay on the GPIO 4 and printing its current state.

let relay = new Relay(4, 7000); // 4 is the PIN number, 7000 is the number of seconds after which the relay will be deactivated.
relay.enable(); // enables the relay
 
// Gets the current state of the relay
relay.getState().then((value) => {
    switch (value) {
        case 1:
            console.log("Enabled !");
            break;
        case 0:
            console.log("Disabled !");
            break;
    }
});

Finally, if you want the system to email a user you could easily add a logging system and email notification to keep people up to date with the current state. This has not been set up, but is easy to do.

Requirements.

Some modules require Node 10.16.2 The bot has been written on on 10.16.2, but may work on lower versions.

Error Handling

There should be fairly comprehensive error handling, the bot shouldnavigate most errors and carry on. In the event that there is an error, in order to keep the bot running 24/7 i recommend using one of the following:

https://www.npmjs.com/package/forever

or

https://www.npmjs.com/package/nodemon

Issues and PR's

I am happy to receive any bugs, issues or pull requests to help make the code better, and improve functionality.

License

Copyright 2021 Will Shearer.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

smart's People

Contributors

wilburforce83 avatar

Watchers

James Cloos avatar  avatar

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.