Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "devices" type that have inputs and outputs #1

Closed
shmick opened this issue Jan 16, 2016 · 1 comment
Closed

Add "devices" type that have inputs and outputs #1

shmick opened this issue Jan 16, 2016 · 1 comment

Comments

@shmick
Copy link

shmick commented Jan 16, 2016

First off, nice project. The UI is nice and clean.

Right now I have 2 garage doors that I'm currently controlling with my Pi, but I'd like a nicer web interface. Each door has an input and an output on the Pi. The input is a magnetic reed switch that reports door state ( open / close ) and the output is a relay that simulates a button push (on, wait, off).

The UI would then report red/green status based on the value of input pin, but would control the output pin

What would be nice is something like a "devices" type that would have properties such as:

  "devices": [
    {
      "name": "South Door",
      "input": "south_door_input"
      "output": "south_door_output",
      "outmode": "(pulse | toggle)"  # Or maybe define this in the pin config
    },
....
  "pins": [
    {
      "name": "south_door_input",
      "num": 7,
      "io": "in",
      "state": 0
    },
    {
      "name": "south_door_output",
      "num": 11,
      "io": "out",
      "state": 1 < state = low or high mode?
    },

Cheers.

@shmick shmick changed the title Add "devices" type that have input and output "pins" Add "devices" type that have inputs and outputs Jan 16, 2016
@octronic-uk
Copy link
Owner

Hi @shmick, Thanks I appreciate that :) I'm currently working on adding GPIO scripting capabilities that should allow the application to function as you've described. The implementation will allow you to define 'do', 'while' and 'then' conditions. basically in the following format (pseudo) I'll try to describe it using your application as an example.

And yes state refers to the setting of an IO pin HIGH or LOW.

Do: This will set the states for the relay and an 'opening' warning light (as an example of multiple outputs).

  "do": [
      { 
        "pin": "door_output_relay", 
        state: 1 
      },
      { 
        "pin": "door_warning_light", 
        state 1 
      }
  ]

While: Pause while waiting for a different pin's condition to change - In this case the 'door is open' reed switch. (so far equivalent of 'do ... while (door_open_input == 0)' )

  "while": [
      { 
        "pin": "door_open_input", 
        state: 0
      }
  ]

Then: Apply this state to the specified pins after the while condition is no longer satisfied.

  "then": [
      { 
        "pin": "door_output", 
        state: 0
      },
      { 
        "pin": "door_warning_light", 
        state 0
      }
  ]

Which forms the equivalent of

do:
  set door_output_relay to 1
  set door_warning light to 1
while:
 door_input == 0
then:
  set door_output_relay to 0
  set door_warning_light to 0

This script can be named something like "Open South Door" and triggered from the home screen in a similar way to the existing 'serial commands' section. Also the application's GPIO area can configure a gpio input to indicate the current state of 'door_input' on the home screen.

You will be able to set these scripts up by modifying the config.json file or through the UI in the app's settings page.

Hope this all makes sense :) I wanted to create a solution that kept the application as general-purpose as possible, so let me know if this will accomplish what you wanted.

Ash.

@shmick shmick closed this as completed Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants