GithubHelp home page GithubHelp logo

guipas / piwr Goto Github PK

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

A minimal remote control for your raspbery pi. Control your raspberry pi from your phone (or any web browser). You can configure buttons by modifying the config.ts file.

TypeScript 85.45% JavaScript 2.56% CSS 11.99%

piwr's Introduction

Piwr (Pi Web Remote)

A small application that serves as a remote control for a raspbery pie. You can configure buttons by modifying the config.ts file.

Features:

  • Neumorphic styles
  • Built on NextJS
  • Add as many buttons as you wish
    • Each button can have a healthcheck, ie a function that will be run in the backend, and depending on the result the button LED will change color and/or display a particular message
    • Each button can have an action, ie a function that will run in the backend when clicking on the button.
  • Run it with the docker-compose file included

Important note: this application does not implement any authentication system. I don't care because I run it on a local network, with a limited number of actions to perform... but keep in mind that if you dont protect this application behind, for example, an API gateway, everybody on your network will be able to use this remote control.

Install

  1. Clone this repo git clone [email protected]:guipas/telepi.git
  2. Modify the config.ts file to suit you needs (see example below)
  3. Launch it with docker compose, docker-compose up -d

Configure

You can easily add buttons to perform various action by modifying the config.ts file.

export const config: Config = {
  title: 'My Raspberry Pie',
  buttons: [
    {
      id: 'pi_status',
      labels: {
        // those labels will be display in the button depending on the healthcheck results
        success: 'On',
        error: 'Off',
        confirm: 'Reboot ?',
        pending: 'Rebooting',
      },
      healthCheck: true, // can be a boolean or function (see below), if it's a boolean, it will basically just check if the app is running
      action: (req: NextApiRequest, res: NextApiResponse) => {
        // you can acces the NodeJS API from there, this will be executed in the backend
        // when the user click on the button
        if (req.method === 'POST') {
          fs.writeFileSync(`/trigger`, 'b');
        }
      }
    },
    {
      id: 'external_hdd_status',
      labels: {
        success: 'HDD',
        error: 'HDD Disconnected',
        pending: 'Checking HDD...',
      },
      healthCheck: async () => {
        // if the function throws an error, the button on the frontend will turn red
        // if the function succeed, the button will turn green
        if (process.env.TELEPI_HDD_PATH) {
          // for this example, the healthcheck checks if a particular path is accessible in our pi
          // if not, then this function will throw an error, the button will turn red on the frontend
          await fs.promises.readdir(process.env.TELEPI_HDD_PATH, 'utf-8');
        } else {
          console.error(`Enable to check if the HDD is connnected. The env varible TELEPI_HDD_PATH is not set`);
        }
      }
    },
  ]
};

Inspirations

piwr's People

Contributors

guipas avatar

Stargazers

 avatar

Watchers

 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.