Giter Site home page Giter Site logo

tagno25 / octorelay Goto Github PK

View Code? Open in Web Editor NEW

This project forked from borisbu/octorelay

0.0 0.0 0.0 4.13 MB

OctoPrint / Octopi plugin to control relays

License: GNU Affero General Public License v3.0

Shell 0.10% Python 86.82% TypeScript 8.63% SCSS 0.60% Jinja 3.86%

octorelay's Introduction

OctoRelay

CI CodeQL Coverage Status Downloads of latest release

The plugin adds buttons to control GPIO pins of Raspberry Pi for switching relays and indicating their states.

WebUI interface

In this screenshot, the black printer icon shows the ON state of its relay, and the gray ones indicate OFF. The plugin allows you to set your own icons and flexibly customize the way the relay states are displayed.

I use it with a 4 relay board, and printed this case for it. Just hooked up the GPIO pins with the relay board, and now I can turn the power of the printer, the fan and the light on and off with OctoPrint.

This plugin was based on the OctoLight Plugin by Žiga Kralj, thanks ;-)

Boris Burgstaller

Relay Board Raspberry Pi GPIO

Requirements

Setup

Install via the bundled Plugin Manager or manually using this URL:

https://github.com/borisbu/OctoRelay/releases/latest/download/release.zip

In case you want to enable the plugin for user groups other than admins and users (operators), you need to grant them the permission "Relay switching" in the "Access control" section of OctoPrint settings.

After installing the plugin you need to configure it in order to see the control buttons in the navigation bar.

Configuration

Settings panel

Currently, OctoRelay supports up to 8 relays represented by the tabs on the top of the settings screen. Each relay has the following settings (in order of appearance):

Setting Description
Active Activates the relay control and indication on the navigation bar
Label The relay description to show on tooltip and in dialogs
Icon ON / OFF An image or emoji to indicate the relay state (supports HTML)
This is printer relay Closes the printer connection when turning this relay OFF
AutoConnect delay Printer relay feature adjustment when turning it ON
GPIO Number The GPIO pin on the Raspberry Pi
Inverted output For normally closed relay: the relay is ON without power
Confirm turning OFF Enables a confirmation dialog when turning the relay OFF
Alert on switches ahead Notifies on upcoming switch with an ability to cancel it
Events: Behavior customization (automation)
on Startup The state to switch the relay to when OctoPrint started
on Printing Started The state to switch the relay to when started printing
on Printing Stopped The state to switch the relay to when stopped printing
after Turned ON The state to switch the relay to after it has been turned ON
skip (option) No action should be taken
delay Postpones the action for the time specified in seconds
Side effects: Additional actions in certain cases
Command ON / OFF An optional OS command to run when toggling the relay

Operation

You can toggle the relays ON and OFF the following ways:

  • By clicking the control buttons on the navigation bar.
    • The icon you choose for the button will display the current state.
  • By sending GCODE command @OCTORELAY r#.
    • Where # is relay index from 1 to 8.
  • Or by querying the API (see below).

OctoRelay API

Relays can be queried and updated through the OctoPrint API. Read that documentation on how to get an API Key.

Change the relay state

This query turns the relay r1 OFF:

curl 'http://octopi.local/api/plugin/octorelay' \
  -H 'X-Api-Key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{ "command": "update", "subject": "r1", "target": false }'

# Sample response:
# {
#   "status": false
# }

The target entry in request payload is an optional boolean parameter. When it's null or omitted the relay will toggle. The status entry in the response payload reflects the relay state as the outcome of the request.

Request the relay state

This query provides the status or the relay r1:

curl 'http://octopi.local/api/plugin/octorelay' \
  -H 'X-Api-Key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{ "command": "getStatus", "subject": "r1" }'

# Sample response:
# {
#   "status": true
# }

List all the relay states

This query provides the statuses of all the relays:

curl 'http://octopi.local/api/plugin/octorelay' \
  -H 'X-Api-Key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{ "command": "listAllStatus" }'

# Sample response:
# [
#   {
#     "status": true,
#     "id": "r1",
#     "name": "Light"
#   },
#   {
#     "status": false,
#     "id": "r2",
#     "name": "Printer"
#   }
# ]

The status entry reflects the actual state of the relay.

Updates

Check out the versions, their features and bug fixes in the Changelog.

octorelay's People

Contributors

robintail avatar borisbu avatar bastienstefani avatar deymos42 avatar jneilliii avatar skobkars avatar sydrbloc avatar patrickcollins12 avatar hcooper avatar tagno25 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.