Skip to content

Commit

Permalink
Upgraded to ESPHome 1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
mannkind committed Feb 1, 2019
1 parent 528b7b5 commit 6ddc552
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 148 deletions.
6 changes: 2 additions & 4 deletions ESPHomeLibRoombaComponent.h → ESPHomeRoombaComponent.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#include "esphomelib/application.h"
#include "esphomelib.h"
#include <Roomba.h>

using namespace esphomelib;

static const char *TAG = "component.Roomba";

Roomba roomba(&Serial, Roomba::Baud115200);
void roombaWakeup(uint8_t pin)
{
Expand Down Expand Up @@ -242,7 +240,7 @@ class RoombaComponent : public PollingComponent
roomba.start();

ESP_LOGD(TAG, "Attempting to subscribe to MQTT.");
mqtt::global_mqtt_client->subscribe(this->commandTopic, [&](const std::string &payload) {
mqtt::global_mqtt_client->subscribe(this->commandTopic, [&](const std::string &topic, const std::string &payload) {
ESP_LOGD(TAG, "Got values %s", payload.c_str());
if (payload == "turn_on")
{
Expand Down
50 changes: 4 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,8 @@
# Roomba Component for ESPHomeLib
# Roomba Component for ESPHome

A barebones wrapper to enable control of a Roomba via ESPHomeLib.
Tested with ESPHomeLib 1.9.1, and a Roomba 650 w/a Wemos D1 Mini installed.
A barebones wrapper to enable control of a Roomba via ESPHome.
Tested with ESPHome 1.10.0, and a Roomba 650 w/a Wemos D1 Mini installed.

## Setup/Use

Take a look at the example directory for a fully working example (very close to my setup).

In short:

* Add `#include "ESPHomeLibRoombaComponent.h"` under the esphomelib include.

* Add the following before `App.setup()`

```c++
auto *custom_roomba = new RoombaComponent(
"Distance",
"Voltage",
"Current",
"Charge",
"Capacity",
"Charging",
"Docked",
"Cleaning",
"On",
"Off",
"Dock",
"Locate",
"Spot Clean",
"Roomba/command", /* command_topic */
4, /* BRC Pin */
5000 /* Update Interval */
);

App.register_component(custom_roomba);
App.register_sensor(custom_roomba->distance_sensor);
App.register_sensor(custom_roomba->voltage_sensor);
App.register_sensor(custom_roomba->current_sensor);
App.register_sensor(custom_roomba->charge_sensor);
App.register_sensor(custom_roomba->capacity_sensor);
App.register_binary_sensor(custom_roomba->chargingState_sensor);
App.register_binary_sensor(custom_roomba->dockedState_sensor);
App.register_binary_sensor(custom_roomba->cleaningState_sensor);
App.register_switch(custom_roomba->on_switch);
App.register_switch(custom_roomba->off_switch);
App.register_switch(custom_roomba->dock_switch);
App.register_switch(custom_roomba->locate_switch);
App.register_switch(custom_roomba->spot_switch);
```
Take a look at the example directory for a fully working example (very close to my setup).
10 changes: 10 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Gitignore settings for esphomeyaml
# This is an example and may include too much for your use-case.
# You can modify this file to suit your needs.
/.esphomeyaml/
**/.pioenvs/
**/.piolibdeps/
**/lib/
**/src/
**/platformio.ini
/secrets.yaml
49 changes: 46 additions & 3 deletions example/roomba.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,61 @@
esphomeyaml:
use_custom_code: True
name: roomba
platform: ESP8266
board: esp01_1m
includes:
- ../ESPHomeRoombaComponent.h
libraries:
- Roomba=http://www.airspayce.com/mikem/arduino/Roomba/Roomba-1.4.zip

wifi:
ssid: "My Wifi SSID"
password: "My Wifi Password"

mqtt:
broker: "mosquitto.org"
broker: "test.mosquitto.org"
discovery: true

logger:
level: info

ota:
ota:

custom_component:
- lambda: |-
auto custom_roomba = new RoombaComponent(
"Roomba Distance",
"Roomba Voltage",
"Roomba Current",
"Roomba Charge",
"Roomba Capacity",
"Roomba Charging",
"Roomba Docked",
"Roomba Cleaning",
"Roomba On",
"Roomba Off",
"Roomba Dock",
"Roomba Locate",
"Roomba Spot Clean",
"roomba/command", /* command_topic */
4, /* BRC Pin */
5000 /* Update Interval */
);
App.register_component(custom_roomba);
App.register_sensor(custom_roomba->distance_sensor);
App.register_sensor(custom_roomba->voltage_sensor);
App.register_sensor(custom_roomba->current_sensor);
App.register_sensor(custom_roomba->charge_sensor);
App.register_sensor(custom_roomba->capacity_sensor);
App.register_binary_sensor(custom_roomba->chargingState_sensor);
App.register_binary_sensor(custom_roomba->dockedState_sensor);
App.register_binary_sensor(custom_roomba->cleaningState_sensor);
App.register_switch(custom_roomba->on_switch);
App.register_switch(custom_roomba->off_switch);
App.register_switch(custom_roomba->dock_switch);
App.register_switch(custom_roomba->locate_switch);
App.register_switch(custom_roomba->spot_switch);
return {custom_roomba};
switch:
29 changes: 0 additions & 29 deletions example/roomba/platformio.ini

This file was deleted.

66 changes: 0 additions & 66 deletions example/roomba/src/main.cpp

This file was deleted.

0 comments on commit 6ddc552

Please sign in to comment.