Git Product home page Git Product logo

restsmart's Introduction

restSmart

Hosts a REST Server on an ESP32 to set variables of different types. Compatible with openHAB HTTP Binding.

Features:

  • Optional automatic storage of data in EEPROM
  • Automatic WiFi reconnect
  • Easily controlled through a simple REST interface

Available Prop types:

  • Boolean
  • Float
  • Int
  • Color
  • String

Read/Write values

To read values you need to send an HTTP GET request to /get/propname. You can easily do this in your browser (navigate to http://devicename/get/propname) or via Postman.

To write values you need to send an HTTP PUT request to /set/propname. This is done most easily via Postman, where you can put the data to be set in the "Body" settings with the type set to "raw".

Connect to openHAB

NOTE: There was a bug with the HTTP Binding so it would parse any valid RGB color value to "UNDEF". I fixed this in Pull Request #10897, so the fix will appear in openHAB version 3.1.

  1. Install HTTP Binding
  2. Add new HTTP thing with baseURL http://devicename/ where devicename is the wifiHostname specified in your ESP32 sketch
  3. Go to the "Code" tab and set up the commandMethod PUT and your desired channels, as shown in this example (* means don't change):
UID: *
label: *
thingTypeUID: http:url
configuration:
  baseURL: *
  refresh: 10
  commandMethod: PUT
channels:
  - id: brightness
    channelTypeUID: http:dimmer
    label: Brightness
    description: ""
    configuration:
      stateExtension: get/brightness
      commandExtension: set/brightness
  - id: power
    channelTypeUID: http:switch
    label: Power
    description: ""
    configuration:
      stateExtension: get/power
      commandExtension: set/power
      onValue: ON
      offValue: OFF
  - id: color
    channelTypeUID: http:color
    label: Color
    description: ""
    configuration:
      stateExtension: get/color
      commandExtension: set/color
      colorMode: RGB

This example is compatible with the "simple" example sketch.

restsmart's People

Contributors

ryz3d 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.