Giter Club home page Giter Club logo

sonoff-basic-openhab's Introduction

A Sonoff Basic firmware to work with openHAB

This firmware drives Sonoff Basic from iTead Studio, and powered by Mongoose OS. It targets to work with openHAB 2.4 or newer using the MQTT binding.

Features

  • LED blink pattern to indicate connectivity
  • On board button to toggle the switch manually in case of no connectivity
  • Bounce protection
  • Device local schedule timer
  • Countdown timer to toggle the switch
  • Switch ON duration counter for energy consumption analysis
  • Night Mode to turn off status LED
  • Web interface for setting up WiFi SSID and password
  • Reset to firmware defaults by holding the on board button for over 5 seconds

Configuration options

You have 2 options to implement this firmware:

  1. automatic configuration by Homie Convention

Homie Convention enables auto-discovery of the device by openHAB. Things, Channels and Items will be automatically setup.

  1. manual configuration with text files

openHAB UI

openHAB UI

energy consumption chart

Build for Homie support

Build using default cloud service:

cat mos-homie.yml > mos.yml
mos build --platform esp8266 \
  --build-var FLASH_SIZE=1048576 --build-var BOARD=esp8266-1M

Build for manual configuration

Build using default cloud service:

cat mos-manual.yml > mos.yml
mos build --platform esp8266 \
  --build-var FLASH_SIZE=1048576 --build-var BOARD=esp8266-1M

Flash

Sonoff Basic has only 1Mbytes flash.

mos flash --esp-flash-params "dout,8m,40m"

WiFi Setup

  1. Switch your PC or smartphone to the device's WiFi network. The SSID is named like Sonoff_??????, and the password is SonoffBasic.

  2. Use your browser to open http://192.168.4.1/

openHAB Configuration

If you choose the manual configration option, please check the manual folder.

Local schedule timer

Before using the local timer, make sure to set correct time zone via timer.tz.

For Example, a Hong Kong user:

mos config-set timer.tz=+0800

And a user in California (DST):

mos config-set timer.tz=-0700

Then, create a JSON file schedules.json and upload to the filesystem. Please reference the supplied sample for syntax.

Countdown timer

When the countdown timer reached zero, the switch will be toggled.

The local schedule timer will be disabled until the countdown is completed.

This timer is not persisted across reboots.

Night Mode

Example: set night mode from 23:00 to 6:30:

mos config-set nm.enable=true nm.bh=23 nm.bm=0 nm.eh=6 nm.em=30

Reset to firmware defaults

Press and hold the on board button for over 5 seconds.

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.