Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Xiaomi Mi Scale V1 and V2 #691

Closed
wants to merge 116 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
cfcc4a4
Add support for Xiaomi BLE Scale V1 and V2
tiagofreire-pt Aug 10, 2019
f043468
Update xiaomi_ble.h
tiagofreire-pt Aug 10, 2019
6e1eb5d
Create __init__.py
tiagofreire-pt Aug 10, 2019
b8235f7
Create sensor.py
tiagofreire-pt Aug 10, 2019
c87ef7c
Create xiaomi_miscale.cpp
tiagofreire-pt Aug 10, 2019
ee67249
Create xiaomi_miscale.h
tiagofreire-pt Aug 10, 2019
48f35c1
Update esphome/components/xiaomi_ble/xiaomi_ble.cpp
tiagofreire-pt Aug 13, 2019
effed96
Update __init__.py
tiagofreire-pt Aug 13, 2019
0976095
Update __init__.py
tiagofreire-pt Aug 13, 2019
e774d99
Update sensor.py
tiagofreire-pt Aug 13, 2019
d049f43
Update const.py
tiagofreire-pt Aug 13, 2019
dbd4bad
Update __init__.py
tiagofreire-pt Aug 13, 2019
01921de
Delete __init__.py
tiagofreire-pt Aug 13, 2019
a6d7225
Create __init__.py
tiagofreire-pt Aug 13, 2019
f2a4d2e
Delete __init__.py
tiagofreire-pt Aug 13, 2019
1aafaa4
Add files via upload
tiagofreire-pt Aug 13, 2019
8ebea04
Update __init__.py
tiagofreire-pt Aug 13, 2019
9bfc5cf
Update __init__.py
tiagofreire-pt Aug 13, 2019
9effe68
Update sensor.py
tiagofreire-pt Aug 13, 2019
2dc330e
Update xiaomi_ble.cpp
tiagofreire-pt Aug 21, 2019
33f4c16
Update xiaomi_ble.h
tiagofreire-pt Aug 21, 2019
0a6d220
Update const.py
tiagofreire-pt Aug 21, 2019
7ff7ac5
Update sensor.py
tiagofreire-pt Aug 21, 2019
aa091f6
Update sensor.py
tiagofreire-pt Aug 21, 2019
b3eab9c
Update sensor.py
tiagofreire-pt Aug 21, 2019
6d2663c
Update xiaomi_miscale.h
tiagofreire-pt Aug 21, 2019
a03d905
Update const.py
tiagofreire-pt Aug 21, 2019
54cc905
Update sensor.py
tiagofreire-pt Aug 21, 2019
e942b4c
Update const.py
tiagofreire-pt Aug 21, 2019
05dd0be
Update xiaomi_ble.cpp
tiagofreire-pt Aug 22, 2019
32fc914
Update xiaomi_ble.cpp
tiagofreire-pt Aug 22, 2019
6ba132e
Update sensor.py
tiagofreire-pt Aug 22, 2019
8a817f1
Update sensor.py
tiagofreire-pt Aug 22, 2019
b451b3e
Update sensor.py
tiagofreire-pt Aug 22, 2019
1d92efa
Update sensor.py
tiagofreire-pt Aug 22, 2019
b4a48d5
Update sensor.py
tiagofreire-pt Aug 22, 2019
961e0ea
Update sensor.py
tiagofreire-pt Aug 31, 2019
46531e5
Update esphome/const.py
tiagofreire-pt Aug 31, 2019
a7e6bc4
Update esphome/const.py
tiagofreire-pt Aug 31, 2019
8eb9dad
Update xiaomi_ble.h
tiagofreire-pt Aug 31, 2019
55a39be
Update xiaomi_ble.cpp
tiagofreire-pt Aug 31, 2019
8e35753
Merge branch 'dev' into patch-1
tiagofreire-pt Aug 31, 2019
a17dac7
Update sensor.py
tiagofreire-pt Aug 31, 2019
f549cce
Update sensor.py
tiagofreire-pt Aug 31, 2019
5ccd494
Update xiaomi_ble.cpp
tiagofreire-pt Sep 17, 2019
9059b3e
Update xiaomi_ble.cpp
tiagofreire-pt Sep 17, 2019
e78e361
Update xiaomi_ble.cpp
tiagofreire-pt Sep 17, 2019
be4c9bd
Update xiaomi_ble.cpp
tiagofreire-pt Sep 17, 2019
2bbce10
Update xiaomi_ble.cpp
tiagofreire-pt Sep 17, 2019
ce974ad
Update xiaomi_ble.cpp
tiagofreire-pt Sep 17, 2019
563df68
Update xiaomi_ble.cpp
tiagofreire-pt Sep 17, 2019
993f0c3
Update xiaomi_ble.cpp
tiagofreire-pt Sep 17, 2019
fa458bc
Update xiaomi_miscale.h
tiagofreire-pt Sep 17, 2019
0e65a94
Update xiaomi_ble.cpp
tiagofreire-pt Sep 17, 2019
419c23e
Merge branch 'dev' into xiaomi-scale
OttoWinter Oct 17, 2019
d83e1ef
Update xiaomi_ble.cpp
OttoWinter Oct 17, 2019
347184e
Merge branch 'dev' into xiaomi-scale
OttoWinter Oct 19, 2019
eef63cc
Rename to XMTZC0XHM
OttoWinter Oct 19, 2019
c69da4f
esphome/components/xiaomi_xmtzc0xhm/sensor.py:15:42: E128 continuatio…
tiagofreire-pt Nov 26, 2019
83f2a33
Split the SGP30 baseline into 2 values
panuruj Dec 30, 2019
7d7d319
Make both eCO2 and TVOC required if the optional baseline is defined
panuruj Dec 31, 2019
bd02165
Make dump_config() looks better
panuruj Dec 31, 2019
3332a84
Use b''.decode() instead of str(b'')
timsavage Jan 7, 2020
8d6b4a6
Adding the espressif 2.6.3
Valcob Jan 8, 2020
9bfab74
add miscale
Jan 9, 2020
1f65846
Merge branch 'dev' of github.com:dmkif/esphome; commit 'refs/pull/936…
Jan 9, 2020
1931018
fix hdc1080 timing problem
Jan 9, 2020
5854f32
Merge commit 'refs/pull/944/head' of github.com:esphome/esphome into dev
Jan 9, 2020
222cd0c
Merge commit 'refs/pull/941/head' of github.com:esphome/esphome into dev
Jan 9, 2020
6105caf
Merge branch 'dev' of github.com:esphome/esphome into dev
Jan 14, 2020
93eb902
add wakeup pin
Jan 15, 2020
9a55501
Merge remote-tracking branch 'origin' into ccs8811
Mar 3, 2020
ea55820
Merge branch 'dev', remote-tracking branch 'origin' into miscale
Mar 3, 2020
d8a16eb
Merge branch 'ccs8811' into miscale
Mar 3, 2020
3db67f8
add miscale v2 support
Mar 3, 2020
3e718ce
Merge branch 'dev' of github.com:esphome/esphome into miscale
Mar 12, 2020
b96bfb0
Merge branch 'dev' of github.com:esphome/esphome into miscale
Mar 16, 2020
1d334f8
Merge branch 'dev' of github.com:esphome/esphome into miscale
Mar 23, 2020
f001e54
Merge branch 'dev' of github.com:esphome/esphome into miscale
Apr 8, 2020
85f2f6c
Merge branch 'dev' of github.com:esphome/esphome into miscale
Apr 21, 2020
f13b3a7
Merge branch 'dev' of github.com:esphome/esphome into miscale
May 1, 2020
341d3f0
Merge branch 'patch-1' into miscale
tiagofreire-pt Jun 10, 2020
053caf3
Merge pull request #1 from dmkif/miscale
tiagofreire-pt Jun 10, 2020
852eaed
Merge branch 'dev' into patch-1
tiagofreire-pt Jun 10, 2020
23ca5bb
Update sensor.py
tiagofreire-pt Jun 10, 2020
aaea178
Update xiaomi_ble.h
tiagofreire-pt Jun 10, 2020
9b8b9e3
Update xiaomi_ble.cpp
tiagofreire-pt Jun 10, 2020
cd00912
Update sensor.py
tiagofreire-pt Jun 10, 2020
0ccc147
Update sensor.py
tiagofreire-pt Jun 10, 2020
8bedcf2
Update xiaomi_ble.cpp
tiagofreire-pt Jun 10, 2020
f9a776a
Update sensor.py
tiagofreire-pt Jun 10, 2020
f031dba
Update xiaomi_ble.cpp
tiagofreire-pt Jun 10, 2020
c17c738
Update const.py
tiagofreire-pt Jun 10, 2020
2797615
Update xiaomi_ble.cpp
tiagofreire-pt Jun 10, 2020
09bd5ca
Update xiaomi_ble.cpp
tiagofreire-pt Jun 10, 2020
4717100
Update const.py
tiagofreire-pt Jun 10, 2020
0cda688
Update sensor.py
tiagofreire-pt Jun 10, 2020
7042b4d
Update sensor.py
tiagofreire-pt Jun 10, 2020
b587296
Update xiaomi_ble.cpp
tiagofreire-pt Jun 10, 2020
6a9bda4
Update sensor.py
tiagofreire-pt Jun 10, 2020
bbe782e
Update xiaomi_ble.cpp
tiagofreire-pt Jun 10, 2020
eb27ad7
Update ccs811.cpp
tiagofreire-pt Jun 10, 2020
dc5d249
Update xiaomi_ble.cpp
tiagofreire-pt Jun 10, 2020
f6883b9
Update ccs811.h
tiagofreire-pt Jun 10, 2020
e4fbe1b
Update ccs811.cpp
tiagofreire-pt Jun 10, 2020
7493e1c
Update ccs811.cpp
tiagofreire-pt Jun 10, 2020
19121cc
Update ccs811.cpp
tiagofreire-pt Jun 10, 2020
7402e0c
Update ccs811.h
tiagofreire-pt Jun 10, 2020
7c32456
Update xiaomi_ble.cpp
tiagofreire-pt Jun 10, 2020
7e42571
Update xiaomi_ble.h
tiagofreire-pt Jun 10, 2020
90bfbe3
Update ccs811.h
tiagofreire-pt Jun 10, 2020
35ed834
Update xiaomi_ble.cpp
tiagofreire-pt Jun 10, 2020
b641904
Smaller Fixes
jan-loeffler Jul 6, 2020
4c20fa7
Merge pull request #2 from jan-loeffler/patch-1
tiagofreire-pt Jul 9, 2020
6567b22
Clang Formating
jan-loeffler Jul 9, 2020
c24acc9
Merge pull request #3 from jan-loeffler/patch-1
tiagofreire-pt Jul 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions esphome/components/ccs811/ccs811.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ static const char *TAG = "ccs811";
#define CHECKED_IO(f) CHECK_TRUE(f, COMMUNICAITON_FAILED)

