Skip to content

Commit

Permalink
Only send sensor data if changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
mannkind committed Apr 1, 2019
1 parent 6ddc552 commit bf76d09
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
34 changes: 25 additions & 9 deletions ESPHomeRoombaComponent.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "esphomelib.h"
#include "esphome.h"
#include <Roomba.h>
using namespace esphomelib;

Expand Down Expand Up @@ -318,13 +318,29 @@ class RoombaComponent : public PollingComponent
dockedState = current > -50;
chargingState = charging == Roomba::ChargeStateReconditioningCharging || charging == Roomba::ChargeStateFullChanrging || charging == Roomba::ChargeStateTrickleCharging;

this->distance_sensor->publish_state(distance);
this->voltage_sensor->publish_state(voltage);
this->current_sensor->publish_state(current);
this->charge_sensor->publish_state(charge);
this->capacity_sensor->publish_state(capacity);
this->chargingState_sensor->publish_state(chargingState);
this->dockedState_sensor->publish_state(dockedState);
this->cleaningState_sensor->publish_state(cleaningState);
if (this->distance_sensor->state != distance) {
this->distance_sensor->publish_state(distance);
}
if (this->voltage_sensor->state != voltage) {
this->voltage_sensor->publish_state(voltage);
}
if (this->current_sensor->state != current) {
this->current_sensor->publish_state(current);
}
if (this->charge_sensor->state != charge) {
this->charge_sensor->publish_state(charge);
}
if (this->capacity_sensor->state != capacity) {
this->capacity_sensor->publish_state(capacity);
}
if (this->chargingState_sensor->state != chargingState) {
this->chargingState_sensor->publish_state(chargingState);
}
if (this->dockedState_sensor->state != dockedState) {
this->dockedState_sensor->publish_state(dockedState);
}
if (this->cleaningState_sensor->state != cleaningState) {
this->cleaningState_sensor->publish_state(cleaningState);
}
}
};
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Roomba Component for ESPHome

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.
Tested with ESPHome 1.12.1, and a Roomba 650 w/a Wemos D1 Mini installed.

## Setup/Use

Expand Down

0 comments on commit bf76d09

Please sign in to comment.