Compare commits

..

144 Commits

Author SHA1 Message Date
Guillermo Ruffino
ab48e4a466 Merge pull request #1333 from esphome/bump-1.15.3
1.15.3
2020-10-23 00:16:18 -03:00
Guillermo Ruffino
8ef0f5b047 Lint 2020-10-23 00:06:05 -03:00
Guillermo Ruffino
2c14d134be Bump version to v1.15.3 2020-10-22 23:54:44 -03:00
ikatkov
9cd21bb5a0 AQICalculator is off by 1 (#1331)
Co-authored-by: Igor Katkov <ikatkov@atlassian.com>
2020-10-22 23:54:40 -03:00
thejonesyboy
bd061ac2ee fix: Incorrect time delay conversion breaks remote_transmitter_esp8266.cpp (#1322)
* Incorrect time delay conversion breaks remote_transmitter_esp8266.cpp

I'm unsure why the conversion from microseconds into whole millseconds and remaining microseconds is done using a value of 16383, rather than 1000. This breaks the "on", "off" times, as well as the repeat wait_time if the period is more than 16383 microseconds.

I have confirmed behaviour with an oscilloscope. See https://community.home-assistant.io/t/infrared-remote-transmitter-not-working/232825

* Update esphome/core/helpers.cpp

Co-authored-by: Guillermo Ruffino <glm.net@gmail.com>

Co-authored-by: Guillermo Ruffino <glm.net@gmail.com>
2020-10-22 23:54:39 -03:00
Andrej Komelj
dd3e821857 fix mqtt config check in OnlyWith configuration helper (#1304)
* fix config check in OnlyWith configuration helper

OnlyWith configuration helper check now verifies whether a component
is configured in any of the packages not only in raw configuration

* fix C0301(line-too-long) pylint in imports

* fix flake8 (E127) over-indented line
2020-10-22 23:54:25 -03:00
Guillermo Ruffino
b38b7019ea Fix scheduler with too many cancelled timers (#1309)
* Fix scheduler with too many cancelled timers

* lint

* use variable name
2020-10-22 23:46:38 -03:00
Marvin Gaube
2c71ee7853 Fix RGBW color-interlock control (#1325) 2020-10-22 23:46:37 -03:00
Alexander Leisentritt
540c62061d Fix Xiaomi merged packet parsing (#1293)
* Fix Xiaomi merged packet parsing

solves #1500

* renamed variables and updated payload and value checking

* renamed function and parameter

* add function to header

* changed log message
2020-10-22 23:46:35 -03:00
MartinWelsch
221ef07c8b Fix Light Trigger (#1308)
* make LightTransitionTransformer publish at end

* adjust on trigger + cleanup

* add target_state_reached_callback_

* fix format

* revert publish_at_end change

* fix bug for rapid on/off switching + remove debug logging

* formatting

* call state reached callback when no transition

Co-authored-by: Guillermo Ruffino <glm.net@gmail.com>
2020-10-22 23:46:34 -03:00
Samuel Sieb
29fc7ea154 Fix max7219digit chip_rotation: 180 (#1321)
Co-authored-by: Samuel Sieb <samuel@sieb.net>
2020-10-22 23:46:32 -03:00
Guillermo Ruffino
a3b2d384f5 Merge pull request #1292 from esphome/bump-1.15.2
1.15.2
2020-09-20 11:37:33 -03:00
Guillermo Ruffino
50238f8d72 Bump version to v1.15.2 2020-09-20 11:30:30 -03:00
Luke Fitzgerald
704470d606 fix(remote_receiver): Add missing pin setup for ESP32 (#1252) 2020-09-20 11:30:25 -03:00
Jesse Hills
f7e6195466 Readds the battery level for xiaomi_hhccjcy01 (#1288) 2020-09-20 11:30:24 -03:00
Jesse Hills
a0bb7c3ed0 Adds new homeassistant.tag_scanned action (#1281) 2020-09-20 11:30:22 -03:00
Guillermo Ruffino
c4edd3047f Merge pull request #1278 from esphome/bump-1.15.1
1.15.1
2020-09-14 22:03:13 -03:00
Guillermo Ruffino
c50da1593a Bump version to v1.15.1 2020-09-14 21:39:08 -03:00
Jesse Hills
1d06426281 Adds support for Tuya Climate temperature multiplier (#1276)
* Adds support for temperature multiplier

* Add new multiplier to test file

* Remove import

* Fixes
2020-09-14 21:39:04 -03:00
akoivist
9c5b693dd5 Fix for Ruuvi voltage parsing of RAWv2 format (#1267)
Power_info should be 2 bytes, so changed uint8 to uint16. With uint8 voltage is always reported to be near 1.6V.
2020-09-14 21:39:03 -03:00
Guillermo Ruffino
5fecc70db1 fix sntp timezone (#1266) 2020-09-14 21:39:01 -03:00
Guillermo Ruffino
1a04e2d1b8 Merge pull request #1277 from esphome/bump-1.15.0
1.15.0
2020-09-13 16:23:51 -03:00
Guillermo Ruffino
52c4dd0e35 Bump version to v1.15.0 2020-09-13 14:18:32 -03:00
Guillermo Ruffino
ff90f6a440 Merge branch 'beta' into bump-1.15.0 2020-09-13 14:18:19 -03:00
Guillermo Ruffino
51ab0f0b78 Bump version to v1.14.5 2020-06-23 22:39:24 -03:00
Otto Winter
bf0cce4ad8 Fix ESP32 interrupt enable/disable switched
Needs to be manually cherry-picked
2020-06-23 22:36:00 -03:00
Otto Winter
60e6366521 Bump version to v1.14.4 2020-06-05 12:56:23 +02:00
Otto Winter
072b2c445c Add ESP8266 core v2.6.2 (#905)
* Add ESP8266 core v2.6.2

* Upstream ESP8266 Wifi fixes

* Replace disable_interrupt with InterruptLock C++ class

* Update code to use InterruptLock

* Lint

* Update dht.cpp

* Improve InterruptLock docs, mark as ICACHE_RAM_ATTR

* Fixes
2020-06-05 12:56:10 +02:00
Otto Winter
219fe41831 Update ESP32 BLE ADV parse to match BLE spec (#904)
* Update ESP32 BLE ADV parse to match BLE spec

* Update xiaomi

* Update ruuvi

* Format

* Update esp32_ble_tracker.cpp

* Fix log

* Format

* Update xiaomi_ble.cpp
2020-06-05 12:55:24 +02:00
Otto Winter
dcc8bb83af Ignore ESP32 Camera unknown framesizes (#901)
Fixes https://github.com/esphome/issues/issues/866
2020-06-05 12:52:05 +02:00
Otto Winter
a8e3521f3c web_server call setup_controller (#899) 2020-06-05 12:52:05 +02:00
Otto Winter
706dc6d116 Fix MQTT logs Int or String expected Python 3 (#898)
Fixes https://github.com/esphome/issues/issues/850
2020-06-05 12:52:04 +02:00
Guillermo Ruffino
84accb6df6 fix climate_ir on receive optional (#897)
* fix climate on receive optional

* add climate tests
2020-06-05 12:52:04 +02:00
warpzone
8421570b18 fix the problem of missing part of advertising packet when activ… (#868)
* fix the problem of missing part of advertising packet when active scan is enabled.

* fix for ci-suggest-changes
2020-06-05 12:52:04 +02:00
Otto Winter
d355543ac9 Merge branch '1.14.4' 2020-06-05 12:42:56 +02:00
Otto Winter
3a597c5aa6 Fix gitignore intellij idea 2020-06-05 12:38:05 +02:00
Otto Winter
c7dddaded4 Upgrade docker base image to 2.1.1 2020-06-05 12:28:37 +02:00
Otto Winter
aae4b2ea5d Upgrade docker base image to 2.1.0 2020-06-05 12:27:26 +02:00
Otto Winter
310e2a0b20 Fix build 2020-06-05 12:25:29 +02:00
Niklas Wagner
0b04d143ac Upgrade dependencies 2020-06-05 12:00:20 +02:00
Otto Winter
53c231a7eb Revert "Atm90e32 pf fix (#841)"
This reverts commit 7842a55c81.
2019-11-17 23:37:00 +01:00
Otto Winter
d44ce82aa1 Bump version to v1.14.3 2019-11-17 23:34:04 +01:00
Otto Winter
a055de48e4 Change ESP8266 default wifi output power (#862)
See also https://github.com/esphome/issues/issues/455
2019-11-17 23:34:01 +01:00
Otto Winter
37b8d665fe Revert ESP32 BLE Tracker defaults (#863)
Fixes https://github.com/esphome/issues/issues/824
Fixes https://github.com/esphome/issues/issues/851
2019-11-17 23:34:01 +01:00
Otto Winter
dd7c8dabb1 Fix MQTT python 3 stringify IPAddress Type (#864)
Fixes https://github.com/esphome/issues/issues/850
2019-11-17 23:34:01 +01:00
Otto Winter
e41a9875e3 Improve WiFi disconnect messages (#857)
* Improve WiFi disconnect messages

* Fix

* Update wifi_component_esp32.cpp
2019-11-17 23:34:01 +01:00
Brandon Davidson
c5c42c4338 Tuya: Fix init sequence and handle wifi test command (#820)
* Handle WiFi test command

Also rename commands to match Tuya protocol docs

* Fix init sequence and product info check

* Fix clang-format suggestions

* Additional changes based on code review

* Fix temp command buffer scope

* Let the interval timer fire the first heatbeat

* Fix init steps; add logging

* Lint

* Remove setup_priority override

* Add delay to dump_config

* Refactor dump sequence

* Fix verbose logging

* Fix lints

* Don't bother suppressing duplicate config dumps

* nolint


Co-authored-by: Otto Winter <otto@otto-winter.com>
2019-11-17 23:34:00 +01:00
Brandon Davidson
531428b8b0 Fix logger uart conflict check (#858)
* Fix logger uart conflict check

* Fix class for check func

* Fix syntax

Hope lint is OK with moving the end of the conditional outside the #IFDEF

* Move end of conditional inside ifdef and remove extra whitespace

* Simplify

clang-format did not like the ifdefs and was reformatting in a way that killed clang-tidy.

Simple solution is to use logger's hw_serial as source of truth

Also simplifies the code - uart doesn't need to know what the logger uart settings mean
2019-11-17 23:34:00 +01:00
Otto Winter
ea8068e001 Switch to 115200 baud upload if 460800 fails (#856)
* Switch to 115200 baud upload if 460800 fails

* Update __main__.py
2019-11-17 23:34:00 +01:00
Mark
7842a55c81 Atm90e32 pf fix (#841)
* correct set_pf_sensor to set_power_factor_senor

* remove junk files added in error

* correct sensors.yaml reference to set_reactive_power

* Fixes
2019-11-17 23:33:56 +01:00
Samuel Sieb
51d39862b1 add position reporting to the template cover (#821)
* add position reporting to the template cover

* remove duplicate import

* use config flag instead


Co-authored-by: Samuel Sieb <samuel@sieb.net>
2019-11-17 23:33:21 +01:00
Otto Winter
bfea6ca79b Mark python 3.5 support deprecated (#849)
* Mark python 3.5 unsupported

Fixes https://github.com/esphome/issues/issues/831

* Update .travis.yml

* Update typing dep
2019-11-17 23:33:20 +01:00
Otto Winter
6297395018 Fix PZEM004T v2 (#846)
Fixes https://github.com/esphome/issues/issues/817
2019-11-17 23:33:20 +01:00
Otto Winter
a5b49dbfa6 Adjust some units (#852)
* Adjust some units

Fixes https://github.com/esphome/issues/issues/843

* Lint
2019-11-17 23:33:12 +01:00
Otto Winter
7c0d777173 Check DHT sensor exists before publishing (#850)
Fixes https://github.com/esphome/issues/issues/841
2019-11-17 23:31:36 +01:00
Otto Winter
74878276fc Web server CORS headers (#840)
* Add CORS header to web server

* Refactor

* Cleanup

See also https://github.com/esphome/issues/issues/806
2019-11-17 23:31:35 +01:00
Otto Winter
226e3b1dad Fix sensor force_update native API (#847)
Fixes https://github.com/esphome/issues/issues/842
2019-11-17 23:31:35 +01:00
Otto Winter
7752794fc5 Fix neopixelbus missing method pins (#848)
Fixes https://github.com/esphome/issues/issues/839
2019-11-17 23:31:35 +01:00
Otto Winter
b3094d6a53 Add missing state attribute (#851)
* Add api missing_state attribute

Fixes https://github.com/esphome/issues/issues/828

Adds a new property for missing state, so that HA can now when a sensor does not have a state yet.

* Update api.proto
2019-11-17 23:31:35 +01:00
Otto Winter
e3640e710f Add wifi output_power setting (#853)
* Add wifi output_power setting

See also:
 - https://github.com/esphome/feature-requests/issues/471#issuecomment-552350467
 - https://github.com/esp8266/Arduino/issues/6366
 - https://github.com/esp8266/Arduino/issues/6471
 - 849f8cf920/code/espurna/config/general.h (L593-L599)
 - https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/network/esp_wifi.html#_CPPv425esp_wifi_set_max_tx_power6int8_t

* Lint
2019-11-17 23:31:35 +01:00
Guillermo Ruffino
2ef64b55c5 fix missing checks of is_playing condition (#844) 2019-11-17 23:31:34 +01:00
Otto Winter
7f6672bb37 Fix calculations for negative sun declination (#839)
Fixes https://github.com/esphome/issues/issues/793

Also adds a clampd function that operates with doubles, not floats
2019-11-17 23:31:34 +01:00
Otto Winter
68a3b31628 Update variable in scheduler (#838)
Fixes https://github.com/esphome/issues/issues/826
2019-11-17 23:31:34 +01:00
Otto Winter
1b35855e68 Update platformio libraries (#837)
* Update platformio libraries

* Lint
2019-11-17 23:31:34 +01:00
Otto Winter
1e1837000d Fix homeassistant.service schema lambda (#833)
* Fix homeassistant.service schema lambda

Fixes https://github.com/esphome/issues/issues/820

* Improve

* Fix
2019-11-17 23:31:34 +01:00
Otto Winter
e2d5257632 Fix ESP32 rotary encoder (#834)
* Fix ESP32 rotary encoder

Fixes https://github.com/esphome/issues/issues/672

* Update rotary_encoder.cpp

* Lint
2019-11-17 23:31:34 +01:00
Otto Winter
387c75793b WiFi AP apply manual ip settings (#836) 2019-11-17 23:31:33 +01:00
Otto Winter
4f3a74d08a ESP8266 remove default opmode check (#835) 2019-11-17 23:31:33 +01:00
Otto Winter
fdbc59a159 Bump version to v1.14.2 2019-11-03 00:20:31 +01:00
Otto Winter
0db37bb55c Fix weird ESP8266 wifi crashes (#831)
* Try fix ESP8266 weird crashes

* Only call disconnect if STA is active
2019-11-03 00:20:25 +01:00
Otto Winter
2ff2750628 Fix stack trace decode for latest platformio (#830) 2019-11-02 21:19:36 +01:00
Otto Winter
eae5c17b87 Bump version to v1.14.1 2019-11-02 21:00:05 +01:00
Otto Winter
a59cde91ad Add servo missing restore option to codegen (#829)
See also https://github.com/esphome/issues/issues/609
2019-11-02 20:59:56 +01:00
Otto Winter
1f243ae37e Remove PCF8574 input_pullup mode and cleanup (#828)
Fixes https://github.com/esphome/issues/issues/755
Closes https://github.com/esphome/esphome/pull/822
Fixes https://github.com/esphome/issues/issues/667
Closes https://github.com/esphome/esphome/pull/808

Co-Authored-By: Amish Vishwakarma <amishv@users.noreply.github.com>
Co-Authored-By: S-Przybylski <s-przybylski@users.noreply.github.com>
2019-11-02 20:59:56 +01:00
Otto Winter
603f82977e Fix update-all input in dashboard (#826)
Fixes https://github.com/esphome/issues/issues/798
2019-11-02 20:59:56 +01:00
Otto Winter
2d70422a6f Move native API enums to new namespace (#825)
Fixes https://github.com/esphome/issues/issues/801
2019-11-02 20:59:55 +01:00
Otto Winter
e2c8b21195 Fix wizard mkdir (#824)
* Fix CLI wizard mkdir_p with empty path

Fixes https://github.com/esphome/issues/issues/796

* Cleanup

* Lint
2019-11-02 20:59:55 +01:00
Alexander Leisentritt
7adaeacd0b refactored xiaomi ble data parsing (#823) 2019-11-02 20:59:55 +01:00
Otto Winter
3aaa92fdff Bump version to v1.14.0 2019-11-01 18:27:24 +01:00
Otto Winter
5efd076c08 Merge branch 'beta' 2019-11-01 18:26:19 +01:00
Otto Winter
1ca241615d Bump version to v1.13.6 2019-06-14 12:55:23 +02:00
Otto Winter
b8aa84002a Re-add CustomMQTTDevice class (#640)
* Re-add CustomMQTTDevice class

Fixes https://github.com/esphome/issues/issues/427

* Fix
2019-06-14 12:55:20 +02:00
Otto Winter
10cc0b1d5b Fix remote_receiver raw binary sensor (#639)
* Fix remote_receiver raw binary sensor

Fixes https://github.com/esphome/issues/issues/439

* Lint
2019-06-14 12:55:19 +02:00
Otto Winter
11d9c203c1 Fix version.h file (#630)
* Fix version.h file

* Lint
2019-06-14 12:55:19 +02:00
Otto Winter
c9ab454c3c Fix globals.set (#635)
* Fix globals.set

* Update __init__.py
2019-06-14 12:55:19 +02:00
Otto Winter
4a55692885 Fix russia timezone detection (#637)
Fixes https://github.com/esphome/issues/issues/378#issuecomment-500219634
2019-06-14 12:55:19 +02:00
Otto Winter
88c129e705 Fix ESP32 RCSwitch Dump Stack Smash Protection (#636)
Fixes https://github.com/esphome/issues/issues/366
2019-06-14 12:55:19 +02:00
Otto Winter
80b48f01fb Fix esp8266_restore_from_flash (#638)
Fixes https://github.com/esphome/issues/issues/424
2019-06-14 12:36:30 +02:00
Otto Winter
642bc91a76 Update esp32_ble_tracker.cpp 2019-06-08 17:06:29 +02:00
Otto Winter
d69926ee56 Bump version to v1.13.5 2019-06-08 16:49:04 +02:00
Otto Winter
4758403d44 Work around ESP32 core WiFi Bug (#627)
* Work around ESP32 WiFi Bug

* Lint
2019-06-08 16:49:00 +02:00
Otto Winter
4b0ec5c28a Work around ESP32 BLE issue (#626) 2019-06-08 16:49:00 +02:00
Otto Winter
4b2a9e5e49 Fix status binary sensor for MQTT (#628)
Fixes https://github.com/esphome/issues/issues/417
2019-06-08 16:48:59 +02:00
Otto Winter
1449c51d49 Update base image to 1.8.3 (#625) 2019-06-08 16:48:59 +02:00
Otto Winter
a451705e0b Fix sun default elevation (#620) 2019-06-08 16:48:58 +02:00
Otto Winter
2e6db39173 Fix integration sensor, add test (#619)
* Fix integration sensor, add test

* Fix

* Fix
2019-06-08 16:48:58 +02:00
Otto Winter
373f75253c Update docker base image to 1.8.0 (#618) 2019-06-08 16:48:58 +02:00
Otto Winter
724842084e Make ForCondition a component (#616)
Fixes https://github.com/esphome/issues/issues/396
2019-06-08 16:48:57 +02:00
Otto Winter
8f3635b167 Fix remote_receiver always shows sony (#617)
Fixes https://github.com/esphome/issues/issues/383#issuecomment-498370572
2019-06-08 16:48:57 +02:00
Otto Winter
11605a36f7 Fix Hass.io addon SSL (#613)
Fixes https://github.com/esphome/issues/issues/404
2019-06-08 16:48:56 +02:00
Otto Winter
533f81d625 Template Cover don't auto-set current_operation (#612)
Fixes https://github.com/esphome/issues/issues/408
2019-06-08 16:48:56 +02:00
Otto Winter
aacb9e44e8 DHT22 ignore invalid values (#614)
Fixes https://github.com/esphome/issues/issues/397
2019-06-08 16:48:55 +02:00
Peter Tatrai
c6e3f1bca6 Fix ForCondition time duration check (#610)
According documentation ForCondition should evaluate to true if a nested condition is true for at least the specified time duration and not the less.
2019-06-08 16:48:55 +02:00
Otto Winter
a933d4aeb6 Move ESPHome version define (#607)
* Move ESPHome version define

* Lint
2019-06-08 16:48:55 +02:00
Otto Winter
caa5b20791 Bump version to v1.13.4 2019-06-03 15:24:10 +02:00
Otto Winter
e2ad9ed746 ESP8266 connect fixes (#605)
* ESP8266 Connection Fixes

* Update client.py

* Update mqtt_client.cpp

* Update mqtt_client.cpp

* Fix ping

* Async dump config

* Update base image to 1.7.0

* Update helpers.py

* Updates

* Update Dockerfile.lint
2019-06-03 15:23:57 +02:00
Otto Winter
32c0e7c2ae Fix ADS1115 calculation (#606)
Fixes https://github.com/esphome/issues/issues/393
2019-06-03 15:23:56 +02:00
Otto Winter
6c564c7b7f Fix validation infinite loop with empty platform block (#598)
* Fix validation infinite loop with empty platform block

* Update util.py
2019-06-03 15:23:56 +02:00
Otto Winter
c81e3a3be4 Fix hx711 (#602)
* Fix HX711

* Use signed value

* Update hx711.cpp
2019-06-03 15:23:56 +02:00
Otto Winter
6b1b9ef7ec Fix color wipe effect (#599) 2019-06-03 15:23:56 +02:00
Otto Winter
c26a8b8718 Allow old remote_transmitter repeat schema (#601)
Fixes https://github.com/esphome/issues/issues/389
2019-06-03 15:23:56 +02:00
Otto Winter
4a89a475bd Add better esphomeyaml migration path (#600)
Fixes https://github.com/esphome/issues/issues/387
2019-06-03 15:23:55 +02:00
Otto Winter
8cf15c7f5c Bump version to v1.13.3 2019-06-01 22:02:10 +02:00
Otto Winter
adc76ca1b8 Fix dashboard for Py3 installs (#596)
Fixes https://github.com/esphome/issues/issues/368
2019-06-01 22:02:05 +02:00
Otto Winter
8f8892440c Fix medium fan speed (#595) 2019-06-01 22:02:04 +02:00
Otto Winter
570843150d Fix flicker light effect turning itself off (#594)
Fixes https://github.com/esphome/issues/issues/382
2019-06-01 22:02:04 +02:00
Otto Winter
f3fc9e4142 Fix remote_receiver binary_sensor (#592)
Fixes https://github.com/esphome/issues/issues/369
2019-06-01 22:02:04 +02:00
Otto Winter
075fcb77a8 Fix timezone detection (#586)
* Fix timezone detection

* Update __init__.py
2019-06-01 22:02:04 +02:00
Otto Winter
e5899ff717 Fix scripts circular dependency (#591)
Fixes https://github.com/esphome/issues/issues/370
2019-06-01 22:02:04 +02:00
Otto Winter
2fb3970027 Fix addressable effects (#590) 2019-06-01 22:02:03 +02:00
Marc-Antoine Courteau
1a4efa1b8c List the correct boards when building for ESP32 (#589)
* List the ESP32 boards for ESP32 builds.

* Sort the list of valid boards.
2019-06-01 22:02:03 +02:00
Otto Winter
72f656ffef Bump version to v1.13.2 2019-05-31 16:37:56 +02:00
Otto Winter
b60239d5e5 Fix i2c setup priority (#585)
Fixes https://github.com/esphome/issues/issues/314
2019-05-31 16:37:49 +02:00
Otto Winter
d02e280c3c Fix light partition (#584)
* Fix light partition

Fixes https://github.com/esphome/issues/issues/365

* Lint
2019-05-31 16:37:48 +02:00
Otto Winter
6535b0966e Fix MQTT on_message trigger (#583)
Fixes https://github.com/esphome/issues/issues/363
Fixes https://github.com/esphome/issues/issues/364
2019-05-31 16:37:48 +02:00
Otto Winter
82dbacbee5 Fix travis build (#582) 2019-05-31 16:37:48 +02:00
Otto Winter
2432901974 Fix Rotary Encoder (#580)
Fixes https://github.com/esphome/issues/issues/360
2019-05-31 16:37:48 +02:00
Otto Winter
ebb5d58c14 Fix MQTT client_id changed (#579)
Fixes https://github.com/esphome/issues/issues/323
2019-05-31 16:37:48 +02:00
Otto Winter
605e365405 Fix remote_receiver binary_sensor schema (#578)
Fixes https://github.com/esphome/issues/issues/353#issuecomment-497491863
2019-05-31 16:37:47 +02:00
Otto Winter
5ab995d8ca Bump version to v1.13.1 2019-05-30 22:31:56 +02:00
Otto Winter
4248741b11 Fix waveshare 7.5in model (#576)
* Fix waveshare 7.5in model

Fixes https://github.com/esphome/issues/issues/357

* Fix platformio travis errors
2019-05-30 22:31:54 +02:00
Otto Winter
4b8ecc7634 Dashboard work around Hass.io bug (#575)
* Dashboard work around Hass.io bug

Ref https://github.com/home-assistant/hassio/issues/1103

* Lint
2019-05-30 22:31:53 +02:00
Otto Winter
25d04c759c Fix Sun Trigger (#572)
* Fix Sun Trigger

* Fix cwww lights
2019-05-30 22:31:53 +02:00
Otto Winter
b4ec84030e Fix validation TypeError (#574) 2019-05-30 22:31:53 +02:00
Otto Winter
29e8761373 Fix merge 2019-05-30 14:20:06 +02:00
Otto Winter
a04299c59e Bump version to v1.13.0 2019-05-30 14:15:41 +02:00
Otto Winter
d7bf3c51d9 Merge branch 'beta' 2019-05-30 14:15:28 +02:00
Otto Winter
ac0b095941 Bump version to v1.12.2 2019-03-31 13:13:12 +02:00
Otto Winter
cda9bad233 Upgrade docker base image to 1.4.3 (#499) 2019-03-31 13:13:09 +02:00
Otto Winter
41db8a1264 Fix text sensor MQTT settings (#495)
Fixes https://github.com/esphome/issues/issues/170
2019-03-31 13:13:09 +02:00
Otto Winter
e7e785fd60 Fix dashboard wizard unicode (#494)
* Fix dashboard wizard unicode

Fixes https://github.com/esphome/issues/issues/169

* Fix password md5
2019-03-31 13:13:08 +02:00
Otto Winter
300d3a1f46 Upgrade ESPAsyncTCP to 1.2.0 (#497) 2019-03-31 13:13:08 +02:00
Otto Winter
356554c08d ESP8266 SDK 2.3.0 compat (#490) 2019-03-31 13:13:08 +02:00
Guillermo Ruffino
ced28ad006 Better symlink support under Windows (#487)
* Better symlink support under Windows

* Conditional loading of ctypes wintypes module

* Shortening comment line for pylint

* Adding plint bypass for Python 3
2019-03-31 13:13:08 +02:00
26 changed files with 236 additions and 154 deletions

1
.gitignore vendored
View File

@@ -119,3 +119,4 @@ config/
tests/build/
tests/.esphome/
/.temp-clang-tidy.cpp
/.idea/

View File

@@ -3,7 +3,8 @@ import esphome.config_validation as cv
from esphome import automation
from esphome.automation import Condition
from esphome.const import CONF_DATA, CONF_DATA_TEMPLATE, CONF_ID, CONF_PASSWORD, CONF_PORT, \
CONF_REBOOT_TIMEOUT, CONF_SERVICE, CONF_VARIABLES, CONF_SERVICES, CONF_TRIGGER_ID, CONF_EVENT
CONF_REBOOT_TIMEOUT, CONF_SERVICE, CONF_VARIABLES, CONF_SERVICES, CONF_TRIGGER_ID, CONF_EVENT, \
CONF_TAG
from esphome.core import coroutine_with_priority
DEPENDENCIES = ['network']
@@ -137,6 +138,23 @@ def homeassistant_event_to_code(config, action_id, template_arg, args):
yield var
HOMEASSISTANT_TAG_SCANNED_ACTION_SCHEMA = cv.maybe_simple_value({
cv.GenerateID(): cv.use_id(APIServer),
cv.Required(CONF_TAG): cv.templatable(cv.string_strict),
}, key=CONF_TAG)
@automation.register_action('homeassistant.tag_scanned', HomeAssistantServiceCallAction,
HOMEASSISTANT_TAG_SCANNED_ACTION_SCHEMA)
def homeassistant_tag_scanned_to_code(config, action_id, template_arg, args):
serv = yield cg.get_variable(config[CONF_ID])
var = cg.new_Pvariable(action_id, template_arg, serv, True)
cg.add(var.set_service('esphome.tag_scanned'))
templ = yield cg.templatable(config[CONF_TAG], args, cg.std_string)
cg.add(var.add_data('tag_id', templ))
yield var
@automation.register_condition('api.connected', APIConnectedCondition, {})
def api_connected_to_code(config, condition_id, template_arg, args):
yield cg.new_Pvariable(condition_id, template_arg)

View File

@@ -33,7 +33,7 @@ class AQICalculator : public AbstractAQICalculator {
}
int get_grid_index_(uint16_t value, int array[AMOUNT_OF_LEVELS][2]) {
for (int i = 0; i < AMOUNT_OF_LEVELS - 1; i++) {
for (int i = 0; i < AMOUNT_OF_LEVELS; i++) {
if (value >= array[i][0] && value <= array[i][1]) {
return i;
}

View File

@@ -102,17 +102,18 @@ class LightTurnOnTrigger : public Trigger<> {
public:
LightTurnOnTrigger(LightState *a_light) {
a_light->add_new_remote_values_callback([this, a_light]() {
auto is_on = a_light->current_values.is_on();
// using the remote value because of transitions we need to trigger as early as possible
auto is_on = a_light->remote_values.is_on();
// only trigger when going from off to on
auto should_trigger = is_on && !last_on_;
auto should_trigger = is_on && !this->last_on_;
// Set new state immediately so that trigger() doesn't devolve
// into infinite loop
last_on_ = is_on;
this->last_on_ = is_on;
if (should_trigger) {
this->trigger();
}
});
last_on_ = a_light->current_values.is_on();
this->last_on_ = a_light->current_values.is_on();
}
protected:
@@ -122,22 +123,14 @@ class LightTurnOnTrigger : public Trigger<> {
class LightTurnOffTrigger : public Trigger<> {
public:
LightTurnOffTrigger(LightState *a_light) {
a_light->add_new_remote_values_callback([this, a_light]() {
a_light->add_new_target_state_reached_callback([this, a_light]() {
auto is_on = a_light->current_values.is_on();
// only trigger when going from on to off
auto should_trigger = !is_on && last_on_;
// Set new state immediately so that trigger() doesn't devolve
// into infinite loop
last_on_ = is_on;
if (should_trigger) {
if (!is_on) {
this->trigger();
}
});
last_on_ = a_light->current_values.is_on();
}
protected:
bool last_on_;
};
template<typename... Ts> class AddressableSet : public Action<Ts...> {

View File

@@ -145,6 +145,7 @@ void LightState::loop() {
if (this->transformer_ != nullptr) {
if (this->transformer_->is_finished()) {
this->remote_values = this->current_values = this->transformer_->get_end_values();
this->target_state_reached_callback_.call();
if (this->transformer_->publish_at_end())
this->publish_state();
this->transformer_ = nullptr;
@@ -336,6 +337,9 @@ void LightCall::perform() {
this->parent_->set_immediately_(v, this->publish_);
}
if (!this->has_transition_()) {
this->parent_->target_state_reached_callback_.call();
}
if (this->publish_) {
this->parent_->publish_state();
}
@@ -395,13 +399,13 @@ LightColorValues LightCall::validate_() {
// sets RGB to 100% if only White specified
if (this->white_.has_value()) {
if (!this->red_.has_value() && !this->green_.has_value() && !this->blue_.has_value()) {
this->red_ = optional<float>(1.0f);
this->green_ = optional<float>(1.0f);
this->blue_ = optional<float>(1.0f);
}
// make white values binary aka 0.0f or 1.0f...this allows brightness to do its job
if (traits.get_supports_color_interlock()) {
if (!this->red_.has_value() && !this->green_.has_value() && !this->blue_.has_value()) {
this->red_ = optional<float>(1.0f);
this->green_ = optional<float>(1.0f);
this->blue_ = optional<float>(1.0f);
}
// make white values binary aka 0.0f or 1.0f...this allows brightness to do its job
if (*this->white_ > 0.0f) {
this->white_ = optional<float>(1.0f);
} else {
@@ -411,11 +415,13 @@ LightColorValues LightCall::validate_() {
}
// White to 0% if (exclusively) setting any RGB value that isn't 255,255,255
else if (this->red_.has_value() || this->green_.has_value() || this->blue_.has_value()) {
if (*this->red_ == 1.0f && *this->green_ == 1.0f && *this->blue_ == 1.0f && traits.get_supports_rgb_white_value() &&
traits.get_supports_color_interlock()) {
this->white_ = optional<float>(1.0f);
} else if (!this->white_.has_value() || !traits.get_supports_rgb_white_value()) {
this->white_ = optional<float>(0.0f);
if (traits.get_supports_color_interlock()) {
if (*this->red_ == 1.0f && *this->green_ == 1.0f && *this->blue_ == 1.0f &&
traits.get_supports_rgb_white_value() && traits.get_supports_color_interlock()) {
this->white_ = optional<float>(1.0f);
} else if (!this->white_.has_value() || !traits.get_supports_rgb_white_value()) {
this->white_ = optional<float>(0.0f);
}
}
}
// if changing Kelvin alone, change to white light
@@ -752,6 +758,10 @@ void LightState::current_values_as_cwww(float *cold_white, float *warm_white, bo
void LightState::add_new_remote_values_callback(std::function<void()> &&send_callback) {
this->remote_values_callback_.add(std::move(send_callback));
}
void LightState::add_new_target_state_reached_callback(std::function<void()> &&send_callback) {
this->target_state_reached_callback_.add(std::move(send_callback));
}
LightEffect *LightState::get_active_effect_() {
if (this->active_effect_index_ == 0)
return nullptr;

View File

@@ -242,6 +242,13 @@ class LightState : public Nameable, public Component {
*/
void add_new_remote_values_callback(std::function<void()> &&send_callback);
/**
* The callback is called once the state of current_values and remote_values are equal
*
* @param send_callback
*/
void add_new_target_state_reached_callback(std::function<void()> &&send_callback);
/// Return whether the light has any effects that meet the trait requirements.
bool supports_effects();
@@ -318,6 +325,12 @@ class LightState : public Nameable, public Component {
* starting with the beginning of the transition.
*/
CallbackManager<void()> remote_values_callback_{};
/** Callback to call when the state of current_values and remote_values are equal
* This should be called once the state of current_values changed and equals the state of remote_values
*/
CallbackManager<void()> target_state_reached_callback_{};
LightOutput *output_; ///< Store the output to allow effects to have more access.
/// Whether the light value should be written in the next cycle.
bool next_write_{true};

View File

@@ -229,7 +229,7 @@ void MAX7219Component::send64pixels(uint8_t chip, const uint8_t pixels[8]) {
b = pixels[col];
} else if (this->orientation_ == 2) {
for (uint8_t i = 0; i < 8; i++) {
b |= ((pixels[i] >> (7 - col)) << (7 - i));
b |= ((pixels[i] >> (7 - col)) & 1) << i;
}
} else {
b = pixels[7 - col];

View File

@@ -11,6 +11,7 @@ static const char *TAG = "remote_receiver.esp32";
void RemoteReceiverComponent::setup() {
ESP_LOGCONFIG(TAG, "Setting up Remote Receiver...");
this->pin_->setup();
rmt_config_t rmt{};
this->config_rmt(rmt);
rmt.gpio_num = gpio_num_t(this->pin_->get_pin());

View File

@@ -50,7 +50,7 @@ bool parse_ruuvi_data_byte(const esp32_ble_tracker::adv_data_t &adv_data, RuuviP
const float acceleration_y = (int16_t(data[8] << 8) + int16_t(data[9])) / 1000.0f;
const float acceleration_z = (int16_t(data[10] << 8) + int16_t(data[11])) / 1000.0f;
const uint8_t power_info = (data[12] << 8) | data[13];
const uint16_t power_info = (uint16_t(data[12] << 8) | data[13]);
const float battery_voltage = ((power_info >> 5) + 1600.0f) / 1000.0f;
const float tx_power = ((power_info & 0x1F) * 2.0f) - 40.0f;

View File

@@ -33,10 +33,6 @@ void SNTPComponent::setup() {
sntp_setservername(2, strdup(this->server_3_.c_str()));
}
#ifdef ARDUINO_ARCH_ESP8266
// let localtime/gmtime handle timezones, not sntp
sntp_set_timezone(0);
#endif
sntp_init();
}
void SNTPComponent::dump_config() {

View File

@@ -66,6 +66,7 @@ def to_code(config):
cg.add(var.set_optimistic(config[CONF_OPTIMISTIC]))
cg.add(var.set_assumed_state(config[CONF_ASSUMED_STATE]))
cg.add(var.set_restore_mode(config[CONF_RESTORE_MODE]))
cg.add(var.set_has_position(config[CONF_HAS_POSITION]))
@automation.register_action('cover.template.publish', cover.CoverPublishAction, cv.Schema({

View File

@@ -7,9 +7,9 @@ from .. import tuya_ns, CONF_TUYA_ID, Tuya
DEPENDENCIES = ['tuya']
CODEOWNERS = ['@jesserockz']
CONF_TARGET_TEMPERATURE_DATAPOINT = "target_temperature_datapoint"
CONF_CURRENT_TEMPERATURE_DATAPOINT = "current_temperature_datapoint"
# CONF_ECO_MODE_DATAPOINT = "eco_mode_datapoint"
CONF_TARGET_TEMPERATURE_DATAPOINT = 'target_temperature_datapoint'
CONF_CURRENT_TEMPERATURE_DATAPOINT = 'current_temperature_datapoint'
CONF_TEMPERATURE_MULTIPLIER = 'temperature_multiplier'
TuyaClimate = tuya_ns.class_('TuyaClimate', climate.Climate, cg.Component)
@@ -19,7 +19,7 @@ CONFIG_SCHEMA = cv.All(climate.CLIMATE_SCHEMA.extend({
cv.Optional(CONF_SWITCH_DATAPOINT): cv.uint8_t,
cv.Optional(CONF_TARGET_TEMPERATURE_DATAPOINT): cv.uint8_t,
cv.Optional(CONF_CURRENT_TEMPERATURE_DATAPOINT): cv.uint8_t,
# cv.Optional(CONF_ECO_MODE_DATAPOINT): cv.uint8_t,
cv.Optional(CONF_TEMPERATURE_MULTIPLIER, default=1): cv.positive_float,
}).extend(cv.COMPONENT_SCHEMA), cv.has_at_least_one_key(
CONF_TARGET_TEMPERATURE_DATAPOINT, CONF_SWITCH_DATAPOINT))
@@ -38,5 +38,4 @@ def to_code(config):
cg.add(var.set_target_temperature_id(config[CONF_TARGET_TEMPERATURE_DATAPOINT]))
if CONF_CURRENT_TEMPERATURE_DATAPOINT in config:
cg.add(var.set_current_temperature_id(config[CONF_CURRENT_TEMPERATURE_DATAPOINT]))
# if CONF_ECO_MODE_DATAPOINT in config:
# cg.add(var.set_eco_mode_id(config[CONF_ECO_MODE_DATAPOINT]))
cg.add(var.set_temperature_multiplier(config[CONF_TEMPERATURE_MULTIPLIER]))

View File

@@ -21,28 +21,20 @@ void TuyaClimate::setup() {
}
if (this->target_temperature_id_.has_value()) {
this->parent_->register_listener(*this->target_temperature_id_, [this](TuyaDatapoint datapoint) {
this->target_temperature = datapoint.value_int;
this->target_temperature = datapoint.value_int * this->temperature_multiplier_;
this->compute_state_();
this->publish_state();
ESP_LOGD(TAG, "MCU reported target temperature is: %d", datapoint.value_int);
ESP_LOGD(TAG, "MCU reported target temperature is: %.1f", this->target_temperature);
});
}
if (this->current_temperature_id_.has_value()) {
this->parent_->register_listener(*this->current_temperature_id_, [this](TuyaDatapoint datapoint) {
this->current_temperature = datapoint.value_int;
this->current_temperature = datapoint.value_int * this->temperature_multiplier_;
this->compute_state_();
this->publish_state();
ESP_LOGD(TAG, "MCU reported current temperature is: %d", datapoint.value_int);
ESP_LOGD(TAG, "MCU reported current temperature is: %.1f", this->current_temperature);
});
}
// if (this->eco_mode_id_.has_value()) {
// this->parent_->register_listener(*this->eco_mode_id_, [this](TuyaDatapoint datapoint) {
// this->eco_mode = datapoint.value_bool;
// this->compute_state_();
// this->publish_state();
// ESP_LOGD(TAG, "MCU reported eco mode of: %s", ONOFF(datapoint.value_bool));
// });
// }
}
void TuyaClimate::control(const climate::ClimateCall &call) {
@@ -56,30 +48,17 @@ void TuyaClimate::control(const climate::ClimateCall &call) {
this->parent_->set_datapoint_value(datapoint);
ESP_LOGD(TAG, "Setting switch: %s", ONOFF(datapoint.value_bool));
}
if (call.get_target_temperature_low().has_value())
this->target_temperature_low = *call.get_target_temperature_low();
if (call.get_target_temperature_high().has_value())
this->target_temperature_high = *call.get_target_temperature_high();
if (call.get_target_temperature().has_value()) {
this->target_temperature = *call.get_target_temperature();
TuyaDatapoint datapoint{};
datapoint.id = *this->target_temperature_id_;
datapoint.type = TuyaDatapointType::INTEGER;
datapoint.value_int = (int) this->target_temperature;
datapoint.value_int = (int) (this->target_temperature / this->temperature_multiplier_);
this->parent_->set_datapoint_value(datapoint);
ESP_LOGD(TAG, "Setting target temperature: %d", datapoint.value_int);
ESP_LOGD(TAG, "Setting target temperature: %.1f", this->target_temperature);
}
// if (call.get_eco_mode().has_value()) {
// this->eco_mode = *call.get_eco_mode();
// TuyaDatapoint datapoint{};
// datapoint.id = *this->eco_mode_id_;
// datapoint.type = TuyaDatapointType::BOOLEAN;
// datapoint.value_bool = this->eco_mode;
// this->parent_->set_datapoint_value(datapoint);
// ESP_LOGD(TAG, "Setting eco mode: %s", ONOFF(datapoint.value_bool));
// }
this->compute_state_();
this->publish_state();
@@ -89,7 +68,6 @@ climate::ClimateTraits TuyaClimate::traits() {
auto traits = climate::ClimateTraits();
traits.set_supports_current_temperature(this->current_temperature_id_.has_value());
traits.set_supports_heat_mode(true);
// traits.set_supports_eco_mode(this->eco_mode_id_.has_value());
traits.set_supports_action(true);
return traits;
}
@@ -102,8 +80,6 @@ void TuyaClimate::dump_config() {
ESP_LOGCONFIG(TAG, " Target Temperature has datapoint ID %u", *this->target_temperature_id_);
if (this->current_temperature_id_.has_value())
ESP_LOGCONFIG(TAG, " Current Temperature has datapoint ID %u", *this->current_temperature_id_);
// if (this->eco_mode_id_.has_value())
// ESP_LOGCONFIG(TAG, " Eco Mode has datapoint ID %u", *this->mode_id_);
}
void TuyaClimate::compute_state_() {

View File

@@ -18,7 +18,9 @@ class TuyaClimate : public climate::Climate, public Component {
void set_current_temperature_id(uint8_t current_temperature_id) {
this->current_temperature_id_ = current_temperature_id;
}
// void set_eco_mode_id(uint8_t eco_mode_id) { this->eco_mode_id_ = eco_mode_id; }
void set_temperature_multiplier(float temperature_multiplier) {
this->temperature_multiplier_ = temperature_multiplier;
}
void set_tuya_parent(Tuya *parent) { this->parent_ = parent; }
@@ -38,7 +40,7 @@ class TuyaClimate : public climate::Climate, public Component {
optional<uint8_t> switch_id_{};
optional<uint8_t> target_temperature_id_{};
optional<uint8_t> current_temperature_id_{};
// optional<uint8_t> eco_mode_id_{};
float temperature_multiplier_{1.0f};
};
} // namespace tuya

View File

@@ -12,6 +12,75 @@ namespace xiaomi_ble {
static const char *TAG = "xiaomi_ble";
bool parse_xiaomi_value(uint8_t value_type, const uint8_t *data, uint8_t value_length, XiaomiParseResult &result) {
// motion detection, 1 byte, 8-bit unsigned integer
if ((value_type == 0x03) && (value_length == 1)) {
result.has_motion = (data[0]) ? true : false;
}
// temperature, 2 bytes, 16-bit signed integer (LE), 0.1 °C
else if ((value_type == 0x04) && (value_length == 2)) {
const int16_t temperature = uint16_t(data[0]) | (uint16_t(data[1]) << 8);
result.temperature = temperature / 10.0f;
}
// humidity, 2 bytes, 16-bit signed integer (LE), 0.1 %
else if ((value_type == 0x06) && (value_length == 2)) {
const int16_t humidity = uint16_t(data[0]) | (uint16_t(data[1]) << 8);
result.humidity = humidity / 10.0f;
}
// illuminance (+ motion), 3 bytes, 24-bit unsigned integer (LE), 1 lx
else if (((value_type == 0x07) || (value_type == 0x0F)) && (value_length == 3)) {
const uint32_t illuminance = uint32_t(data[0]) | (uint32_t(data[1]) << 8) | (uint32_t(data[2]) << 16);
result.illuminance = illuminance;
result.is_light = (illuminance == 100) ? true : false;
if (value_type == 0x0F)
result.has_motion = true;
}
// soil moisture, 1 byte, 8-bit unsigned integer, 1 %
else if ((value_type == 0x08) && (value_length == 1)) {
result.moisture = data[0];
}
// conductivity, 2 bytes, 16-bit unsigned integer (LE), 1 µS/cm
else if ((value_type == 0x09) && (value_length == 2)) {
const uint16_t conductivity = uint16_t(data[0]) | (uint16_t(data[1]) << 8);
result.conductivity = conductivity;
}
// battery, 1 byte, 8-bit unsigned integer, 1 %
else if ((value_type == 0x0A) && (value_length == 1)) {
result.battery_level = data[0];
}
// temperature + humidity, 4 bytes, 16-bit signed integer (LE) each, 0.1 °C, 0.1 %
else if ((value_type == 0x0D) && (value_length == 4)) {
const int16_t temperature = uint16_t(data[0]) | (uint16_t(data[1]) << 8);
const int16_t humidity = uint16_t(data[2]) | (uint16_t(data[3]) << 8);
result.temperature = temperature / 10.0f;
result.humidity = humidity / 10.0f;
}
// formaldehyde, 2 bytes, 16-bit unsigned integer (LE), 0.01 mg / m3
else if ((value_type == 0x10) && (value_length == 2)) {
const uint16_t formaldehyde = uint16_t(data[0]) | (uint16_t(data[1]) << 8);
result.formaldehyde = formaldehyde / 100.0f;
}
// on/off state, 1 byte, 8-bit unsigned integer
else if ((value_type == 0x12) && (value_length == 1)) {
result.is_active = (data[0]) ? true : false;
}
// mosquito tablet, 1 byte, 8-bit unsigned integer, 1 %
else if ((value_type == 0x13) && (value_length == 1)) {
result.tablet = data[0];
}
// idle time since last motion, 4 byte, 32-bit unsigned integer, 1 min
else if ((value_type == 0x17) && (value_length == 4)) {
const uint32_t idle_time =
uint32_t(data[0]) | (uint32_t(data[1]) << 8) | (uint32_t(data[2]) << 16) | (uint32_t(data[2]) << 24);
result.idle_time = idle_time / 60.0f;
result.has_motion = (idle_time) ? false : true;
} else {
return false;
}
return true;
}
bool parse_xiaomi_message(const std::vector<uint8_t> &message, XiaomiParseResult &result) {
result.has_encryption = (message[0] & 0x08) ? true : false; // update encryption status
if (result.has_encryption) {
@@ -25,81 +94,39 @@ bool parse_xiaomi_message(const std::vector<uint8_t> &message, XiaomiParseResult
// Byte 2: length
// Byte 3..3+len-1: data point value
const uint8_t *raw = message.data() + result.raw_offset;
const uint8_t *data = raw + 3;
const uint8_t data_length = raw[2];
const uint8_t *payload = message.data() + result.raw_offset;
uint8_t payload_length = message.size() - result.raw_offset;
uint8_t payload_offset = 0;
bool success = false;
if ((data_length < 1) || (data_length > 4)) {
ESP_LOGVV(TAG, "parse_xiaomi_message(): payload has wrong size (%d)!", data_length);
if (payload_length < 4) {
ESP_LOGVV(TAG, "parse_xiaomi_message(): payload has wrong size (%d)!", payload_length);
return false;
}
// motion detection, 1 byte, 8-bit unsigned integer
if ((raw[0] == 0x03) && (data_length == 1)) {
result.has_motion = (data[0]) ? true : false;
}
// temperature, 2 bytes, 16-bit signed integer (LE), 0.1 °C
else if ((raw[0] == 0x04) && (data_length == 2)) {
const int16_t temperature = uint16_t(data[0]) | (uint16_t(data[1]) << 8);
result.temperature = temperature / 10.0f;
}
// humidity, 2 bytes, 16-bit signed integer (LE), 0.1 %
else if ((raw[0] == 0x06) && (data_length == 2)) {
const int16_t humidity = uint16_t(data[0]) | (uint16_t(data[1]) << 8);
result.humidity = humidity / 10.0f;
}
// illuminance (+ motion), 3 bytes, 24-bit unsigned integer (LE), 1 lx
else if (((raw[0] == 0x07) || (raw[0] == 0x0F)) && (data_length == 3)) {
const uint32_t illuminance = uint32_t(data[0]) | (uint32_t(data[1]) << 8) | (uint32_t(data[2]) << 16);
result.illuminance = illuminance;
result.is_light = (illuminance == 100) ? true : false;
if (raw[0] == 0x0F)
result.has_motion = true;
}
// soil moisture, 1 byte, 8-bit unsigned integer, 1 %
else if ((raw[0] == 0x08) && (data_length == 1)) {
result.moisture = data[0];
}
// conductivity, 2 bytes, 16-bit unsigned integer (LE), 1 µS/cm
else if ((raw[0] == 0x09) && (data_length == 2)) {
const uint16_t conductivity = uint16_t(data[0]) | (uint16_t(data[1]) << 8);
result.conductivity = conductivity;
}
// battery, 1 byte, 8-bit unsigned integer, 1 %
else if ((raw[0] == 0x0A) && (data_length == 1)) {
result.battery_level = data[0];
}
// temperature + humidity, 4 bytes, 16-bit signed integer (LE) each, 0.1 °C, 0.1 %
else if ((raw[0] == 0x0D) && (data_length == 4)) {
const int16_t temperature = uint16_t(data[0]) | (uint16_t(data[1]) << 8);
const int16_t humidity = uint16_t(data[2]) | (uint16_t(data[3]) << 8);
result.temperature = temperature / 10.0f;
result.humidity = humidity / 10.0f;
}
// formaldehyde, 2 bytes, 16-bit unsigned integer (LE), 0.01 mg / m3
else if ((raw[0] == 0x10) && (data_length == 2)) {
const uint16_t formaldehyde = uint16_t(data[0]) | (uint16_t(data[1]) << 8);
result.formaldehyde = formaldehyde / 100.0f;
}
// on/off state, 1 byte, 8-bit unsigned integer
else if ((raw[0] == 0x12) && (data_length == 1)) {
result.is_active = (data[0]) ? true : false;
}
// mosquito tablet, 1 byte, 8-bit unsigned integer, 1 %
else if ((raw[0] == 0x13) && (data_length == 1)) {
result.tablet = data[0];
}
// idle time since last motion, 4 byte, 32-bit unsigned integer, 1 min
else if ((raw[0] == 0x17) && (data_length == 4)) {
const uint32_t idle_time =
uint32_t(data[0]) | (uint32_t(data[1]) << 8) | (uint32_t(data[2]) << 16) | (uint32_t(data[2]) << 24);
result.idle_time = idle_time / 60.0f;
result.has_motion = (idle_time) ? false : true;
} else {
return false;
while (payload_length > 0) {
if (payload[payload_offset + 1] != 0x10) {
ESP_LOGVV(TAG, "parse_xiaomi_message(): fixed byte not found, stop parsing residual data.");
break;
}
const uint8_t value_length = payload[payload_offset + 2];
if ((value_length < 1) || (value_length > 4) || (payload_length < (3 + value_length))) {
ESP_LOGVV(TAG, "parse_xiaomi_message(): value has wrong size (%d)!", value_length);
break;
}
const uint8_t value_type = payload[payload_offset + 0];
const uint8_t *data = &payload[payload_offset + 3];
if (parse_xiaomi_value(value_type, data, value_length, result))
success = true;
payload_length -= 3 + value_length;
payload_offset += 3 + value_length;
}
return true;
return success;
}
optional<XiaomiParseResult> parse_xiaomi_header(const esp32_ble_tracker::ServiceData &service_data) {

View File

@@ -57,6 +57,7 @@ struct XiaomiAESVector {
size_t ivsize;
};
bool parse_xiaomi_value(uint8_t value_type, const uint8_t *data, uint8_t value_length, XiaomiParseResult &result);
bool parse_xiaomi_message(const std::vector<uint8_t> &message, XiaomiParseResult &result);
optional<XiaomiParseResult> parse_xiaomi_header(const esp32_ble_tracker::ServiceData &service_data);
bool decrypt_xiaomi_payload(std::vector<uint8_t> &raw, const uint8_t *bindkey, const uint64_t &address);

View File

@@ -1,8 +1,8 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import sensor, esp32_ble_tracker
from esphome.const import CONF_MAC_ADDRESS, CONF_TEMPERATURE, \
UNIT_CELSIUS, ICON_THERMOMETER, UNIT_PERCENT, ICON_WATER_PERCENT, CONF_ID, \
from esphome.const import CONF_BATTERY_LEVEL, CONF_MAC_ADDRESS, CONF_TEMPERATURE, \
UNIT_CELSIUS, ICON_THERMOMETER, UNIT_PERCENT, ICON_WATER_PERCENT, ICON_BATTERY, CONF_ID, \
CONF_MOISTURE, CONF_ILLUMINANCE, ICON_BRIGHTNESS_5, UNIT_LUX, CONF_CONDUCTIVITY, \
UNIT_MICROSIEMENS_PER_CENTIMETER, ICON_FLOWER
@@ -19,6 +19,7 @@ CONFIG_SCHEMA = cv.Schema({
cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema(UNIT_CELSIUS, ICON_THERMOMETER, 1),
cv.Optional(CONF_MOISTURE): sensor.sensor_schema(UNIT_PERCENT, ICON_WATER_PERCENT, 0),
cv.Optional(CONF_ILLUMINANCE): sensor.sensor_schema(UNIT_LUX, ICON_BRIGHTNESS_5, 0),
cv.Optional(CONF_BATTERY_LEVEL): sensor.sensor_schema(UNIT_PERCENT, ICON_BATTERY, 0),
cv.Optional(CONF_CONDUCTIVITY):
sensor.sensor_schema(UNIT_MICROSIEMENS_PER_CENTIMETER, ICON_FLOWER, 0),
}).extend(esp32_ble_tracker.ESP_BLE_DEVICE_SCHEMA).extend(cv.COMPONENT_SCHEMA)
@@ -43,3 +44,6 @@ def to_code(config):
if CONF_CONDUCTIVITY in config:
sens = yield sensor.new_sensor(config[CONF_CONDUCTIVITY])
cg.add(var.set_conductivity(sens))
if CONF_BATTERY_LEVEL in config:
sens = yield sensor.new_sensor(config[CONF_BATTERY_LEVEL])
cg.add(var.set_battery_level(sens))

View File

@@ -14,6 +14,7 @@ void XiaomiHHCCJCY01::dump_config() {
LOG_SENSOR(" ", "Moisture", this->moisture_);
LOG_SENSOR(" ", "Conductivity", this->conductivity_);
LOG_SENSOR(" ", "Illuminance", this->illuminance_);
LOG_SENSOR(" ", "Battery Level", this->battery_level_);
}
bool XiaomiHHCCJCY01::parse_device(const esp32_ble_tracker::ESPBTDevice &device) {
@@ -50,6 +51,8 @@ bool XiaomiHHCCJCY01::parse_device(const esp32_ble_tracker::ESPBTDevice &device)
this->conductivity_->publish_state(*res->conductivity);
if (res->illuminance.has_value() && this->illuminance_ != nullptr)
this->illuminance_->publish_state(*res->illuminance);
if (res->battery_level.has_value() && this->battery_level_ != nullptr)
this->battery_level_->publish_state(*res->battery_level);
success = true;
}

View File

@@ -22,6 +22,7 @@ class XiaomiHHCCJCY01 : public Component, public esp32_ble_tracker::ESPBTDeviceL
void set_moisture(sensor::Sensor *moisture) { moisture_ = moisture; }
void set_conductivity(sensor::Sensor *conductivity) { conductivity_ = conductivity; }
void set_illuminance(sensor::Sensor *illuminance) { illuminance_ = illuminance; }
void set_battery_level(sensor::Sensor *battery_level) { battery_level_ = battery_level; }
protected:
uint64_t address_;
@@ -29,6 +30,7 @@ class XiaomiHHCCJCY01 : public Component, public esp32_ble_tracker::ESPBTDeviceL
sensor::Sensor *moisture_{nullptr};
sensor::Sensor *conductivity_{nullptr};
sensor::Sensor *illuminance_{nullptr};
sensor::Sensor *battery_level_{nullptr};
};
} // namespace xiaomi_hhccjcy01

View File

@@ -11,10 +11,11 @@ from string import ascii_letters, digits
import voluptuous as vol
from esphome import core
from esphome.const import CONF_AVAILABILITY, CONF_COMMAND_TOPIC, CONF_DISCOVERY, CONF_ID, \
CONF_INTERNAL, CONF_NAME, CONF_PAYLOAD_AVAILABLE, CONF_PAYLOAD_NOT_AVAILABLE, \
CONF_RETAIN, CONF_SETUP_PRIORITY, CONF_STATE_TOPIC, CONF_TOPIC, \
CONF_HOUR, CONF_MINUTE, CONF_SECOND, CONF_VALUE, CONF_UPDATE_INTERVAL, CONF_TYPE_ID, CONF_TYPE
from esphome.const import CONF_AVAILABILITY, CONF_COMMAND_TOPIC, \
CONF_DISCOVERY, CONF_ID, CONF_INTERNAL, CONF_NAME, CONF_PAYLOAD_AVAILABLE, \
CONF_PAYLOAD_NOT_AVAILABLE, CONF_RETAIN, CONF_SETUP_PRIORITY, CONF_STATE_TOPIC, CONF_TOPIC, \
CONF_HOUR, CONF_MINUTE, CONF_SECOND, CONF_VALUE, CONF_UPDATE_INTERVAL, CONF_TYPE_ID, \
CONF_TYPE, CONF_PACKAGES
from esphome.core import CORE, HexInt, IPAddress, Lambda, TimePeriod, TimePeriodMicroseconds, \
TimePeriodMilliseconds, TimePeriodSeconds, TimePeriodMinutes
from esphome.helpers import list_starts_with, add_class_to_obj
@@ -1167,9 +1168,12 @@ class OnlyWith(Optional):
@property
def default(self):
# pylint: disable=unsupported-membership-test
if self._component not in CORE.raw_config:
return vol.UNDEFINED
return self._default
if (self._component in CORE.raw_config or
(CONF_PACKAGES in CORE.raw_config and
self._component in
{list(x.keys())[0] for x in CORE.raw_config[CONF_PACKAGES].values()})):
return self._default
return vol.UNDEFINED
@default.setter
def default(self, value):

View File

@@ -2,7 +2,7 @@
MAJOR_VERSION = 1
MINOR_VERSION = 15
PATCH_VERSION = '0b4'
PATCH_VERSION = '3'
__short_version__ = f'{MAJOR_VERSION}.{MINOR_VERSION}'
__version__ = f'{__short_version__}.{PATCH_VERSION}'

View File

@@ -178,8 +178,8 @@ void delay_microseconds_accurate(uint32_t usec) {
if (usec <= 16383UL) {
delayMicroseconds(usec);
} else {
delay(usec / 16383UL);
delayMicroseconds(usec % 16383UL);
delay(usec / 1000UL);
delayMicroseconds(usec % 1000UL);
}
}

View File

@@ -8,6 +8,7 @@ namespace esphome {
static const char *TAG = "scheduler";
static const uint32_t SCHEDULER_DONT_RUN = 4294967295UL;
static const uint32_t MAX_LOGICALLY_DELETED_ITEMS = 10;
// Uncomment to debug scheduler
// #define ESPHOME_DEBUG_SCHEDULER
@@ -107,6 +108,26 @@ void ICACHE_RAM_ATTR HOT Scheduler::call() {
}
#endif // ESPHOME_DEBUG_SCHEDULER
auto to_remove_was = to_remove_;
auto items_was = items_.size();
// If we have too many items to remove
if (to_remove_ > MAX_LOGICALLY_DELETED_ITEMS) {
std::vector<std::unique_ptr<SchedulerItem>> valid_items;
while (!this->empty_()) {
auto item = std::move(this->items_[0]);
this->pop_raw_();
valid_items.push_back(std::move(item));
}
this->items_ = std::move(valid_items);
// The following should not happen unless I'm missing something
if (to_remove_ != 0) {
ESP_LOGW(TAG, "to_remove_ was %u now: %u items where %zu now %zu. Please report this", to_remove_was, to_remove_,
items_was, items_.size());
to_remove_ = 0;
}
}
while (!this->empty_()) {
// use scoping to indicate visibility of `item` variable
{
@@ -147,6 +168,7 @@ void ICACHE_RAM_ATTR HOT Scheduler::call() {
if (item->remove) {
// We were removed/cancelled in the function call, stop
to_remove_--;
continue;
}
@@ -182,6 +204,7 @@ void HOT Scheduler::cleanup_() {
if (!item->remove)
return;
to_remove_--;
this->pop_raw_();
}
}
@@ -193,7 +216,8 @@ void HOT Scheduler::push_(std::unique_ptr<Scheduler::SchedulerItem> item) { this
bool HOT Scheduler::cancel_item_(Component *component, const std::string &name, Scheduler::SchedulerItem::Type type) {
bool ret = false;
for (auto &it : this->items_)
if (it->component == component && it->name == name && it->type == type) {
if (it->component == component && it->name == name && it->type == type && !it->remove) {
to_remove_++;
it->remove = true;
ret = true;
}

View File

@@ -61,6 +61,7 @@ class Scheduler {
std::vector<std::unique_ptr<SchedulerItem>> to_add_;
uint32_t last_millis_{0};
uint8_t millis_major_{0};
uint32_t to_remove_{0};
};
} // namespace esphome

View File

@@ -101,6 +101,8 @@ sensor:
name: "Xiaomi HHCCJCY01 Illuminance"
conductivity:
name: "Xiaomi HHCCJCY01 Soil Conductivity"
battery_level:
name: "Xiaomi HHCCJCY01 Battery Level"
- platform: xiaomi_lywsdcgq
mac_address: 7A:80:8E:19:36:BA
temperature:
@@ -280,6 +282,9 @@ text_sensor:
service: light.turn_on
data:
entity_id: light.my_light
- homeassistant.tag_scanned:
tag: 1234-abcd
- homeassistant.tag_scanned: 1234-abcd
- platform: template
name: "Template Text Sensor"
lambda: |-

View File

@@ -87,6 +87,7 @@ climate:
id: tuya_climate
switch_datapoint: 1
target_temperature_datapoint: 3
temperature_multiplier: 0.5
switch:
- platform: tuya