void CCS811Component::setup() {
if (this->wakepin_) {
this->wakepin_->setup();
}
this->NO_PRIVATE_METHODS_ALWAYS_USE_PROTECTEDwakeup(true);
// page 9 programming guide - hwid is always 0x81
uint8_t hw_id;
CHECKED_IO(this->read_byte(0x20, &hw_id))
Expand Down Expand Up @@ -51,8 +55,11 @@ void CCS811Component::setup() {
// baseline available, write to sensor
this->write_bytes(0x11, decode_uint16(*this->baseline_));
}
this->NO_PRIVATE_METHODS_ALWAYS_USE_PROTECTEDwakeup(false);
}
void CCS811Component::update() {
// enable ccs8811
this->NO_PRIVATE_METHODS_ALWAYS_USE_PROTECTEDwakeup(true);
if (!this->status_has_data_())
this->status_set_warning();

Expand Down Expand Up @@ -84,6 +91,8 @@ void CCS811Component::update() {
this->status_clear_warning();

this->send_env_data_();
// disable ccs8811
this->NO_PRIVATE_METHODS_ALWAYS_USE_PROTECTEDwakeup(false);
}
void CCS811Component::send_env_data_() {
if (this->humidity_ == nullptr && this->temperature_ == nullptr)
Expand Down Expand Up @@ -111,6 +120,11 @@ void CCS811Component::dump_config() {
ESP_LOGCONFIG(TAG, "CCS811");
LOG_I2C_DEVICE(this)
LOG_UPDATE_INTERVAL(this)
if (this->wakepin_) {
ESP_LOGCONFIG(TAG, " WAKEUP Pin: GPIO%u", this->wakepin_->get_pin());
} else {
ESP_LOGCONFIG(TAG, " WAKEUP Pin: NOT SET");
}
LOG_SENSOR(" ", "CO2 Sensor", this->co2_)
LOG_SENSOR(" ", "TVOC Sensor", this->tvoc_)
if (this->baseline_) {
Expand Down Expand Up @@ -142,6 +156,11 @@ void CCS811Component::dump_config() {
}
}
}
void CCS811Component::NO_PRIVATE_METHODS_ALWAYS_USE_PROTECTEDwakeup(boolean set_on) {
if (this->wakepin_ != nullptr) {
this->wakepin_->digital_write(!set_on);
}
}

} // namespace ccs811
} // namespace esphome
5 changes: 5 additions & 0 deletions esphome/components/ccs811/ccs811.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ namespace esphome {
namespace ccs811 {

class CCS811Component : public PollingComponent, public i2c::I2CDevice {
private:
void NO_PRIVATE_METHODS_ALWAYS_USE_PROTECTEDwakeup(boolean set_on);

public:
void set_wakepin(GPIOPin *wakepin) { wakepin_ = wakepin; }
void set_co2(sensor::Sensor *co2) { co2_ = co2; }
void set_tvoc(sensor::Sensor *tvoc) { tvoc_ = tvoc; }
void set_baseline(uint16_t baseline) { baseline_ = baseline; }
Expand Down Expand Up @@ -48,6 +52,7 @@ class CCS811Component : public PollingComponent, public i2c::I2CDevice {
sensor::Sensor *humidity_{nullptr};
/// Input sensor for temperature reading.
sensor::Sensor *temperature_{nullptr};
GPIOPin *wakepin_{nullptr};
};

} // namespace ccs811
Expand Down
10 changes: 9 additions & 1 deletion esphome/components/ccs811/sensor.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import esphome.codegen as cg
from esphome import pins
# from esphome.components import output
import esphome.config_validation as cv
from esphome.components import i2c, sensor
from esphome.const import CONF_ID, ICON_RADIATOR, UNIT_PARTS_PER_MILLION, \
UNIT_PARTS_PER_BILLION, CONF_TEMPERATURE, CONF_HUMIDITY, ICON_PERIODIC_TABLE_CO2
UNIT_PARTS_PER_BILLION, CONF_TEMPERATURE, CONF_HUMIDITY, ICON_PERIODIC_TABLE_CO2, \
CONF_WAKEUP_PIN

DEPENDENCIES = ['i2c']

Expand All @@ -22,6 +25,7 @@
cv.Optional(CONF_BASELINE): cv.hex_uint16_t,
cv.Optional(CONF_TEMPERATURE): cv.use_id(sensor.Sensor),
cv.Optional(CONF_HUMIDITY): cv.use_id(sensor.Sensor),
cv.Optional(CONF_WAKEUP_PIN): pins.gpio_output_pin_schema,
}).extend(cv.polling_component_schema('60s')).extend(i2c.i2c_device_schema(0x5A))


Expand All @@ -44,3 +48,7 @@ def to_code(config):
if CONF_HUMIDITY in config:
sens = yield cg.get_variable(config[CONF_HUMIDITY])
cg.add(var.set_humidity(sens))

if CONF_WAKEUP_PIN in config:
wakepin = yield cg.gpio_pin_expression(config[CONF_WAKEUP_PIN])
cg.add(var.set_wakepin(wakepin))