GithubHelp home page GithubHelp logo

davedavenport / arduino-connector-for-home-assistant Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dmurph24/arduino-connector-for-home-assistant

0.0 2.0 0.0 32 KB

Home Assistant Library for the ESP8266 chipset

License: MIT License

C 2.47% C++ 97.53%

arduino-connector-for-home-assistant's Introduction

Arduino Connector for Home Assistant

Contributors

  • Daniel Murphy (Creator)
  • Brandon Farmer (Examples of usage)

Supported Architectures

If you would like to contribute, please submit a pull request that matches the styling used in the current codebase and you will be added to the list of contributors.

  • All ESP8266 platforms

Dependencies

ESP8266HomeAssistant requires ArduinoJson to create and parse objects to Home Assistant. Therefore, this library must be installed. Additionally, the ESP8266 platform. This allows the device to use WiFi and HTTPClient libraries.

  1. Install the ArduinoJson library (ArduinoJson Website)
  1. Open the Arduino IDE and go to Preferences. In Additional Boards Manager URLs enter the following:
  • http://arduino.esp8266.com/stable/package_esp8266com_index.json

Installation

Download the ZIP from this repository. Unzip the contents and change the name of the unzipped folder to ESP8266HomeAssistant. Move the folder to the Ardunio/libraries/ directory on your computer.

Usage

The full usage of this library is included in the examples folder of this project (See example file). Below is a summary of the library functions:

Creating an instance

// Creates a singleton instance of the Home Assistant client
HomeAssistant ha;

Connecting WiFi and Home Assistant

// Connects to the wifi and Home Assistant server
ha.begin(WIFI_SSID, WIFI_PASS, HA_BASE_URL, HA_PASS);

// Check if Home Assistant is successfully connected
bool connected = ha.connected()

Reading a state from an entity

// Entity ID Example: light.kitchen_light
String state = ha.readState("light.kitchen_light");
if (state == "on") {
  // Do something awesome
}

Turning On/Off a light or other entity

// Toggle, or turn a light on or off
// This library also supports scripts, switches, and input booleans
// Check the src/HomeAssistant/HomeAssistantServices.h for all supported services or view on the README.md
ha.callEntityService(LIGHT_TURN_ON, LIGHT_ENTITY_ID);
ha.callEntityService(LIGHT_TURN_OFF, LIGHT_ENTITY_ID);
ha.callEntityService(LIGHT_TOGGLE, LIGHT_ENTITY_ID);

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.