mirror of
https://github.com/esphome/esphome.git
synced 2026-06-01 01:19:45 +08:00
Merge branch 'beta'
This commit is contained in:
@@ -1,49 +0,0 @@
|
|||||||
---
|
|
||||||
name: Bug report
|
|
||||||
about: Create a report to help esphomelib improve
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
<!-- Thanks for reporting a bug for this project. READ THIS FIRST:
|
|
||||||
- Please make sure to submit issues in the right GitHub repository, if unsure just post it here:
|
|
||||||
- esphomeyaml [here] - This is mostly for reporting bugs when compiling and when you get a long stack trace while compiling or if a configuration fails to validate.
|
|
||||||
- esphomelib [https://github.com/OttoWinter/esphomelib] - Report bugs there if the ESP is crashing or a feature is not working as expected.
|
|
||||||
- esphomedocs [https://github.com/OttoWinter/esphomedocs] - Report bugs there if the documentation is wrong/outdated.
|
|
||||||
- Provide as many details as possible. Paste logs, configuration sample and code into the backticks (```).
|
|
||||||
|
|
||||||
DO NOT DELETE ANY TEXT from this template! Otherwise the issue may be closed without a comment.
|
|
||||||
-->
|
|
||||||
|
|
||||||
**Operating environment (Hass.io/Docker/pip/etc.):**
|
|
||||||
<!--
|
|
||||||
Please provide details about your environment.
|
|
||||||
-->
|
|
||||||
|
|
||||||
**ESP (ESP32/ESP8266/Board/Sonoff):**
|
|
||||||
<!--
|
|
||||||
Please provide details about which ESP you're using.
|
|
||||||
-->
|
|
||||||
|
|
||||||
**Affected component:**
|
|
||||||
<!--
|
|
||||||
Please add the link to the documentation at https://esphomelib.com/esphomeyaml/index.html of the component in question.
|
|
||||||
-->
|
|
||||||
|
|
||||||
|
|
||||||
**Description of problem:**
|
|
||||||
|
|
||||||
|
|
||||||
**Problem-relevant YAML-configuration entries:**
|
|
||||||
```yaml
|
|
||||||
PASTE YAML FILE HERE
|
|
||||||
```
|
|
||||||
|
|
||||||
**Traceback (if applicable):**
|
|
||||||
<!--
|
|
||||||
Please copy the traceback here if compilation is failing. If possible, also connect to the ESP and copy its logs into the backticks.
|
|
||||||
-->
|
|
||||||
```
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
**Additional information:**
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
---
|
|
||||||
name: Feature request
|
|
||||||
about: Suggest an idea for this project
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
<!-- READ THIS FIRST:
|
|
||||||
- This is for feature requests only, if you want to have a certain new sensor/module supported, please use the "new integration" template.
|
|
||||||
- Please be as descriptive as possible, especially use-cases that can otherwise not be solved boost the problem's priority.
|
|
||||||
|
|
||||||
DO NOT DELETE ANY TEXT from this template! Otherwise the issue may be closed without a comment.
|
|
||||||
-->
|
|
||||||
|
|
||||||
**Is your feature request related to a problem/use-case? Please describe.**
|
|
||||||
<!-- A clear and concise description of what the problem is. -->
|
|
||||||
|
|
||||||
**Describe the solution you'd like:**
|
|
||||||
<!-- A description of what you want to happen. -->
|
|
||||||
|
|
||||||
**Additional context:**
|
|
||||||
<!-- Add any other context about the feature request here. -->
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
---
|
|
||||||
name: New integration
|
|
||||||
about: Suggest a new integration for esphomelib
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
DO NOT POST NEW INTEGRATION REQUESTS HERE!
|
|
||||||
|
|
||||||
Please post all new integration requests in the esphomelib repository:
|
|
||||||
|
|
||||||
https://github.com/OttoWinter/esphomelib/issues
|
|
||||||
|
|
||||||
Thank you!
|
|
||||||
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
**Related issue (if applicable):** fixes <link to issue>
|
**Related issue (if applicable):** fixes <link to issue>
|
||||||
|
|
||||||
**Pull request in [esphomedocs](https://github.com/OttoWinter/esphomedocs) with documentation (if applicable):** OttoWinter/esphomedocs#<esphomedocs PR number goes here>
|
**Pull request in [esphome-docs](https://github.com/esphome/esphome-docs) with documentation (if applicable):** esphome/esphome-docs#<esphome-docs PR number goes here>
|
||||||
**Pull request in [esphomelib](https://github.com/OttoWinter/esphomelib) with C++ framework changes (if applicable):** OttoWinter/esphomelib#<esphomelib PR number goes here>
|
**Pull request in [esphome-core](https://github.com/esphome/esphome-core) with C++ framework changes (if applicable):** esphome/esphome-core#<esphome-core PR number goes here>
|
||||||
|
|
||||||
## Checklist:
|
## Checklist:
|
||||||
- [ ] The code change is tested and works locally.
|
- [ ] The code change is tested and works locally.
|
||||||
|
|||||||
+1
-1
@@ -105,4 +105,4 @@ venv.bak/
|
|||||||
|
|
||||||
config/
|
config/
|
||||||
tests/build/
|
tests/build/
|
||||||
tests/.esphomeyaml/
|
tests/.esphome/
|
||||||
|
|||||||
+276
-243
File diff suppressed because it is too large
Load Diff
+13
-12
@@ -8,23 +8,24 @@ matrix:
|
|||||||
env: TARGET=Lint2.7
|
env: TARGET=Lint2.7
|
||||||
install: pip install -e . && pip install flake8==3.6.0 pylint==1.9.4 pillow
|
install: pip install -e . && pip install flake8==3.6.0 pylint==1.9.4 pillow
|
||||||
script:
|
script:
|
||||||
- flake8 esphomeyaml
|
- flake8 esphome
|
||||||
- pylint esphomeyaml
|
- pylint esphome
|
||||||
- python: "3.5.3"
|
- python: "3.5.3"
|
||||||
env: TARGET=Lint3.5
|
env: TARGET=Lint3.5
|
||||||
install: pip install -U https://github.com/platformio/platformio-core/archive/develop.zip && pip install -e . && pip install flake8==3.6.0 pylint==2.2.2 pillow
|
install: pip install -U https://github.com/platformio/platformio-core/archive/develop.zip && pip install -e . && pip install flake8==3.6.0 pylint==2.2.2 pillow
|
||||||
script:
|
script:
|
||||||
- flake8 esphomeyaml
|
- flake8 esphome
|
||||||
- pylint esphomeyaml
|
- pylint esphome
|
||||||
- python: "2.7"
|
- python: "2.7"
|
||||||
env: TARGET=Test2.7
|
env: TARGET=Test2.7
|
||||||
install: pip install -e . && pip install flake8==3.6.0 pylint==1.9.4 pillow
|
install: pip install -e . && pip install flake8==3.6.0 pylint==1.9.4 pillow
|
||||||
script:
|
script:
|
||||||
- esphomeyaml tests/test1.yaml compile
|
- esphome tests/test1.yaml compile
|
||||||
- esphomeyaml tests/test2.yaml compile
|
- esphome tests/test2.yaml compile
|
||||||
- python: "3.5.3"
|
- esphome tests/test3.yaml compile
|
||||||
env: TARGET=Test3.5
|
#- python: "3.5.3"
|
||||||
install: pip install -U https://github.com/platformio/platformio-core/archive/develop.zip && pip install -e . && pip install flake8==3.6.0 pylint==2.2.2 pillow
|
# env: TARGET=Test3.5
|
||||||
script:
|
# install: pip install -U https://github.com/platformio/platformio-core/archive/develop.zip && pip install -e . && pip install flake8==3.6.0 pylint==2.2.2 pillow
|
||||||
- esphomeyaml tests/test1.yaml compile
|
# script:
|
||||||
- esphomeyaml tests/test2.yaml compile
|
# - esphome tests/test1.yaml compile
|
||||||
|
# - esphome tests/test2.yaml compile
|
||||||
|
|||||||
+5
-5
@@ -1,16 +1,16 @@
|
|||||||
# Contributing to esphomeyaml
|
# Contributing to ESPHome
|
||||||
|
|
||||||
esphomeyaml is a part of esphomelib and is responsible for reading in YAML configuration files,
|
This python project is responsible for reading in YAML configuration files,
|
||||||
converting them to C++ code. This code is then converted to a platformio project and compiled
|
converting them to C++ code. This code is then converted to a platformio project and compiled
|
||||||
with [esphomelib](https://github.com/OttoWinter/esphomelib), the C++ framework behind the project.
|
with [esphome-core](https://github.com/esphome/esphome-core), the C++ framework behind the project.
|
||||||
|
|
||||||
For a detailed guide, please see https://esphomelib.com/esphomeyaml/guides/contributing.html#contributing-to-esphomeyaml
|
For a detailed guide, please see https://esphome.io/guides/contributing.html#contributing-to-esphomeyaml
|
||||||
|
|
||||||
Things to note when contributing:
|
Things to note when contributing:
|
||||||
|
|
||||||
- Please test your changes :)
|
- Please test your changes :)
|
||||||
- If a new feature is added or an existing user-facing feature is changed, you should also
|
- If a new feature is added or an existing user-facing feature is changed, you should also
|
||||||
update the [docs](https://github.com/OttoWinter/esphomedocs). See [contributing to esphomedocs](https://esphomelib.com/esphomeyaml/guides/contributing.html#contributing-to-esphomedocs)
|
update the [docs](https://github.com/esphome/esphome-docs). See [contributing to esphome-docs](https://esphome.io/guides/contributing.html#contributing-to-esphomedocs)
|
||||||
for more information.
|
for more information.
|
||||||
- Please also update the tests in the `tests/` folder. You can do so by just adding a line in one of the YAML files
|
- Please also update the tests in the `tests/` folder. You can do so by just adding a line in one of the YAML files
|
||||||
which checks if your new feature compiles correctly.
|
which checks if your new feature compiles correctly.
|
||||||
|
|||||||
-28
@@ -1,28 +0,0 @@
|
|||||||
ARG BUILD_FROM=python:2.7
|
|
||||||
FROM ${BUILD_FROM}
|
|
||||||
MAINTAINER Otto Winter <contact@otto-winter.com>
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y \
|
|
||||||
python-pil \
|
|
||||||
git \
|
|
||||||
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* && \
|
|
||||||
pip install --no-cache-dir --no-binary :all: platformio && \
|
|
||||||
platformio settings set enable_telemetry No && \
|
|
||||||
platformio settings set check_libraries_interval 1000000 && \
|
|
||||||
platformio settings set check_platformio_interval 1000000 && \
|
|
||||||
platformio settings set check_platforms_interval 1000000
|
|
||||||
|
|
||||||
ENV ESPHOMEYAML_OTA_HOST_PORT=6123
|
|
||||||
EXPOSE 6123
|
|
||||||
VOLUME /config
|
|
||||||
WORKDIR /usr/src/app
|
|
||||||
|
|
||||||
COPY docker/platformio.ini /pio/platformio.ini
|
|
||||||
RUN platformio run -d /pio; rm -rf /pio
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
RUN pip install --no-cache-dir --no-binary :all: -e .
|
|
||||||
|
|
||||||
WORKDIR /config
|
|
||||||
ENTRYPOINT ["esphomeyaml"]
|
|
||||||
CMD ["/config", "dashboard"]
|
|
||||||
+16
-16
@@ -1,17 +1,17 @@
|
|||||||
include README.md
|
include README.md
|
||||||
include esphomeyaml/dashboard/templates/index.html
|
include esphome/dashboard/templates/index.html
|
||||||
include esphomeyaml/dashboard/templates/login.html
|
include esphome/dashboard/templates/login.html
|
||||||
include esphomeyaml/dashboard/static/ace.js
|
include esphome/dashboard/static/ace.js
|
||||||
include esphomeyaml/dashboard/static/esphomeyaml.css
|
include esphome/dashboard/static/esphome.css
|
||||||
include esphomeyaml/dashboard/static/esphomeyaml.js
|
include esphome/dashboard/static/esphome.js
|
||||||
include esphomeyaml/dashboard/static/favicon.ico
|
include esphome/dashboard/static/favicon.ico
|
||||||
include esphomeyaml/dashboard/static/jquery.min.js
|
include esphome/dashboard/static/jquery.min.js
|
||||||
include esphomeyaml/dashboard/static/jquery.validate.min.js
|
include esphome/dashboard/static/jquery.validate.min.js
|
||||||
include esphomeyaml/dashboard/static/jquery-ui.min.js
|
include esphome/dashboard/static/jquery-ui.min.js
|
||||||
include esphomeyaml/dashboard/static/materialize.min.css
|
include esphome/dashboard/static/materialize.min.css
|
||||||
include esphomeyaml/dashboard/static/materialize.min.js
|
include esphome/dashboard/static/materialize.min.js
|
||||||
include esphomeyaml/dashboard/static/materialize-stepper.min.css
|
include esphome/dashboard/static/materialize-stepper.min.css
|
||||||
include esphomeyaml/dashboard/static/materialize-stepper.min.js
|
include esphome/dashboard/static/materialize-stepper.min.js
|
||||||
include esphomeyaml/dashboard/static/mode-yaml.js
|
include esphome/dashboard/static/mode-yaml.js
|
||||||
include esphomeyaml/dashboard/static/theme-dreamweaver.js
|
include esphome/dashboard/static/theme-dreamweaver.js
|
||||||
include esphomeyaml/dashboard/static/ext-searchbox.js
|
include esphome/dashboard/static/ext-searchbox.js
|
||||||
|
|||||||
@@ -1,38 +1,9 @@
|
|||||||
# esphomeyaml for [esphomelib](https://github.com/OttoWinter/esphomelib)
|
# ESPHome [](https://travis-ci.org/esphome/esphome) [](https://discord.gg/KhAMKrd) [](https://GitHub.com/esphome/esphome/releases/)
|
||||||
|
|
||||||
### Getting Started Guide: https://esphomelib.com/esphomeyaml/guides/getting_started_command_line.html
|
[](https://esphome.io/)
|
||||||
|
|
||||||
### Available Components: https://esphomelib.com/esphomeyaml/index.html
|
**Documentation:** https://esphome.io/
|
||||||
|
|
||||||
esphomeyaml is the solution for your ESP8266/ESP32 projects with Home Assistant. It allows you to create **custom firmwares** for your microcontrollers with no programming experience required. All you need to know is the YAML configuration format which is also used by [Home Assistant](https://www.home-assistant.io).
|
For issues, please go to [the issue tracker](https://github.com/esphome/issues/issues).
|
||||||
|
|
||||||
esphomeyaml will:
|
For feature requests, please see [feature requests](https://github.com/esphome/feature-requests/issues).
|
||||||
|
|
||||||
* Read your configuration file and warn you about potential errors (like using the invalid pins.)
|
|
||||||
* Create a custom C++ sketch file for you using esphomeyaml's powerful C++ generation engine.
|
|
||||||
* Compile the sketch file for you using [platformio](http://platformio.org/).
|
|
||||||
* Upload the binary to your ESP via Over the Air updates.
|
|
||||||
* Automatically start remote logs via MQTT.
|
|
||||||
|
|
||||||
And all of that with a single command 🎉:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
esphomeyaml configuration.yaml run
|
|
||||||
```
|
|
||||||
|
|
||||||
## Features
|
|
||||||
|
|
||||||
* **No programming experience required:** just edit YAML configuration
|
|
||||||
files like you're used to with Home Assistant.
|
|
||||||
* **Flexible:** Use [esphomelib](https://github.com/OttoWinter/esphomelib)'s powerful core to create custom sensors/outputs.
|
|
||||||
* **Fast and efficient:** Written in C++ and keeps memory consumption to a minimum.
|
|
||||||
* **Made for [Home Assistant](https://www.home-assistant.io):** Almost all [Home Assistant](https://www.home-assistant.io) features are supported out of the box. Including RGB lights and many more.
|
|
||||||
* **Easy reproducible configuration:** No need to go through a long setup process for every single node. Just copy a configuration file and run a single command.
|
|
||||||
* **Smart Over The Air Updates:** esphomeyaml has OTA updates deeply integrated into the system. It even automatically enters a recovery mode if a boot loop is detected.
|
|
||||||
* **Powerful logging engine:** View colorful logs and debug issues remotely.
|
|
||||||
* **Open Source**
|
|
||||||
* For me: Makes documenting esphomelib's features a lot easier.
|
|
||||||
|
|
||||||
## Special Thanks
|
|
||||||
|
|
||||||
Special Thanks to the Home Assistant project. Lots of the code base of esphomeyaml is based off of Home Assistant, for example the loading and config validation code.
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
ARG BUILD_FROM=esphome/esphome-base-amd64:1.2.1
|
||||||
|
FROM ${BUILD_FROM}
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
RUN \
|
||||||
|
pip2 install --no-cache-dir --no-binary :all: -e .
|
||||||
|
|
||||||
|
WORKDIR /config
|
||||||
|
ENTRYPOINT ["esphome"]
|
||||||
|
CMD ["/config", "dashboard"]
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
FROM multiarch/ubuntu-core:amd64-xenial
|
|
||||||
|
|
||||||
# setup locals
|
|
||||||
RUN apt-get update && apt-get install -y \
|
|
||||||
jq \
|
|
||||||
git \
|
|
||||||
python3-setuptools \
|
|
||||||
&& rm -rf /var/lib/apt/lists/* \
|
|
||||||
ENV LANG C.UTF-8
|
|
||||||
|
|
||||||
# Install docker
|
|
||||||
# https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/
|
|
||||||
RUN apt-get update && apt-get install -y \
|
|
||||||
apt-transport-https \
|
|
||||||
ca-certificates \
|
|
||||||
curl \
|
|
||||||
software-properties-common \
|
|
||||||
&& rm -rf /var/lib/apt/lists/* \
|
|
||||||
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \
|
|
||||||
&& add-apt-repository "deb https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
|
|
||||||
&& apt-get update && apt-get install -y docker-ce \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# setup arm binary support
|
|
||||||
RUN apt-get update && apt-get install -y \
|
|
||||||
qemu-user-static \
|
|
||||||
binfmt-support \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
WORKDIR /data
|
|
||||||
@@ -1,75 +1,20 @@
|
|||||||
ARG BUILD_FROM=hassioaddons/ubuntu-base:2.2.0
|
ARG BUILD_FROM=esphome/esphome-hassio-base-amd64:1.2.1
|
||||||
# hadolint ignore=DL3006
|
|
||||||
FROM ${BUILD_FROM}
|
FROM ${BUILD_FROM}
|
||||||
|
|
||||||
# Set shell
|
|
||||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
|
||||||
|
|
||||||
# Copy root filesystem
|
# Copy root filesystem
|
||||||
COPY esphomeyaml-edge/rootfs /
|
COPY docker/rootfs/ /
|
||||||
COPY setup.py setup.cfg MANIFEST.in /opt/esphomeyaml/
|
COPY setup.py setup.cfg MANIFEST.in /opt/esphome/
|
||||||
COPY esphomeyaml /opt/esphomeyaml/esphomeyaml
|
COPY esphome /opt/esphome/esphome
|
||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
# Temporarily move nginx.conf (otherwise dpkg fails)
|
pip2 install --no-cache-dir --no-binary :all: -e /opt/esphome
|
||||||
mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bkp \
|
|
||||||
# Install add-on dependencies
|
|
||||||
&& apt-get update \
|
|
||||||
&& apt-get install -y --no-install-recommends \
|
|
||||||
# Python for esphomeyaml
|
|
||||||
python \
|
|
||||||
python-pip \
|
|
||||||
python-setuptools \
|
|
||||||
# Python Pillow for display component
|
|
||||||
python-pil \
|
|
||||||
# Git for esphomelib downloads
|
|
||||||
git \
|
|
||||||
# Ping for dashboard online/offline status
|
|
||||||
iputils-ping \
|
|
||||||
# NGINX proxy
|
|
||||||
nginx \
|
|
||||||
\
|
|
||||||
&& mv /etc/nginx/nginx.conf.bkp /etc/nginx/nginx.conf \
|
|
||||||
\
|
|
||||||
&& pip2 install --no-cache-dir --no-binary :all: -e /opt/esphomeyaml \
|
|
||||||
\
|
|
||||||
# Change some platformio settings
|
|
||||||
&& platformio settings set enable_telemetry No \
|
|
||||||
&& platformio settings set check_libraries_interval 1000000 \
|
|
||||||
&& platformio settings set check_platformio_interval 1000000 \
|
|
||||||
&& platformio settings set check_platforms_interval 1000000 \
|
|
||||||
\
|
|
||||||
# Build an empty platformio project to force platformio to install all fw build dependencies
|
|
||||||
# The return-code will be non-zero since there's nothing to build.
|
|
||||||
&& (platformio run -d /opt/pio; echo "Done") \
|
|
||||||
\
|
|
||||||
# Cleanup
|
|
||||||
&& rm -fr \
|
|
||||||
/tmp/* \
|
|
||||||
/var/{cache,log}/* \
|
|
||||||
/var/lib/apt/lists/* \
|
|
||||||
/opt/pio/
|
|
||||||
|
|
||||||
# Build arugments
|
# Build arguments
|
||||||
ARG BUILD_ARCH=amd64
|
ARG BUILD_VERSION=dev
|
||||||
ARG BUILD_DATE
|
|
||||||
ARG BUILD_REF
|
|
||||||
ARG BUILD_VERSION
|
|
||||||
|
|
||||||
# Labels
|
# Labels
|
||||||
LABEL \
|
LABEL \
|
||||||
io.hass.name="esphomeyaml" \
|
io.hass.name="ESPHome" \
|
||||||
io.hass.description="Manage and program ESP8266/ESP32 microcontrollers through YAML configuration files" \
|
io.hass.description="Manage and program ESP8266/ESP32 microcontrollers through YAML configuration files" \
|
||||||
io.hass.arch="${BUILD_ARCH}" \
|
|
||||||
io.hass.type="addon" \
|
io.hass.type="addon" \
|
||||||
io.hass.version=${BUILD_VERSION} \
|
io.hass.version=${BUILD_VERSION}
|
||||||
maintainer="Otto Winter <contact@otto-winter.com>" \
|
|
||||||
org.label-schema.description="Manage and program ESP8266/ESP32 microcontrollers through YAML configuration files" \
|
|
||||||
org.label-schema.build-date=${BUILD_DATE} \
|
|
||||||
org.label-schema.name="esphomeyaml" \
|
|
||||||
org.label-schema.schema-version="1.0" \
|
|
||||||
org.label-schema.url="https://esphomelib.com" \
|
|
||||||
org.label-schema.usage="https://github.com/OttoWinter/esphomeyaml/tree/dev/esphomeyaml/README.md" \
|
|
||||||
org.label-schema.vcs-ref=${BUILD_REF} \
|
|
||||||
org.label-schema.vcs-url="https://github.com/OttoWinter/esphomeyaml" \
|
|
||||||
org.label-schema.vendor="esphomelib"
|
|
||||||
|
|||||||
Executable
+26
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# the Docker repository tag being built.
|
||||||
|
declare CACHE_TAG
|
||||||
|
echo "CACHE_TAG: ${CACHE_TAG}"
|
||||||
|
# the name and tag of the Docker repository being built. (This variable is a combination of DOCKER_REPO:CACHE_TAG.)
|
||||||
|
declare IMAGE_NAME
|
||||||
|
echo "IMAGE_NAME: ${IMAGE_NAME}"
|
||||||
|
# the architecture to build
|
||||||
|
declare BUILD_ARCH
|
||||||
|
echo "BUILD_ARCH: ${BUILD_ARCH}"
|
||||||
|
# whether this is a hassio build
|
||||||
|
declare IS_HASSIO
|
||||||
|
echo "IS_HASSIO: ${IS_HASSIO}"
|
||||||
|
echo "PWD: $PWD"
|
||||||
|
|
||||||
|
if [[ ${IS_HASSIO} = "YES" ]]; then
|
||||||
|
docker build \
|
||||||
|
--build-arg "BUILD_FROM=esphome/esphome-hassio-base-${BUILD_ARCH}:1.2.1" \
|
||||||
|
--build-arg "BUILD_VERSION=${CACHE_TAG}" \
|
||||||
|
-t "${IMAGE_NAME}" -f ../docker/Dockerfile.hassio ..
|
||||||
|
else
|
||||||
|
docker build \
|
||||||
|
--build-arg "BUILD_FROM=esphome/esphome-base-${BUILD_ARCH}:1.2.1" \
|
||||||
|
-t "${IMAGE_NAME}" -f ../docker/Dockerfile ..
|
||||||
|
fi
|
||||||
Executable
+18
@@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# the architecture to build
|
||||||
|
declare BUILD_ARCH
|
||||||
|
|
||||||
|
echo "BUILD_ARCH: ${BUILD_ARCH}"
|
||||||
|
|
||||||
|
if [[ ${BUILD_ARCH} = "amd64" ]]; then
|
||||||
|
echo "No qemu required..."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
if [[ ${BUILD_ARCH} = "i386" ]]; then
|
||||||
|
echo "No qemu required..."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Installing qemu..."
|
||||||
|
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/with-contenv bash
|
#!/usr/bin/with-contenv bash
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Community Hass.io Add-ons: esphomeyaml
|
# Community Hass.io Add-ons: ESPHome
|
||||||
# This files check if all user configuration requirements are met
|
# This files check if all user configuration requirements are met
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
@@ -22,7 +22,7 @@ if hass.config.true 'ssl'; then
|
|||||||
text="You enabled encrypted connections using the \"ssl\": true option.
|
text="You enabled encrypted connections using the \"ssl\": true option.
|
||||||
However, the SSL files \"$(hass.config.get 'certfile')\" and \"$(hass.config.get 'keyfile')\"
|
However, the SSL files \"$(hass.config.get 'certfile')\" and \"$(hass.config.get 'keyfile')\"
|
||||||
were not found. If you're using Hass.io on your local network and don't want
|
were not found. If you're using Hass.io on your local network and don't want
|
||||||
to encrypt connections to the esphomeyaml dashboard, you can manually disable
|
to encrypt connections to the ESPHome dashboard, you can manually disable
|
||||||
SSL by setting \"ssl\" to false."
|
SSL by setting \"ssl\" to false."
|
||||||
hass.die "${text}"
|
hass.die "${text}"
|
||||||
fi
|
fi
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/with-contenv bash
|
#!/usr/bin/with-contenv bash
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Community Hass.io Add-ons: esphomeyaml
|
# Community Hass.io Add-ons: ESPHome
|
||||||
# Configures NGINX for use with esphomeyaml
|
# Configures NGINX for use with ESPHome
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
source /usr/lib/hassio-addons/base.sh
|
source /usr/lib/hassio-addons/base.sh
|
||||||
+6
-6
@@ -1,14 +1,14 @@
|
|||||||
#!/usr/bin/with-contenv bash
|
#!/usr/bin/with-contenv bash
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Community Hass.io Add-ons: esphomeyaml
|
# Community Hass.io Add-ons: ESPHome
|
||||||
# This files installs the user esphomeyaml version if specified
|
# This files installs the user ESPHome version if specified
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
source /usr/lib/hassio-addons/base.sh
|
source /usr/lib/hassio-addons/base.sh
|
||||||
|
|
||||||
declare esphomeyaml_version
|
declare esphome_version
|
||||||
|
|
||||||
if hass.config.has_value 'esphomeyaml_version'; then
|
if hass.config.has_value 'esphome_version'; then
|
||||||
esphomeyaml_version=$(hass.config.get 'esphomeyaml_version')
|
esphome_version=$(hass.config.get 'esphome_version')
|
||||||
pip2 install --no-cache-dir --no-binary :all: "https://github.com/OttoWinter/esphomeyaml/archive/${esphomeyaml_version}.zip"
|
pip2 install --no-cache-dir --no-binary :all: "https://github.com/esphome/esphome/archive/${esphome_version}.zip"
|
||||||
fi
|
fi
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/with-contenv bash
|
||||||
|
# ==============================================================================
|
||||||
|
# Community Hass.io Add-ons: ESPHome
|
||||||
|
# This files migrates the esphome config directory from the old path
|
||||||
|
# ==============================================================================
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
source /usr/lib/hassio-addons/base.sh
|
||||||
|
|
||||||
|
if [[ ! -d /config/esphome && -d /config/esphomeyaml ]]; then
|
||||||
|
echo "Moving config directory from /config/esphomeyaml to /config/esphome"
|
||||||
|
mv /config/esphomeyaml /config/esphome
|
||||||
|
mv /config/esphome/.esphomeyaml /config/esphome/.esphome
|
||||||
|
fi
|
||||||
+3
-3
@@ -13,9 +13,9 @@ http {
|
|||||||
sendfile on;
|
sendfile on;
|
||||||
keepalive_timeout 65;
|
keepalive_timeout 65;
|
||||||
|
|
||||||
upstream esphomeyaml {
|
upstream esphome {
|
||||||
ip_hash;
|
ip_hash;
|
||||||
server unix:/var/run/esphomeyaml.sock;
|
server unix:/var/run/esphome.sock;
|
||||||
}
|
}
|
||||||
map $http_upgrade $connection_upgrade {
|
map $http_upgrade $connection_upgrade {
|
||||||
default upgrade;
|
default upgrade;
|
||||||
@@ -45,7 +45,7 @@ http {
|
|||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_redirect off;
|
proxy_redirect off;
|
||||||
proxy_pass http://esphomeyaml;
|
proxy_pass http://esphome;
|
||||||
|
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
@@ -13,9 +13,9 @@ http {
|
|||||||
sendfile on;
|
sendfile on;
|
||||||
keepalive_timeout 65;
|
keepalive_timeout 65;
|
||||||
|
|
||||||
upstream esphomeyaml {
|
upstream esphome {
|
||||||
ip_hash;
|
ip_hash;
|
||||||
server unix:/var/run/esphomeyaml.sock;
|
server unix:/var/run/esphome.sock;
|
||||||
}
|
}
|
||||||
map $http_upgrade $connection_upgrade {
|
map $http_upgrade $connection_upgrade {
|
||||||
default upgrade;
|
default upgrade;
|
||||||
@@ -29,7 +29,7 @@ http {
|
|||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_redirect off;
|
proxy_redirect off;
|
||||||
proxy_pass http://esphomeyaml;
|
proxy_pass http://esphome;
|
||||||
|
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/execlineb -S0
|
#!/usr/bin/execlineb -S0
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Community Hass.io Add-ons: esphomeyaml
|
# Community Hass.io Add-ons: ESPHome
|
||||||
# Take down the S6 supervision tree when esphomeyaml fails
|
# Take down the S6 supervision tree when ESPHome fails
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
if -n { s6-test $# -ne 0 }
|
if -n { s6-test $# -ne 0 }
|
||||||
if -n { s6-test ${1} -eq 256 }
|
if -n { s6-test ${1} -eq 256 }
|
||||||
+4
-4
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/with-contenv bash
|
#!/usr/bin/with-contenv bash
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Community Hass.io Add-ons: esphomeyaml
|
# Community Hass.io Add-ons: ESPHome
|
||||||
# Runs the esphomeyaml dashboard
|
# Runs the ESPHome dashboard
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
source /usr/lib/hassio-addons/base.sh
|
source /usr/lib/hassio-addons/base.sh
|
||||||
@@ -10,5 +10,5 @@ if hass.config.true 'leave_front_door_open'; then
|
|||||||
export DISABLE_HA_AUTHENTICATION=true
|
export DISABLE_HA_AUTHENTICATION=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
hass.log.info "Starting esphomeyaml dashboard..."
|
hass.log.info "Starting ESPHome dashboard..."
|
||||||
exec esphomeyaml /config/esphomeyaml dashboard --socket /var/run/esphomeyaml.sock --hassio
|
exec esphome /config/esphome dashboard --socket /var/run/esphome.sock --hassio
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/execlineb -S0
|
#!/usr/bin/execlineb -S0
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Community Hass.io Add-ons: esphomeyaml
|
# Community Hass.io Add-ons: ESPHome
|
||||||
# Take down the S6 supervision tree when NGINX fails
|
# Take down the S6 supervision tree when NGINX fails
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
if -n { s6-test $# -ne 0 }
|
if -n { s6-test $# -ne 0 }
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/with-contenv bash
|
#!/usr/bin/with-contenv bash
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Community Hass.io Add-ons: esphomeyaml
|
# Community Hass.io Add-ons: ESPHome
|
||||||
# Runs the NGINX proxy
|
# Runs the NGINX proxy
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
@@ -8,22 +8,22 @@ import os
|
|||||||
import random
|
import random
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from esphomeyaml import const, core_config, mqtt, platformio_api, wizard, writer, yaml_util
|
from esphome import const, core_config, mqtt, platformio_api, wizard, writer, yaml_util
|
||||||
from esphomeyaml.api.client import run_logs
|
from esphome.api.client import run_logs
|
||||||
from esphomeyaml.config import get_component, iter_components, read_config, strip_default_ids
|
from esphome.config import get_component, iter_components, read_config, strip_default_ids
|
||||||
from esphomeyaml.const import CONF_BAUD_RATE, CONF_ESPHOMEYAML, CONF_LOGGER, CONF_USE_CUSTOM_CODE, \
|
from esphome.const import CONF_BAUD_RATE, CONF_BROKER, CONF_ESPHOME, CONF_LOGGER, \
|
||||||
CONF_BROKER
|
CONF_USE_CUSTOM_CODE
|
||||||
from esphomeyaml.core import CORE, EsphomeyamlError
|
from esphome.core import CORE, EsphomeError
|
||||||
from esphomeyaml.cpp_generator import Expression, RawStatement, add, statement
|
from esphome.cpp_generator import Expression, RawStatement, add, statement
|
||||||
from esphomeyaml.helpers import color, indent
|
from esphome.helpers import color, indent
|
||||||
from esphomeyaml.py_compat import safe_input, text_type, IS_PY2
|
from esphome.py_compat import IS_PY2, safe_input, text_type
|
||||||
from esphomeyaml.storage_json import StorageJSON, esphomeyaml_storage_path, \
|
from esphome.storage_json import StorageJSON, esphome_storage_path, \
|
||||||
start_update_check_thread, storage_path
|
start_update_check_thread, storage_path
|
||||||
from esphomeyaml.util import run_external_command, safe_print
|
from esphome.util import run_external_command, run_external_process, safe_print
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
PRE_INITIALIZE = ['esphomeyaml', 'logger', 'wifi', 'ethernet', 'ota', 'mqtt', 'web_server', 'api',
|
PRE_INITIALIZE = ['esphome', 'logger', 'wifi', 'ethernet', 'ota', 'mqtt', 'web_server', 'api',
|
||||||
'i2c']
|
'i2c']
|
||||||
|
|
||||||
|
|
||||||
@@ -127,9 +127,9 @@ def run_miniterm(config, port):
|
|||||||
def write_cpp(config):
|
def write_cpp(config):
|
||||||
_LOGGER.info("Generating C++ source...")
|
_LOGGER.info("Generating C++ source...")
|
||||||
|
|
||||||
CORE.add_job(core_config.to_code, config[CONF_ESPHOMEYAML], domain='esphomeyaml')
|
CORE.add_job(core_config.to_code, config[CONF_ESPHOME], domain='esphome')
|
||||||
for domain in PRE_INITIALIZE:
|
for domain in PRE_INITIALIZE:
|
||||||
if domain == CONF_ESPHOMEYAML or domain not in config:
|
if domain == CONF_ESPHOME or domain not in config:
|
||||||
continue
|
continue
|
||||||
CORE.add_job(get_component(domain).to_code, config[domain], domain=domain)
|
CORE.add_job(get_component(domain).to_code, config[domain], domain=domain)
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ def write_cpp(config):
|
|||||||
add(RawStatement(''))
|
add(RawStatement(''))
|
||||||
all_code = []
|
all_code = []
|
||||||
for exp in CORE.expressions:
|
for exp in CORE.expressions:
|
||||||
if not config[CONF_ESPHOMEYAML][CONF_USE_CUSTOM_CODE]:
|
if not config[CONF_ESPHOME][CONF_USE_CUSTOM_CODE]:
|
||||||
if isinstance(exp, Expression) and not exp.required:
|
if isinstance(exp, Expression) and not exp.required:
|
||||||
continue
|
continue
|
||||||
all_code.append(text_type(statement(exp)))
|
all_code.append(text_type(statement(exp)))
|
||||||
@@ -157,9 +157,9 @@ def write_cpp(config):
|
|||||||
|
|
||||||
def compile_program(args, config):
|
def compile_program(args, config):
|
||||||
_LOGGER.info("Compiling app...")
|
_LOGGER.info("Compiling app...")
|
||||||
update_check = not os.getenv('ESPHOMEYAML_NO_UPDATE_CHECK', '')
|
update_check = not os.getenv('ESPHOME_NO_UPDATE_CHECK', '')
|
||||||
if update_check:
|
if update_check:
|
||||||
thread = start_update_check_thread(esphomeyaml_storage_path(CORE.config_dir))
|
thread = start_update_check_thread(esphome_storage_path(CORE.config_dir))
|
||||||
rc = platformio_api.run_compile(config, args.verbose)
|
rc = platformio_api.run_compile(config, args.verbose)
|
||||||
if update_check:
|
if update_check:
|
||||||
thread.join()
|
thread.join()
|
||||||
@@ -167,14 +167,17 @@ def compile_program(args, config):
|
|||||||
|
|
||||||
|
|
||||||
def upload_using_esptool(config, port):
|
def upload_using_esptool(config, port):
|
||||||
import esptool
|
|
||||||
|
|
||||||
path = os.path.join(CORE.build_path, '.pioenvs', CORE.name, 'firmware.bin')
|
path = os.path.join(CORE.build_path, '.pioenvs', CORE.name, 'firmware.bin')
|
||||||
cmd = ['esptool.py', '--before', 'default_reset', '--after', 'hard_reset',
|
cmd = ['esptool.py', '--before', 'default_reset', '--after', 'hard_reset',
|
||||||
'--chip', 'esp8266', '--port', port, 'write_flash', '0x0', path]
|
'--chip', 'esp8266', '--port', port, 'write_flash', '0x0', path]
|
||||||
|
|
||||||
|
if os.environ.get('ESPHOME_USE_SUBPROCESS') is None:
|
||||||
|
import esptool
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
return run_external_command(esptool._main, *cmd)
|
return run_external_command(esptool._main, *cmd)
|
||||||
|
|
||||||
|
return run_external_process(*cmd)
|
||||||
|
|
||||||
|
|
||||||
def upload_program(config, args, host):
|
def upload_program(config, args, host):
|
||||||
# if upload is to a serial port use platformio, otherwise assume ota
|
# if upload is to a serial port use platformio, otherwise assume ota
|
||||||
@@ -183,13 +186,13 @@ def upload_program(config, args, host):
|
|||||||
return upload_using_esptool(config, host)
|
return upload_using_esptool(config, host)
|
||||||
return platformio_api.run_upload(config, args.verbose, host)
|
return platformio_api.run_upload(config, args.verbose, host)
|
||||||
|
|
||||||
from esphomeyaml.components import ota
|
from esphome.components import ota
|
||||||
from esphomeyaml import espota2
|
from esphome import espota2
|
||||||
|
|
||||||
if args.host_port is not None:
|
if args.host_port is not None:
|
||||||
host_port = args.host_port
|
host_port = args.host_port
|
||||||
else:
|
else:
|
||||||
host_port = int(os.getenv('ESPHOMEYAML_OTA_HOST_PORT', random.randint(10000, 60000)))
|
host_port = int(os.getenv('ESPHOME_OTA_HOST_PORT', random.randint(10000, 60000)))
|
||||||
|
|
||||||
verbose = args.verbose
|
verbose = args.verbose
|
||||||
remote_port = ota.get_port(config)
|
remote_port = ota.get_port(config)
|
||||||
@@ -212,7 +215,7 @@ def upload_program(config, args, host):
|
|||||||
|
|
||||||
def show_logs(config, args, port):
|
def show_logs(config, args, port):
|
||||||
if 'logger' not in config:
|
if 'logger' not in config:
|
||||||
raise EsphomeyamlError("Logger is not configured!")
|
raise EsphomeError("Logger is not configured!")
|
||||||
if get_port_type(port) == 'SERIAL':
|
if get_port_type(port) == 'SERIAL':
|
||||||
run_miniterm(config, port)
|
run_miniterm(config, port)
|
||||||
return 0
|
return 0
|
||||||
@@ -342,7 +345,7 @@ def command_clean(args, config):
|
|||||||
|
|
||||||
|
|
||||||
def command_hass_config(args, config):
|
def command_hass_config(args, config):
|
||||||
from esphomeyaml.components import mqtt as mqtt_component
|
from esphome.components import mqtt as mqtt_component
|
||||||
|
|
||||||
_LOGGER.info("This is what you should put in your Home Assistant YAML configuration.")
|
_LOGGER.info("This is what you should put in your Home Assistant YAML configuration.")
|
||||||
_LOGGER.info("Please note this is only necessary if you're not using MQTT discovery.")
|
_LOGGER.info("Please note this is only necessary if you're not using MQTT discovery.")
|
||||||
@@ -364,7 +367,7 @@ def command_hass_config(args, config):
|
|||||||
|
|
||||||
|
|
||||||
def command_dashboard(args):
|
def command_dashboard(args):
|
||||||
from esphomeyaml.dashboard import dashboard
|
from esphome.dashboard import dashboard
|
||||||
|
|
||||||
return dashboard.start_web_server(args)
|
return dashboard.start_web_server(args)
|
||||||
|
|
||||||
@@ -389,8 +392,8 @@ POST_CONFIG_ACTIONS = {
|
|||||||
|
|
||||||
|
|
||||||
def parse_args(argv):
|
def parse_args(argv):
|
||||||
parser = argparse.ArgumentParser(prog='esphomeyaml')
|
parser = argparse.ArgumentParser(prog='esphome')
|
||||||
parser.add_argument('-v', '--verbose', help="Enable verbose esphomeyaml logs.",
|
parser.add_argument('-v', '--verbose', help="Enable verbose esphome logs.",
|
||||||
action='store_true')
|
action='store_true')
|
||||||
parser.add_argument('--dashboard', help="Internal flag to set if the command is run from the "
|
parser.add_argument('--dashboard', help="Internal flag to set if the command is run from the "
|
||||||
"dashboard.", action='store_true')
|
"dashboard.", action='store_true')
|
||||||
@@ -441,11 +444,11 @@ def parse_args(argv):
|
|||||||
parser_clean.add_argument('--client-id', help='Manually set the client id.')
|
parser_clean.add_argument('--client-id', help='Manually set the client id.')
|
||||||
|
|
||||||
subparsers.add_parser('wizard', help="A helpful setup wizard that will guide "
|
subparsers.add_parser('wizard', help="A helpful setup wizard that will guide "
|
||||||
"you through setting up esphomeyaml.")
|
"you through setting up esphome.")
|
||||||
|
|
||||||
subparsers.add_parser('mqtt-fingerprint', help="Get the SSL fingerprint from a MQTT broker.")
|
subparsers.add_parser('mqtt-fingerprint', help="Get the SSL fingerprint from a MQTT broker.")
|
||||||
|
|
||||||
subparsers.add_parser('version', help="Print the esphomeyaml version and exit.")
|
subparsers.add_parser('version', help="Print the esphome version and exit.")
|
||||||
|
|
||||||
subparsers.add_parser('clean', help="Delete all temporary build files.")
|
subparsers.add_parser('clean', help="Delete all temporary build files.")
|
||||||
|
|
||||||
@@ -458,7 +461,7 @@ def parse_args(argv):
|
|||||||
dashboard.add_argument("--open-ui", help="Open the dashboard UI in a browser.",
|
dashboard.add_argument("--open-ui", help="Open the dashboard UI in a browser.",
|
||||||
action='store_true')
|
action='store_true')
|
||||||
dashboard.add_argument("--hassio",
|
dashboard.add_argument("--hassio",
|
||||||
help="Internal flag used to tell esphomeyaml is started as a Hass.io "
|
help="Internal flag used to tell esphome is started as a Hass.io "
|
||||||
"add-on.",
|
"add-on.",
|
||||||
action="store_true")
|
action="store_true")
|
||||||
dashboard.add_argument("--socket",
|
dashboard.add_argument("--socket",
|
||||||
@@ -471,7 +474,7 @@ def parse_args(argv):
|
|||||||
return parser.parse_args(argv[1:])
|
return parser.parse_args(argv[1:])
|
||||||
|
|
||||||
|
|
||||||
def run_esphomeyaml(argv):
|
def run_esphome(argv):
|
||||||
args = parse_args(argv)
|
args = parse_args(argv)
|
||||||
CORE.dashboard = args.dashboard
|
CORE.dashboard = args.dashboard
|
||||||
|
|
||||||
@@ -479,7 +482,7 @@ def run_esphomeyaml(argv):
|
|||||||
if args.command in PRE_CONFIG_ACTIONS:
|
if args.command in PRE_CONFIG_ACTIONS:
|
||||||
try:
|
try:
|
||||||
return PRE_CONFIG_ACTIONS[args.command](args)
|
return PRE_CONFIG_ACTIONS[args.command](args)
|
||||||
except EsphomeyamlError as e:
|
except EsphomeError as e:
|
||||||
_LOGGER.error(e)
|
_LOGGER.error(e)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@@ -493,7 +496,7 @@ def run_esphomeyaml(argv):
|
|||||||
if args.command in POST_CONFIG_ACTIONS:
|
if args.command in POST_CONFIG_ACTIONS:
|
||||||
try:
|
try:
|
||||||
return POST_CONFIG_ACTIONS[args.command](args, config)
|
return POST_CONFIG_ACTIONS[args.command](args, config)
|
||||||
except EsphomeyamlError as e:
|
except EsphomeError as e:
|
||||||
_LOGGER.error(e)
|
_LOGGER.error(e)
|
||||||
return 1
|
return 1
|
||||||
safe_print(u"Unknown command {}".format(args.command))
|
safe_print(u"Unknown command {}".format(args.command))
|
||||||
@@ -502,8 +505,8 @@ def run_esphomeyaml(argv):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
try:
|
try:
|
||||||
return run_esphomeyaml(sys.argv)
|
return run_esphome(sys.argv)
|
||||||
except EsphomeyamlError as e:
|
except EsphomeError as e:
|
||||||
_LOGGER.error(e)
|
_LOGGER.error(e)
|
||||||
return 1
|
return 1
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
@@ -92,7 +92,7 @@ message DeviceInfoResponse {
|
|||||||
|
|
||||||
// A string describing the date of compilation, this is generated by the compiler
|
// A string describing the date of compilation, this is generated by the compiler
|
||||||
// and therefore may not be in the same format all the time.
|
// and therefore may not be in the same format all the time.
|
||||||
// If the user isn't using esphomeyaml, this will also not be set.
|
// If the user isn't using esphome, this will also not be set.
|
||||||
string compilation_time = 5;
|
string compilation_time = 5;
|
||||||
|
|
||||||
// The model of the board. For example NodeMCU
|
// The model of the board. For example NodeMCU
|
||||||
@@ -9,18 +9,18 @@ import time
|
|||||||
from typing import Optional # noqa
|
from typing import Optional # noqa
|
||||||
from google.protobuf import message # noqa
|
from google.protobuf import message # noqa
|
||||||
|
|
||||||
from esphomeyaml import const
|
from esphome import const
|
||||||
import esphomeyaml.api.api_pb2 as pb
|
import esphome.api.api_pb2 as pb
|
||||||
from esphomeyaml.const import CONF_PASSWORD, CONF_PORT
|
from esphome.const import CONF_PASSWORD, CONF_PORT
|
||||||
from esphomeyaml.core import EsphomeyamlError
|
from esphome.core import EsphomeError
|
||||||
from esphomeyaml.helpers import resolve_ip_address, indent, color
|
from esphome.helpers import resolve_ip_address, indent, color
|
||||||
from esphomeyaml.py_compat import text_type, IS_PY2, byte_to_bytes, char_to_byte, format_bytes
|
from esphome.py_compat import text_type, IS_PY2, byte_to_bytes, char_to_byte, format_bytes
|
||||||
from esphomeyaml.util import safe_print
|
from esphome.util import safe_print
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class APIConnectionError(EsphomeyamlError):
|
class APIConnectionError(EsphomeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@@ -179,11 +179,11 @@ class APIClient(threading.Thread):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
ip = resolve_ip_address(self._address)
|
ip = resolve_ip_address(self._address)
|
||||||
except EsphomeyamlError as err:
|
except EsphomeError as err:
|
||||||
_LOGGER.warning("Error resolving IP address of %s. Is it connected to WiFi?",
|
_LOGGER.warning("Error resolving IP address of %s. Is it connected to WiFi?",
|
||||||
self._address)
|
self._address)
|
||||||
_LOGGER.warning("(If this error persists, please set a static IP address: "
|
_LOGGER.warning("(If this error persists, please set a static IP address: "
|
||||||
"https://esphomelib.com/esphomeyaml/components/wifi.html#manual-ips)")
|
"https://esphome.io/components/wifi.html#manual-ips)")
|
||||||
raise APIConnectionError(err)
|
raise APIConnectionError(err)
|
||||||
|
|
||||||
_LOGGER.info("Connecting to %s:%s (%s)", self._address, self._port, ip)
|
_LOGGER.info("Connecting to %s:%s (%s)", self._address, self._port, ip)
|
||||||
@@ -200,7 +200,7 @@ class APIClient(threading.Thread):
|
|||||||
self._socket_open_event.set()
|
self._socket_open_event.set()
|
||||||
|
|
||||||
hello = pb.HelloRequest()
|
hello = pb.HelloRequest()
|
||||||
hello.client_info = 'esphomeyaml v{}'.format(const.__version__)
|
hello.client_info = 'ESPHome v{}'.format(const.__version__)
|
||||||
try:
|
try:
|
||||||
resp = self._send_message_await_response(hello, pb.HelloResponse)
|
resp = self._send_message_await_response(hello, pb.HelloResponse)
|
||||||
except APIConnectionError as err:
|
except APIConnectionError as err:
|
||||||
@@ -423,12 +423,14 @@ def run_logs(config, address):
|
|||||||
conf = config['api']
|
conf = config['api']
|
||||||
port = conf[CONF_PORT]
|
port = conf[CONF_PORT]
|
||||||
password = conf[CONF_PASSWORD]
|
password = conf[CONF_PASSWORD]
|
||||||
_LOGGER.info("Starting log output from %s using esphomelib API", address)
|
_LOGGER.info("Starting log output from %s using esphome API", address)
|
||||||
|
|
||||||
cli = APIClient(address, port, password)
|
cli = APIClient(address, port, password)
|
||||||
stopping = False
|
stopping = False
|
||||||
retry_timer = []
|
retry_timer = []
|
||||||
|
|
||||||
|
has_connects = []
|
||||||
|
|
||||||
def try_connect(tries=0, is_disconnect=True):
|
def try_connect(tries=0, is_disconnect=True):
|
||||||
if stopping:
|
if stopping:
|
||||||
return
|
return
|
||||||
@@ -451,6 +453,11 @@ def run_logs(config, address):
|
|||||||
return
|
return
|
||||||
|
|
||||||
wait_time = min(2**tries, 300)
|
wait_time = min(2**tries, 300)
|
||||||
|
if not has_connects:
|
||||||
|
_LOGGER.warning(u"Initial connection failed. The ESP might not be connected "
|
||||||
|
u"to WiFi yet (%s). Re-Trying in %s seconds",
|
||||||
|
error, wait_time)
|
||||||
|
else:
|
||||||
_LOGGER.warning(u"Couldn't connect to API (%s). Trying to reconnect in %s seconds",
|
_LOGGER.warning(u"Couldn't connect to API (%s). Trying to reconnect in %s seconds",
|
||||||
error, wait_time)
|
error, wait_time)
|
||||||
timer = threading.Timer(wait_time, functools.partial(try_connect, tries + 1, is_disconnect))
|
timer = threading.Timer(wait_time, functools.partial(try_connect, tries + 1, is_disconnect))
|
||||||
@@ -465,8 +472,6 @@ def run_logs(config, address):
|
|||||||
'TCP buffer - This is only cosmetic)')
|
'TCP buffer - This is only cosmetic)')
|
||||||
safe_print(time_ + text)
|
safe_print(time_ + text)
|
||||||
|
|
||||||
has_connects = []
|
|
||||||
|
|
||||||
def on_login():
|
def on_login():
|
||||||
try:
|
try:
|
||||||
cli.subscribe_logs(on_log, dump_config=not has_connects)
|
cli.subscribe_logs(on_log, dump_config=not has_connects)
|
||||||
@@ -2,16 +2,16 @@ import copy
|
|||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
import esphomeyaml.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphomeyaml.const import CONF_ABOVE, CONF_ACTION_ID, CONF_AND, CONF_AUTOMATION_ID, \
|
from esphome.const import CONF_ABOVE, CONF_ACTION_ID, CONF_AND, CONF_AUTOMATION_ID, \
|
||||||
CONF_BELOW, CONF_CONDITION, CONF_CONDITION_ID, CONF_DELAY, CONF_ELSE, CONF_ID, CONF_IF, \
|
CONF_BELOW, CONF_CONDITION, CONF_CONDITION_ID, CONF_DELAY, CONF_ELSE, CONF_ID, CONF_IF, \
|
||||||
CONF_LAMBDA, CONF_OR, CONF_RANGE, CONF_THEN, CONF_TRIGGER_ID, CONF_WHILE
|
CONF_LAMBDA, CONF_OR, CONF_RANGE, CONF_THEN, CONF_TRIGGER_ID, CONF_WHILE, CONF_WAIT_UNTIL
|
||||||
from esphomeyaml.core import CORE
|
from esphome.core import CORE
|
||||||
from esphomeyaml.cpp_generator import ArrayInitializer, Pvariable, TemplateArguments, add, \
|
from esphome.cpp_generator import Pvariable, TemplateArguments, add, get_variable, \
|
||||||
get_variable, process_lambda, templatable
|
process_lambda, templatable
|
||||||
from esphomeyaml.cpp_types import Action, App, Component, PollingComponent, Trigger, \
|
from esphome.cpp_types import Action, App, Component, PollingComponent, Trigger, bool_, \
|
||||||
esphomelib_ns, float_, uint32, void, bool_
|
esphome_ns, float_, uint32, void
|
||||||
from esphomeyaml.util import ServiceRegistry
|
from esphome.util import ServiceRegistry
|
||||||
|
|
||||||
|
|
||||||
def maybe_simple_id(*validators):
|
def maybe_simple_id(*validators):
|
||||||
@@ -98,18 +98,19 @@ ACTION_REGISTRY = ServiceRegistry()
|
|||||||
CONDITION_REGISTRY = ServiceRegistry()
|
CONDITION_REGISTRY = ServiceRegistry()
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
DelayAction = esphomelib_ns.class_('DelayAction', Action, Component)
|
DelayAction = esphome_ns.class_('DelayAction', Action, Component)
|
||||||
LambdaAction = esphomelib_ns.class_('LambdaAction', Action)
|
LambdaAction = esphome_ns.class_('LambdaAction', Action)
|
||||||
IfAction = esphomelib_ns.class_('IfAction', Action)
|
IfAction = esphome_ns.class_('IfAction', Action)
|
||||||
WhileAction = esphomelib_ns.class_('WhileAction', Action)
|
WhileAction = esphome_ns.class_('WhileAction', Action)
|
||||||
UpdateComponentAction = esphomelib_ns.class_('UpdateComponentAction', Action)
|
WaitUntilAction = esphome_ns.class_('WaitUntilAction', Action, Component)
|
||||||
Automation = esphomelib_ns.class_('Automation')
|
UpdateComponentAction = esphome_ns.class_('UpdateComponentAction', Action)
|
||||||
|
Automation = esphome_ns.class_('Automation')
|
||||||
|
|
||||||
Condition = esphomelib_ns.class_('Condition')
|
Condition = esphome_ns.class_('Condition')
|
||||||
AndCondition = esphomelib_ns.class_('AndCondition', Condition)
|
AndCondition = esphome_ns.class_('AndCondition', Condition)
|
||||||
OrCondition = esphomelib_ns.class_('OrCondition', Condition)
|
OrCondition = esphome_ns.class_('OrCondition', Condition)
|
||||||
RangeCondition = esphomelib_ns.class_('RangeCondition', Condition)
|
RangeCondition = esphome_ns.class_('RangeCondition', Condition)
|
||||||
LambdaCondition = esphomelib_ns.class_('LambdaCondition', Condition)
|
LambdaCondition = esphome_ns.class_('LambdaCondition', Condition)
|
||||||
|
|
||||||
|
|
||||||
def validate_automation(extra_schema=None, extra_validators=None, single=False):
|
def validate_automation(extra_schema=None, extra_validators=None, single=False):
|
||||||
@@ -125,6 +126,9 @@ def validate_automation(extra_schema=None, extra_validators=None, single=False):
|
|||||||
# First try as a sequence of actions
|
# First try as a sequence of actions
|
||||||
return [schema({CONF_THEN: value})]
|
return [schema({CONF_THEN: value})]
|
||||||
except vol.Invalid as err:
|
except vol.Invalid as err:
|
||||||
|
if err.path and err.path[0] == CONF_THEN:
|
||||||
|
err.path.pop(0)
|
||||||
|
|
||||||
# Next try as a sequence of automations
|
# Next try as a sequence of automations
|
||||||
try:
|
try:
|
||||||
return vol.Schema([schema])(value)
|
return vol.Schema([schema])(value)
|
||||||
@@ -265,6 +269,29 @@ def while_action_to_code(config, action_id, arg_type, template_arg):
|
|||||||
yield action
|
yield action
|
||||||
|
|
||||||
|
|
||||||
|
def validate_wait_until(value):
|
||||||
|
schema = vol.Schema({
|
||||||
|
vol.Required(CONF_CONDITION): validate_recursive_condition
|
||||||
|
})
|
||||||
|
if isinstance(value, dict) and CONF_CONDITION in value:
|
||||||
|
return schema(value)
|
||||||
|
return validate_wait_until({CONF_CONDITION: value})
|
||||||
|
|
||||||
|
|
||||||
|
WAIT_UNTIL_ACTION_SCHEMA = validate_wait_until
|
||||||
|
|
||||||
|
|
||||||
|
@ACTION_REGISTRY.register(CONF_WAIT_UNTIL, WAIT_UNTIL_ACTION_SCHEMA)
|
||||||
|
def wait_until_action_to_code(config, action_id, arg_type, template_arg):
|
||||||
|
for conditions in build_conditions(config[CONF_CONDITION], arg_type):
|
||||||
|
yield None
|
||||||
|
rhs = WaitUntilAction.new(template_arg, conditions)
|
||||||
|
type = WaitUntilAction.template(template_arg)
|
||||||
|
action = Pvariable(action_id, rhs, type=type)
|
||||||
|
add(App.register_component(action))
|
||||||
|
yield action
|
||||||
|
|
||||||
|
|
||||||
LAMBDA_ACTION_SCHEMA = cv.lambda_
|
LAMBDA_ACTION_SCHEMA = cv.lambda_
|
||||||
|
|
||||||
|
|
||||||
@@ -318,11 +345,10 @@ def build_action(full_config, arg_type):
|
|||||||
def build_actions(config, arg_type):
|
def build_actions(config, arg_type):
|
||||||
actions = []
|
actions = []
|
||||||
for conf in config:
|
for conf in config:
|
||||||
action = None
|
|
||||||
for action in build_action(conf, arg_type):
|
for action in build_action(conf, arg_type):
|
||||||
yield None
|
yield None
|
||||||
actions.append(action)
|
actions.append(action)
|
||||||
yield ArrayInitializer(*actions, multiline=False)
|
yield actions
|
||||||
|
|
||||||
|
|
||||||
def build_condition(full_config, arg_type):
|
def build_condition(full_config, arg_type):
|
||||||
@@ -342,7 +368,7 @@ def build_conditions(config, arg_type):
|
|||||||
for condition in build_condition(conf, arg_type):
|
for condition in build_condition(conf, arg_type):
|
||||||
yield None
|
yield None
|
||||||
conditions.append(condition)
|
conditions.append(condition)
|
||||||
yield ArrayInitializer(*conditions, multiline=False)
|
yield conditions
|
||||||
|
|
||||||
|
|
||||||
def build_automation_(trigger, arg_type, config):
|
def build_automation_(trigger, arg_type, config):
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from esphomeyaml.components import i2c, sensor
|
from esphome.components import i2c, sensor
|
||||||
import esphomeyaml.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphomeyaml.const import CONF_ADDRESS, CONF_ID
|
from esphome.const import CONF_ADDRESS, CONF_ID
|
||||||
from esphomeyaml.cpp_generator import Pvariable
|
from esphome.cpp_generator import Pvariable
|
||||||
from esphomeyaml.cpp_helpers import setup_component
|
from esphome.cpp_helpers import setup_component
|
||||||
from esphomeyaml.cpp_types import App, Component
|
from esphome.cpp_types import App, Component
|
||||||
|
|
||||||
DEPENDENCIES = ['i2c']
|
DEPENDENCIES = ['i2c']
|
||||||
MULTI_CONF = True
|
MULTI_CONF = True
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from esphomeyaml.components import i2c, sensor
|
from esphome.components import i2c, sensor
|
||||||
import esphomeyaml.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphomeyaml.const import CONF_ADDRESS, CONF_ID, CONF_UPDATE_INTERVAL
|
from esphome.const import CONF_ADDRESS, CONF_ID, CONF_UPDATE_INTERVAL
|
||||||
from esphomeyaml.cpp_generator import Pvariable, add
|
from esphome.cpp_generator import Pvariable, add
|
||||||
from esphomeyaml.cpp_helpers import setup_component
|
from esphome.cpp_helpers import setup_component
|
||||||
from esphomeyaml.cpp_types import App, PollingComponent
|
from esphome.cpp_types import App, PollingComponent
|
||||||
|
|
||||||
DEPENDENCIES = ['i2c']
|
DEPENDENCIES = ['i2c']
|
||||||
MULTI_CONF = True
|
MULTI_CONF = True
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from esphomeyaml.automation import ACTION_REGISTRY
|
from esphome.automation import ACTION_REGISTRY
|
||||||
import esphomeyaml.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphomeyaml.const import CONF_DATA, CONF_DATA_TEMPLATE, CONF_ID, CONF_PASSWORD, CONF_PORT, \
|
from esphome.const import CONF_DATA, CONF_DATA_TEMPLATE, CONF_ID, CONF_PASSWORD, CONF_PORT, \
|
||||||
CONF_SERVICE, CONF_VARIABLES, CONF_REBOOT_TIMEOUT
|
CONF_REBOOT_TIMEOUT, CONF_SERVICE, CONF_VARIABLES
|
||||||
from esphomeyaml.core import CORE
|
from esphome.core import CORE
|
||||||
from esphomeyaml.cpp_generator import ArrayInitializer, Pvariable, add, get_variable, process_lambda
|
from esphome.cpp_generator import Pvariable, add, get_variable, process_lambda
|
||||||
from esphomeyaml.cpp_helpers import setup_component
|
from esphome.cpp_helpers import setup_component
|
||||||
from esphomeyaml.cpp_types import Action, App, Component, StoringController, esphomelib_ns
|
from esphome.cpp_types import Action, App, Component, StoringController, esphome_ns
|
||||||
|
|
||||||
api_ns = esphomelib_ns.namespace('api')
|
api_ns = esphome_ns.namespace('api')
|
||||||
APIServer = api_ns.class_('APIServer', Component, StoringController)
|
APIServer = api_ns.class_('APIServer', Component, StoringController)
|
||||||
HomeAssistantServiceCallAction = api_ns.class_('HomeAssistantServiceCallAction', Action)
|
HomeAssistantServiceCallAction = api_ns.class_('HomeAssistantServiceCallAction', Action)
|
||||||
KeyValuePair = api_ns.class_('KeyValuePair')
|
KeyValuePair = api_ns.class_('KeyValuePair')
|
||||||
@@ -74,15 +74,15 @@ def homeassistant_service_to_code(config, action_id, arg_type, template_arg):
|
|||||||
add(act.set_service(config[CONF_SERVICE]))
|
add(act.set_service(config[CONF_SERVICE]))
|
||||||
if CONF_DATA in config:
|
if CONF_DATA in config:
|
||||||
datas = [KeyValuePair(k, v) for k, v in config[CONF_DATA].items()]
|
datas = [KeyValuePair(k, v) for k, v in config[CONF_DATA].items()]
|
||||||
add(act.set_data(ArrayInitializer(*datas)))
|
add(act.set_data(datas))
|
||||||
if CONF_DATA_TEMPLATE in config:
|
if CONF_DATA_TEMPLATE in config:
|
||||||
datas = [KeyValuePair(k, v) for k, v in config[CONF_DATA_TEMPLATE].items()]
|
datas = [KeyValuePair(k, v) for k, v in config[CONF_DATA_TEMPLATE].items()]
|
||||||
add(act.set_data_template(ArrayInitializer(*datas)))
|
add(act.set_data_template(datas))
|
||||||
if CONF_VARIABLES in config:
|
if CONF_VARIABLES in config:
|
||||||
datas = []
|
datas = []
|
||||||
for key, value in config[CONF_VARIABLES].items():
|
for key, value in config[CONF_VARIABLES].items():
|
||||||
for value_ in process_lambda(value, []):
|
for value_ in process_lambda(value, []):
|
||||||
yield None
|
yield None
|
||||||
datas.append(TemplatableKeyValuePair(key, value_))
|
datas.append(TemplatableKeyValuePair(key, value_))
|
||||||
add(act.set_variables(ArrayInitializer(*datas)))
|
add(act.set_variables(datas))
|
||||||
yield act
|
yield act
|
||||||
+25
-36
@@ -1,21 +1,19 @@
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from esphomeyaml import automation, core
|
from esphome import automation, core
|
||||||
from esphomeyaml.automation import maybe_simple_id, CONDITION_REGISTRY, Condition
|
from esphome.automation import CONDITION_REGISTRY, Condition, maybe_simple_id
|
||||||
from esphomeyaml.components import mqtt
|
from esphome.components import mqtt
|
||||||
from esphomeyaml.components.mqtt import setup_mqtt_component
|
from esphome.components.mqtt import setup_mqtt_component
|
||||||
import esphomeyaml.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphomeyaml.const import CONF_DELAYED_OFF, CONF_DELAYED_ON, CONF_DEVICE_CLASS, CONF_FILTERS, \
|
from esphome.const import CONF_DELAYED_OFF, CONF_DELAYED_ON, CONF_DEVICE_CLASS, CONF_FILTERS, \
|
||||||
CONF_HEARTBEAT, CONF_ID, CONF_INTERNAL, CONF_INVALID_COOLDOWN, CONF_INVERT, CONF_INVERTED, \
|
CONF_HEARTBEAT, CONF_ID, CONF_INTERNAL, CONF_INVALID_COOLDOWN, CONF_INVERT, CONF_INVERTED, \
|
||||||
CONF_LAMBDA, CONF_MAX_LENGTH, CONF_MIN_LENGTH, CONF_MQTT_ID, CONF_ON_CLICK, \
|
CONF_LAMBDA, CONF_MAX_LENGTH, CONF_MIN_LENGTH, CONF_MQTT_ID, CONF_ON_CLICK, \
|
||||||
CONF_ON_DOUBLE_CLICK, CONF_ON_MULTI_CLICK, CONF_ON_PRESS, CONF_ON_RELEASE, CONF_STATE, \
|
CONF_ON_DOUBLE_CLICK, CONF_ON_MULTI_CLICK, CONF_ON_PRESS, CONF_ON_RELEASE, CONF_ON_STATE, \
|
||||||
CONF_TIMING, CONF_TRIGGER_ID, CONF_ON_STATE
|
CONF_STATE, CONF_TIMING, CONF_TRIGGER_ID
|
||||||
from esphomeyaml.core import CORE
|
from esphome.core import CORE
|
||||||
from esphomeyaml.cpp_generator import process_lambda, ArrayInitializer, add, Pvariable, \
|
from esphome.cpp_generator import Pvariable, StructInitializer, add, get_variable, process_lambda
|
||||||
StructInitializer, get_variable
|
from esphome.cpp_types import App, Component, Nameable, NoArg, Trigger, bool_, esphome_ns, optional
|
||||||
from esphomeyaml.cpp_types import esphomelib_ns, Nameable, Trigger, NoArg, Component, App, bool_, \
|
from esphome.py_compat import string_types
|
||||||
optional
|
|
||||||
from esphomeyaml.py_compat import string_types
|
|
||||||
|
|
||||||
DEVICE_CLASSES = [
|
DEVICE_CLASSES = [
|
||||||
'', 'battery', 'cold', 'connectivity', 'door', 'garage_door', 'gas',
|
'', 'battery', 'cold', 'connectivity', 'door', 'garage_door', 'gas',
|
||||||
@@ -28,7 +26,7 @@ PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
binary_sensor_ns = esphomelib_ns.namespace('binary_sensor')
|
binary_sensor_ns = esphome_ns.namespace('binary_sensor')
|
||||||
BinarySensor = binary_sensor_ns.class_('BinarySensor', Nameable)
|
BinarySensor = binary_sensor_ns.class_('BinarySensor', Nameable)
|
||||||
BinarySensorPtr = BinarySensor.operator('ptr')
|
BinarySensorPtr = BinarySensor.operator('ptr')
|
||||||
MQTTBinarySensorComponent = binary_sensor_ns.class_('MQTTBinarySensorComponent', mqtt.MQTTComponent)
|
MQTTBinarySensorComponent = binary_sensor_ns.class_('MQTTBinarySensorComponent', mqtt.MQTTComponent)
|
||||||
@@ -53,15 +51,15 @@ HeartbeatFilter = binary_sensor_ns.class_('HeartbeatFilter', Filter, Component)
|
|||||||
InvertFilter = binary_sensor_ns.class_('InvertFilter', Filter)
|
InvertFilter = binary_sensor_ns.class_('InvertFilter', Filter)
|
||||||
LambdaFilter = binary_sensor_ns.class_('LambdaFilter', Filter)
|
LambdaFilter = binary_sensor_ns.class_('LambdaFilter', Filter)
|
||||||
|
|
||||||
|
|
||||||
FILTER_KEYS = [CONF_INVERT, CONF_DELAYED_ON, CONF_DELAYED_OFF, CONF_LAMBDA, CONF_HEARTBEAT]
|
FILTER_KEYS = [CONF_INVERT, CONF_DELAYED_ON, CONF_DELAYED_OFF, CONF_LAMBDA, CONF_HEARTBEAT]
|
||||||
|
|
||||||
FILTERS_SCHEMA = cv.ensure_list({
|
FILTERS_SCHEMA = cv.ensure_list({
|
||||||
vol.Optional(CONF_INVERT): None,
|
vol.Optional(CONF_INVERT): None,
|
||||||
vol.Optional(CONF_DELAYED_ON): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_DELAYED_ON): cv.positive_time_period_milliseconds,
|
||||||
vol.Optional(CONF_DELAYED_OFF): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_DELAYED_OFF): cv.positive_time_period_milliseconds,
|
||||||
vol.Optional(CONF_HEARTBEAT): cv.positive_time_period_milliseconds,
|
|
||||||
vol.Optional(CONF_LAMBDA): cv.lambda_,
|
vol.Optional(CONF_LAMBDA): cv.lambda_,
|
||||||
|
|
||||||
|
vol.Optional(CONF_HEARTBEAT): cv.invalid("The heartbeat filter has been removed in 1.11.0"),
|
||||||
}, cv.has_exactly_one_key(*FILTER_KEYS))
|
}, cv.has_exactly_one_key(*FILTER_KEYS))
|
||||||
|
|
||||||
MULTI_CLICK_TIMING_SCHEMA = vol.Schema({
|
MULTI_CLICK_TIMING_SCHEMA = vol.Schema({
|
||||||
@@ -191,7 +189,7 @@ BINARY_SENSOR_SCHEMA = cv.MQTT_COMPONENT_SCHEMA.extend({
|
|||||||
vol.Optional(CONF_INVERTED): cv.invalid(
|
vol.Optional(CONF_INVERTED): cv.invalid(
|
||||||
"The inverted binary_sensor property has been replaced by the "
|
"The inverted binary_sensor property has been replaced by the "
|
||||||
"new 'invert' binary sensor filter. Please see "
|
"new 'invert' binary sensor filter. Please see "
|
||||||
"https://esphomelib.com/esphomeyaml/components/binary_sensor/index.html."
|
"https://esphome.io/components/binary_sensor/index.html."
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -205,8 +203,6 @@ def setup_filter(config):
|
|||||||
yield App.register_component(DelayedOffFilter.new(config[CONF_DELAYED_OFF]))
|
yield App.register_component(DelayedOffFilter.new(config[CONF_DELAYED_OFF]))
|
||||||
elif CONF_DELAYED_ON in config:
|
elif CONF_DELAYED_ON in config:
|
||||||
yield App.register_component(DelayedOnFilter.new(config[CONF_DELAYED_ON]))
|
yield App.register_component(DelayedOnFilter.new(config[CONF_DELAYED_ON]))
|
||||||
elif CONF_HEARTBEAT in config:
|
|
||||||
yield App.register_component(HeartbeatFilter.new(config[CONF_HEARTBEAT]))
|
|
||||||
elif CONF_LAMBDA in config:
|
elif CONF_LAMBDA in config:
|
||||||
for lambda_ in process_lambda(config[CONF_LAMBDA], [(bool_, 'x')],
|
for lambda_ in process_lambda(config[CONF_LAMBDA], [(bool_, 'x')],
|
||||||
return_type=optional.template(bool_)):
|
return_type=optional.template(bool_)):
|
||||||
@@ -217,14 +213,13 @@ def setup_filter(config):
|
|||||||
def setup_filters(config):
|
def setup_filters(config):
|
||||||
filters = []
|
filters = []
|
||||||
for conf in config:
|
for conf in config:
|
||||||
filter = None
|
|
||||||
for filter in setup_filter(conf):
|
for filter in setup_filter(conf):
|
||||||
yield None
|
yield None
|
||||||
filters.append(filter)
|
filters.append(filter)
|
||||||
yield ArrayInitializer(*filters)
|
yield filters
|
||||||
|
|
||||||
|
|
||||||
def setup_binary_sensor_core_(binary_sensor_var, mqtt_var, config):
|
def setup_binary_sensor_core_(binary_sensor_var, config):
|
||||||
if CONF_INTERNAL in config:
|
if CONF_INTERNAL in config:
|
||||||
add(binary_sensor_var.set_internal(CONF_INTERNAL))
|
add(binary_sensor_var.set_internal(CONF_INTERNAL))
|
||||||
if CONF_DEVICE_CLASS in config:
|
if CONF_DEVICE_CLASS in config:
|
||||||
@@ -232,7 +227,6 @@ def setup_binary_sensor_core_(binary_sensor_var, mqtt_var, config):
|
|||||||
if CONF_INVERTED in config:
|
if CONF_INVERTED in config:
|
||||||
add(binary_sensor_var.set_inverted(config[CONF_INVERTED]))
|
add(binary_sensor_var.set_inverted(config[CONF_INVERTED]))
|
||||||
if CONF_FILTERS in config:
|
if CONF_FILTERS in config:
|
||||||
filters = None
|
|
||||||
for filters in setup_filters(config[CONF_FILTERS]):
|
for filters in setup_filters(config[CONF_FILTERS]):
|
||||||
yield
|
yield
|
||||||
add(binary_sensor_var.add_filters(filters))
|
add(binary_sensor_var.add_filters(filters))
|
||||||
@@ -267,7 +261,6 @@ def setup_binary_sensor_core_(binary_sensor_var, mqtt_var, config):
|
|||||||
('min_length', tim[CONF_MIN_LENGTH]),
|
('min_length', tim[CONF_MIN_LENGTH]),
|
||||||
('max_length', tim.get(CONF_MAX_LENGTH, 4294967294)),
|
('max_length', tim.get(CONF_MAX_LENGTH, 4294967294)),
|
||||||
))
|
))
|
||||||
timings = ArrayInitializer(*timings, multiline=False)
|
|
||||||
rhs = App.register_component(binary_sensor_var.make_multi_click_trigger(timings))
|
rhs = App.register_component(binary_sensor_var.make_multi_click_trigger(timings))
|
||||||
trigger = Pvariable(conf[CONF_TRIGGER_ID], rhs)
|
trigger = Pvariable(conf[CONF_TRIGGER_ID], rhs)
|
||||||
if CONF_INVALID_COOLDOWN in conf:
|
if CONF_INVALID_COOLDOWN in conf:
|
||||||
@@ -279,22 +272,19 @@ def setup_binary_sensor_core_(binary_sensor_var, mqtt_var, config):
|
|||||||
trigger = Pvariable(conf[CONF_TRIGGER_ID], rhs)
|
trigger = Pvariable(conf[CONF_TRIGGER_ID], rhs)
|
||||||
automation.build_automation(trigger, bool_, conf)
|
automation.build_automation(trigger, bool_, conf)
|
||||||
|
|
||||||
setup_mqtt_component(mqtt_var, config)
|
setup_mqtt_component(binary_sensor_var.Pget_mqtt(), config)
|
||||||
|
|
||||||
|
|
||||||
def setup_binary_sensor(binary_sensor_obj, mqtt_obj, config):
|
def setup_binary_sensor(binary_sensor_obj, config):
|
||||||
binary_sensor_var = Pvariable(config[CONF_ID], binary_sensor_obj,
|
if not CORE.has_id(config[CONF_ID]):
|
||||||
has_side_effects=False)
|
binary_sensor_obj = Pvariable(config[CONF_ID], binary_sensor_obj, has_side_effects=True)
|
||||||
mqtt_var = Pvariable(config[CONF_MQTT_ID], mqtt_obj,
|
CORE.add_job(setup_binary_sensor_core_, binary_sensor_obj, config)
|
||||||
has_side_effects=False)
|
|
||||||
CORE.add_job(setup_binary_sensor_core_, binary_sensor_var, mqtt_var, config)
|
|
||||||
|
|
||||||
|
|
||||||
def register_binary_sensor(var, config):
|
def register_binary_sensor(var, config):
|
||||||
binary_sensor_var = Pvariable(config[CONF_ID], var, has_side_effects=True)
|
binary_sensor_var = Pvariable(config[CONF_ID], var, has_side_effects=True)
|
||||||
rhs = App.register_binary_sensor(binary_sensor_var)
|
add(App.register_binary_sensor(binary_sensor_var))
|
||||||
mqtt_var = Pvariable(config[CONF_MQTT_ID], rhs, has_side_effects=True)
|
CORE.add_job(setup_binary_sensor_core_, binary_sensor_var, config)
|
||||||
CORE.add_job(setup_binary_sensor_core_, binary_sensor_var, mqtt_var, config)
|
|
||||||
|
|
||||||
|
|
||||||
def core_to_hass_config(data, config):
|
def core_to_hass_config(data, config):
|
||||||
@@ -309,7 +299,6 @@ def core_to_hass_config(data, config):
|
|||||||
|
|
||||||
BUILD_FLAGS = '-DUSE_BINARY_SENSOR'
|
BUILD_FLAGS = '-DUSE_BINARY_SENSOR'
|
||||||
|
|
||||||
|
|
||||||
CONF_BINARY_SENSOR_IS_ON = 'binary_sensor.is_on'
|
CONF_BINARY_SENSOR_IS_ON = 'binary_sensor.is_on'
|
||||||
BINARY_SENSOR_IS_ON_CONDITION_SCHEMA = maybe_simple_id({
|
BINARY_SENSOR_IS_ON_CONDITION_SCHEMA = maybe_simple_id({
|
||||||
vol.Required(CONF_ID): cv.use_variable_id(BinarySensor),
|
vol.Required(CONF_ID): cv.use_variable_id(BinarySensor),
|
||||||
+5
-5
@@ -1,10 +1,10 @@
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from esphomeyaml.components import binary_sensor, sensor
|
from esphome.components import binary_sensor, sensor
|
||||||
from esphomeyaml.components.apds9960 import APDS9960, CONF_APDS9960_ID
|
from esphome.components.apds9960 import APDS9960, CONF_APDS9960_ID
|
||||||
import esphomeyaml.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphomeyaml.const import CONF_DIRECTION, CONF_NAME
|
from esphome.const import CONF_DIRECTION, CONF_NAME
|
||||||
from esphomeyaml.cpp_generator import get_variable
|
from esphome.cpp_generator import get_variable
|
||||||
|
|
||||||
DEPENDENCIES = ['apds9960']
|
DEPENDENCIES = ['apds9960']
|
||||||
APDS9960GestureDirectionBinarySensor = sensor.sensor_ns.class_(
|
APDS9960GestureDirectionBinarySensor = sensor.sensor_ns.class_(
|
||||||
+9
-7
@@ -1,10 +1,10 @@
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from esphomeyaml.components import binary_sensor
|
from esphome.components import binary_sensor
|
||||||
import esphomeyaml.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphomeyaml.const import CONF_BINARY_SENSORS, CONF_ID, CONF_LAMBDA
|
from esphome.const import CONF_BINARY_SENSORS, CONF_ID, CONF_LAMBDA, CONF_NAME
|
||||||
from esphomeyaml.cpp_generator import process_lambda, variable
|
from esphome.cpp_generator import add, process_lambda, variable
|
||||||
from esphomeyaml.cpp_types import std_vector
|
from esphome.cpp_types import std_vector
|
||||||
|
|
||||||
CustomBinarySensorConstructor = binary_sensor.binary_sensor_ns.class_(
|
CustomBinarySensorConstructor = binary_sensor.binary_sensor_ns.class_(
|
||||||
'CustomBinarySensorConstructor')
|
'CustomBinarySensorConstructor')
|
||||||
@@ -26,8 +26,10 @@ def to_code(config):
|
|||||||
|
|
||||||
rhs = CustomBinarySensorConstructor(template_)
|
rhs = CustomBinarySensorConstructor(template_)
|
||||||
custom = variable(config[CONF_ID], rhs)
|
custom = variable(config[CONF_ID], rhs)
|
||||||
for i, sens in enumerate(config[CONF_BINARY_SENSORS]):
|
for i, conf in enumerate(config[CONF_BINARY_SENSORS]):
|
||||||
binary_sensor.register_binary_sensor(custom.get_binary_sensor(i), sens)
|
rhs = custom.Pget_binary_sensor(i)
|
||||||
|
add(rhs.set_name(conf[CONF_NAME]))
|
||||||
|
binary_sensor.register_binary_sensor(rhs, conf)
|
||||||
|
|
||||||
|
|
||||||
BUILD_FLAGS = '-DUSE_CUSTOM_BINARY_SENSOR'
|
BUILD_FLAGS = '-DUSE_CUSTOM_BINARY_SENSOR'
|
||||||
+7
-8
@@ -1,15 +1,15 @@
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from esphomeyaml.components import binary_sensor
|
from esphome.components import binary_sensor
|
||||||
from esphomeyaml.components.esp32_ble_tracker import CONF_ESP32_BLE_ID, ESP32BLETracker, \
|
from esphome.components.esp32_ble_tracker import CONF_ESP32_BLE_ID, ESP32BLETracker, \
|
||||||
make_address_array
|
make_address_array
|
||||||
import esphomeyaml.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphomeyaml.const import CONF_MAC_ADDRESS, CONF_NAME
|
from esphome.const import CONF_MAC_ADDRESS, CONF_NAME
|
||||||
from esphomeyaml.cpp_generator import get_variable
|
from esphome.cpp_generator import get_variable
|
||||||
from esphomeyaml.cpp_types import esphomelib_ns
|
from esphome.cpp_types import esphome_ns
|
||||||
|
|
||||||
DEPENDENCIES = ['esp32_ble_tracker']
|
DEPENDENCIES = ['esp32_ble_tracker']
|
||||||
ESP32BLEPresenceDevice = esphomelib_ns.class_('ESP32BLEPresenceDevice', binary_sensor.BinarySensor)
|
ESP32BLEPresenceDevice = esphome_ns.class_('ESP32BLEPresenceDevice', binary_sensor.BinarySensor)
|
||||||
|
|
||||||
PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(): cv.declare_variable_id(ESP32BLEPresenceDevice),
|
cv.GenerateID(): cv.declare_variable_id(ESP32BLEPresenceDevice),
|
||||||
@@ -19,7 +19,6 @@ PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend
|
|||||||
|
|
||||||
|
|
||||||
def to_code(config):
|
def to_code(config):
|
||||||
hub = None
|
|
||||||
for hub in get_variable(config[CONF_ESP32_BLE_ID]):
|
for hub in get_variable(config[CONF_ESP32_BLE_ID]):
|
||||||
yield
|
yield
|
||||||
rhs = hub.make_presence_sensor(config[CONF_NAME], make_address_array(config[CONF_MAC_ADDRESS]))
|
rhs = hub.make_presence_sensor(config[CONF_NAME], make_address_array(config[CONF_MAC_ADDRESS]))
|
||||||
+7
-7
@@ -1,12 +1,12 @@
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
import esphomeyaml.config_validation as cv
|
from esphome.components import binary_sensor
|
||||||
from esphomeyaml.components import binary_sensor
|
from esphome.components.esp32_touch import ESP32TouchComponent
|
||||||
from esphomeyaml.components.esp32_touch import ESP32TouchComponent
|
import esphome.config_validation as cv
|
||||||
from esphomeyaml.const import CONF_NAME, CONF_PIN, CONF_THRESHOLD, ESP_PLATFORM_ESP32
|
from esphome.const import CONF_NAME, CONF_PIN, CONF_THRESHOLD, ESP_PLATFORM_ESP32
|
||||||
from esphomeyaml.cpp_generator import get_variable
|
from esphome.cpp_generator import get_variable
|
||||||
from esphomeyaml.cpp_types import global_ns
|
from esphome.cpp_types import global_ns
|
||||||
from esphomeyaml.pins import validate_gpio_pin
|
from esphome.pins import validate_gpio_pin
|
||||||
|
|
||||||
ESP_PLATFORMS = [ESP_PLATFORM_ESP32]
|
ESP_PLATFORMS = [ESP_PLATFORM_ESP32]
|
||||||
|
|
||||||
+10
-12
@@ -1,21 +1,19 @@
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
import esphomeyaml.config_validation as cv
|
from esphome import pins
|
||||||
from esphomeyaml import pins
|
from esphome.components import binary_sensor
|
||||||
from esphomeyaml.components import binary_sensor
|
import esphome.config_validation as cv
|
||||||
from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME, CONF_PIN
|
from esphome.const import CONF_ID, CONF_NAME, CONF_PIN
|
||||||
from esphomeyaml.cpp_generator import variable
|
from esphome.cpp_generator import Pvariable
|
||||||
from esphomeyaml.cpp_helpers import gpio_input_pin_expression, setup_component
|
from esphome.cpp_helpers import gpio_input_pin_expression, setup_component
|
||||||
from esphomeyaml.cpp_types import Application, Component, App
|
from esphome.cpp_types import App, Component
|
||||||
|
|
||||||
MakeGPIOBinarySensor = Application.struct('MakeGPIOBinarySensor')
|
|
||||||
GPIOBinarySensorComponent = binary_sensor.binary_sensor_ns.class_('GPIOBinarySensorComponent',
|
GPIOBinarySensorComponent = binary_sensor.binary_sensor_ns.class_('GPIOBinarySensorComponent',
|
||||||
binary_sensor.BinarySensor,
|
binary_sensor.BinarySensor,
|
||||||
Component)
|
Component)
|
||||||
|
|
||||||
PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(): cv.declare_variable_id(GPIOBinarySensorComponent),
|
cv.GenerateID(): cv.declare_variable_id(GPIOBinarySensorComponent),
|
||||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeGPIOBinarySensor),
|
|
||||||
vol.Required(CONF_PIN): pins.gpio_input_pin_schema
|
vol.Required(CONF_PIN): pins.gpio_input_pin_schema
|
||||||
}).extend(cv.COMPONENT_SCHEMA.schema))
|
}).extend(cv.COMPONENT_SCHEMA.schema))
|
||||||
|
|
||||||
@@ -25,9 +23,9 @@ def to_code(config):
|
|||||||
for pin in gpio_input_pin_expression(config[CONF_PIN]):
|
for pin in gpio_input_pin_expression(config[CONF_PIN]):
|
||||||
yield
|
yield
|
||||||
rhs = App.make_gpio_binary_sensor(config[CONF_NAME], pin)
|
rhs = App.make_gpio_binary_sensor(config[CONF_NAME], pin)
|
||||||
gpio = variable(config[CONF_MAKE_ID], rhs)
|
gpio = Pvariable(config[CONF_ID], rhs)
|
||||||
binary_sensor.setup_binary_sensor(gpio.Pgpio, gpio.Pmqtt, config)
|
binary_sensor.setup_binary_sensor(gpio, config)
|
||||||
setup_component(gpio.Pgpio, config)
|
setup_component(gpio, config)
|
||||||
|
|
||||||
|
|
||||||
BUILD_FLAGS = '-DUSE_GPIO_BINARY_SENSOR'
|
BUILD_FLAGS = '-DUSE_GPIO_BINARY_SENSOR'
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from esphome.components import binary_sensor
|
||||||
|
import esphome.config_validation as cv
|
||||||
|
from esphome.const import CONF_ENTITY_ID, CONF_ID, CONF_NAME
|
||||||
|
from esphome.cpp_generator import Pvariable
|
||||||
|
from esphome.cpp_types import App
|
||||||
|
|
||||||
|
DEPENDENCIES = ['api']
|
||||||
|
|
||||||
|
HomeassistantBinarySensor = binary_sensor.binary_sensor_ns.class_('HomeassistantBinarySensor',
|
||||||
|
binary_sensor.BinarySensor)
|
||||||
|
|
||||||
|
PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend({
|
||||||
|
cv.GenerateID(): cv.declare_variable_id(HomeassistantBinarySensor),
|
||||||
|
vol.Required(CONF_ENTITY_ID): cv.entity_id,
|
||||||
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
def to_code(config):
|
||||||
|
rhs = App.make_homeassistant_binary_sensor(config[CONF_NAME], config[CONF_ENTITY_ID])
|
||||||
|
subs = Pvariable(config[CONF_ID], rhs)
|
||||||
|
binary_sensor.setup_binary_sensor(subs, config)
|
||||||
|
|
||||||
|
|
||||||
|
BUILD_FLAGS = '-DUSE_HOMEASSISTANT_BINARY_SENSOR'
|
||||||
|
|
||||||
|
|
||||||
|
def to_hass_config(data, config):
|
||||||
|
return binary_sensor.core_to_hass_config(data, config)
|
||||||
+5
-5
@@ -1,10 +1,10 @@
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from esphomeyaml.components import binary_sensor, display
|
from esphome.components import binary_sensor, display
|
||||||
from esphomeyaml.components.display.nextion import Nextion
|
from esphome.components.display.nextion import Nextion
|
||||||
import esphomeyaml.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphomeyaml.const import CONF_COMPONENT_ID, CONF_NAME, CONF_PAGE_ID
|
from esphome.const import CONF_COMPONENT_ID, CONF_NAME, CONF_PAGE_ID
|
||||||
from esphomeyaml.cpp_generator import get_variable
|
from esphome.cpp_generator import get_variable
|
||||||
|
|
||||||
DEPENDENCIES = ['display']
|
DEPENDENCIES = ['display']
|
||||||
|
|
||||||
+7
-7
@@ -1,11 +1,11 @@
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
import esphomeyaml.config_validation as cv
|
from esphome.components import binary_sensor
|
||||||
from esphomeyaml.components import binary_sensor
|
from esphome.components.pn532 import PN532Component
|
||||||
from esphomeyaml.components.pn532 import PN532Component
|
import esphome.config_validation as cv
|
||||||
from esphomeyaml.const import CONF_NAME, CONF_UID
|
from esphome.const import CONF_NAME, CONF_UID
|
||||||
from esphomeyaml.core import HexInt
|
from esphome.core import HexInt
|
||||||
from esphomeyaml.cpp_generator import get_variable, ArrayInitializer
|
from esphome.cpp_generator import get_variable
|
||||||
|
|
||||||
DEPENDENCIES = ['pn532']
|
DEPENDENCIES = ['pn532']
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ def to_code(config):
|
|||||||
for hub in get_variable(config[CONF_PN532_ID]):
|
for hub in get_variable(config[CONF_PN532_ID]):
|
||||||
yield
|
yield
|
||||||
addr = [HexInt(int(x, 16)) for x in config[CONF_UID].split('-')]
|
addr = [HexInt(int(x, 16)) for x in config[CONF_UID].split('-')]
|
||||||
rhs = hub.make_tag(config[CONF_NAME], ArrayInitializer(*addr, multiline=False))
|
rhs = hub.make_tag(config[CONF_NAME], addr)
|
||||||
binary_sensor.register_binary_sensor(rhs, config)
|
binary_sensor.register_binary_sensor(rhs, config)
|
||||||
|
|
||||||
|
|
||||||
+4
-4
@@ -1,9 +1,9 @@
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
import esphomeyaml.config_validation as cv
|
from esphome.components import binary_sensor, rdm6300
|
||||||
from esphomeyaml.components import binary_sensor, rdm6300
|
import esphome.config_validation as cv
|
||||||
from esphomeyaml.const import CONF_NAME, CONF_UID
|
from esphome.const import CONF_NAME, CONF_UID
|
||||||
from esphomeyaml.cpp_generator import get_variable
|
from esphome.cpp_generator import get_variable
|
||||||
|
|
||||||
DEPENDENCIES = ['rdm6300']
|
DEPENDENCIES = ['rdm6300']
|
||||||
|
|
||||||
+40
-14
@@ -1,42 +1,60 @@
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
import esphomeyaml.config_validation as cv
|
from esphome.components import binary_sensor
|
||||||
from esphomeyaml.components import binary_sensor
|
from esphome.components.remote_receiver import RemoteReceiverComponent, remote_ns
|
||||||
from esphomeyaml.components.remote_receiver import RemoteReceiverComponent, remote_ns
|
from esphome.components.remote_transmitter import RC_SWITCH_RAW_SCHEMA, \
|
||||||
from esphomeyaml.components.remote_transmitter import RC_SWITCH_RAW_SCHEMA, \
|
|
||||||
RC_SWITCH_TYPE_A_SCHEMA, RC_SWITCH_TYPE_B_SCHEMA, RC_SWITCH_TYPE_C_SCHEMA, \
|
RC_SWITCH_TYPE_A_SCHEMA, RC_SWITCH_TYPE_B_SCHEMA, RC_SWITCH_TYPE_C_SCHEMA, \
|
||||||
RC_SWITCH_TYPE_D_SCHEMA, binary_code, build_rc_switch_protocol
|
RC_SWITCH_TYPE_D_SCHEMA, binary_code, build_rc_switch_protocol
|
||||||
from esphomeyaml.const import CONF_ADDRESS, CONF_CHANNEL, CONF_CODE, CONF_COMMAND, CONF_DATA, \
|
import esphome.config_validation as cv
|
||||||
CONF_DEVICE, CONF_FAMILY, CONF_GROUP, CONF_LG, CONF_NAME, CONF_NBITS, CONF_NEC, \
|
from esphome.const import CONF_ADDRESS, CONF_CHANNEL, CONF_CODE, CONF_COMMAND, CONF_DATA, \
|
||||||
CONF_PANASONIC, CONF_PROTOCOL, CONF_RAW, CONF_RC_SWITCH_RAW, CONF_RC_SWITCH_TYPE_A, \
|
CONF_DEVICE, CONF_FAMILY, CONF_GROUP, CONF_ID, CONF_JVC, CONF_LG, CONF_NAME, CONF_NBITS, \
|
||||||
|
CONF_NEC, CONF_PANASONIC, CONF_PROTOCOL, CONF_RAW, CONF_RC_SWITCH_RAW, CONF_RC_SWITCH_TYPE_A, \
|
||||||
CONF_RC_SWITCH_TYPE_B, CONF_RC_SWITCH_TYPE_C, CONF_RC_SWITCH_TYPE_D, CONF_SAMSUNG, CONF_SONY, \
|
CONF_RC_SWITCH_TYPE_B, CONF_RC_SWITCH_TYPE_C, CONF_RC_SWITCH_TYPE_D, CONF_SAMSUNG, CONF_SONY, \
|
||||||
CONF_STATE
|
CONF_STATE, CONF_RC5
|
||||||
from esphomeyaml.cpp_generator import ArrayInitializer, get_variable, Pvariable
|
from esphome.cpp_generator import Pvariable, get_variable, progmem_array
|
||||||
|
from esphome.cpp_types import int32
|
||||||
|
|
||||||
DEPENDENCIES = ['remote_receiver']
|
DEPENDENCIES = ['remote_receiver']
|
||||||
|
|
||||||
REMOTE_KEYS = [CONF_NEC, CONF_LG, CONF_SONY, CONF_PANASONIC, CONF_SAMSUNG, CONF_RAW,
|
REMOTE_KEYS = [CONF_JVC, CONF_NEC, CONF_LG, CONF_SONY, CONF_PANASONIC, CONF_SAMSUNG, CONF_RAW,
|
||||||
CONF_RC_SWITCH_RAW, CONF_RC_SWITCH_TYPE_A, CONF_RC_SWITCH_TYPE_B,
|
CONF_RC_SWITCH_RAW, CONF_RC_SWITCH_TYPE_A, CONF_RC_SWITCH_TYPE_B,
|
||||||
CONF_RC_SWITCH_TYPE_C, CONF_RC_SWITCH_TYPE_D]
|
CONF_RC_SWITCH_TYPE_C, CONF_RC_SWITCH_TYPE_D, CONF_RC5]
|
||||||
|
|
||||||
CONF_REMOTE_RECEIVER_ID = 'remote_receiver_id'
|
CONF_REMOTE_RECEIVER_ID = 'remote_receiver_id'
|
||||||
CONF_RECEIVER_ID = 'receiver_id'
|
CONF_RECEIVER_ID = 'receiver_id'
|
||||||
|
|
||||||
RemoteReceiver = remote_ns.class_('RemoteReceiver', binary_sensor.BinarySensor)
|
RemoteReceiver = remote_ns.class_('RemoteReceiver', binary_sensor.BinarySensor)
|
||||||
|
JVCReceiver = remote_ns.class_('JVCReceiver', RemoteReceiver)
|
||||||
LGReceiver = remote_ns.class_('LGReceiver', RemoteReceiver)
|
LGReceiver = remote_ns.class_('LGReceiver', RemoteReceiver)
|
||||||
NECReceiver = remote_ns.class_('NECReceiver', RemoteReceiver)
|
NECReceiver = remote_ns.class_('NECReceiver', RemoteReceiver)
|
||||||
PanasonicReceiver = remote_ns.class_('PanasonicReceiver', RemoteReceiver)
|
PanasonicReceiver = remote_ns.class_('PanasonicReceiver', RemoteReceiver)
|
||||||
RawReceiver = remote_ns.class_('RawReceiver', RemoteReceiver)
|
RawReceiver = remote_ns.class_('RawReceiver', RemoteReceiver)
|
||||||
SamsungReceiver = remote_ns.class_('SamsungReceiver', RemoteReceiver)
|
SamsungReceiver = remote_ns.class_('SamsungReceiver', RemoteReceiver)
|
||||||
SonyReceiver = remote_ns.class_('SonyReceiver', RemoteReceiver)
|
SonyReceiver = remote_ns.class_('SonyReceiver', RemoteReceiver)
|
||||||
|
RC5Receiver = remote_ns.class_('RC5Receiver', RemoteReceiver)
|
||||||
RCSwitchRawReceiver = remote_ns.class_('RCSwitchRawReceiver', RemoteReceiver)
|
RCSwitchRawReceiver = remote_ns.class_('RCSwitchRawReceiver', RemoteReceiver)
|
||||||
RCSwitchTypeAReceiver = remote_ns.class_('RCSwitchTypeAReceiver', RCSwitchRawReceiver)
|
RCSwitchTypeAReceiver = remote_ns.class_('RCSwitchTypeAReceiver', RCSwitchRawReceiver)
|
||||||
RCSwitchTypeBReceiver = remote_ns.class_('RCSwitchTypeBReceiver', RCSwitchRawReceiver)
|
RCSwitchTypeBReceiver = remote_ns.class_('RCSwitchTypeBReceiver', RCSwitchRawReceiver)
|
||||||
RCSwitchTypeCReceiver = remote_ns.class_('RCSwitchTypeCReceiver', RCSwitchRawReceiver)
|
RCSwitchTypeCReceiver = remote_ns.class_('RCSwitchTypeCReceiver', RCSwitchRawReceiver)
|
||||||
RCSwitchTypeDReceiver = remote_ns.class_('RCSwitchTypeDReceiver', RCSwitchRawReceiver)
|
RCSwitchTypeDReceiver = remote_ns.class_('RCSwitchTypeDReceiver', RCSwitchRawReceiver)
|
||||||
|
|
||||||
|
|
||||||
|
def validate_raw(value):
|
||||||
|
if isinstance(value, dict):
|
||||||
|
return vol.Schema({
|
||||||
|
cv.GenerateID(): cv.declare_variable_id(int32),
|
||||||
|
vol.Required(CONF_DATA): [vol.Any(vol.Coerce(int), cv.time_period_microseconds)],
|
||||||
|
})(value)
|
||||||
|
return validate_raw({
|
||||||
|
CONF_DATA: value
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(): cv.declare_variable_id(RemoteReceiver),
|
cv.GenerateID(): cv.declare_variable_id(RemoteReceiver),
|
||||||
|
vol.Optional(CONF_JVC): vol.Schema({
|
||||||
|
vol.Required(CONF_DATA): cv.hex_uint32_t,
|
||||||
|
}),
|
||||||
vol.Optional(CONF_LG): vol.Schema({
|
vol.Optional(CONF_LG): vol.Schema({
|
||||||
vol.Required(CONF_DATA): cv.hex_uint32_t,
|
vol.Required(CONF_DATA): cv.hex_uint32_t,
|
||||||
vol.Optional(CONF_NBITS, default=28): cv.one_of(28, 32, int=True),
|
vol.Optional(CONF_NBITS, default=28): cv.one_of(28, 32, int=True),
|
||||||
@@ -56,7 +74,11 @@ PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend
|
|||||||
vol.Required(CONF_ADDRESS): cv.hex_uint16_t,
|
vol.Required(CONF_ADDRESS): cv.hex_uint16_t,
|
||||||
vol.Required(CONF_COMMAND): cv.hex_uint32_t,
|
vol.Required(CONF_COMMAND): cv.hex_uint32_t,
|
||||||
}),
|
}),
|
||||||
vol.Optional(CONF_RAW): [vol.Any(vol.Coerce(int), cv.time_period_microseconds)],
|
vol.Optional(CONF_RC5): vol.Schema({
|
||||||
|
vol.Required(CONF_ADDRESS): vol.All(cv.hex_int, vol.Range(min=0, max=0x1F)),
|
||||||
|
vol.Required(CONF_COMMAND): vol.All(cv.hex_int, vol.Range(min=0, max=0x3F)),
|
||||||
|
}),
|
||||||
|
vol.Optional(CONF_RAW): validate_raw,
|
||||||
vol.Optional(CONF_RC_SWITCH_RAW): RC_SWITCH_RAW_SCHEMA,
|
vol.Optional(CONF_RC_SWITCH_RAW): RC_SWITCH_RAW_SCHEMA,
|
||||||
vol.Optional(CONF_RC_SWITCH_TYPE_A): RC_SWITCH_TYPE_A_SCHEMA,
|
vol.Optional(CONF_RC_SWITCH_TYPE_A): RC_SWITCH_TYPE_A_SCHEMA,
|
||||||
vol.Optional(CONF_RC_SWITCH_TYPE_B): RC_SWITCH_TYPE_B_SCHEMA,
|
vol.Optional(CONF_RC_SWITCH_TYPE_B): RC_SWITCH_TYPE_B_SCHEMA,
|
||||||
@@ -71,6 +93,8 @@ PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend
|
|||||||
def receiver_base(full_config):
|
def receiver_base(full_config):
|
||||||
name = full_config[CONF_NAME]
|
name = full_config[CONF_NAME]
|
||||||
key, config = next((k, v) for k, v in full_config.items() if k in REMOTE_KEYS)
|
key, config = next((k, v) for k, v in full_config.items() if k in REMOTE_KEYS)
|
||||||
|
if key == CONF_JVC:
|
||||||
|
return JVCReceiver.new(name, config[CONF_DATA])
|
||||||
if key == CONF_LG:
|
if key == CONF_LG:
|
||||||
return LGReceiver.new(name, config[CONF_DATA], config[CONF_NBITS])
|
return LGReceiver.new(name, config[CONF_DATA], config[CONF_NBITS])
|
||||||
if key == CONF_NEC:
|
if key == CONF_NEC:
|
||||||
@@ -81,9 +105,11 @@ def receiver_base(full_config):
|
|||||||
return SamsungReceiver.new(name, config[CONF_DATA])
|
return SamsungReceiver.new(name, config[CONF_DATA])
|
||||||
if key == CONF_SONY:
|
if key == CONF_SONY:
|
||||||
return SonyReceiver.new(name, config[CONF_DATA], config[CONF_NBITS])
|
return SonyReceiver.new(name, config[CONF_DATA], config[CONF_NBITS])
|
||||||
|
if key == CONF_RC5:
|
||||||
|
return RC5Receiver.new(name, config[CONF_ADDRESS], config[CONF_COMMAND])
|
||||||
if key == CONF_RAW:
|
if key == CONF_RAW:
|
||||||
data = ArrayInitializer(*config, multiline=False)
|
arr = progmem_array(config[CONF_ID], config[CONF_DATA])
|
||||||
return RawReceiver.new(name, data)
|
return RawReceiver.new(name, arr, len(config[CONF_DATA]))
|
||||||
if key == CONF_RC_SWITCH_RAW:
|
if key == CONF_RC_SWITCH_RAW:
|
||||||
return RCSwitchRawReceiver.new(name, build_rc_switch_protocol(config[CONF_PROTOCOL]),
|
return RCSwitchRawReceiver.new(name, build_rc_switch_protocol(config[CONF_PROTOCOL]),
|
||||||
binary_code(config[CONF_CODE]), len(config[CONF_CODE]))
|
binary_code(config[CONF_CODE]), len(config[CONF_CODE]))
|
||||||
+9
-12
@@ -1,27 +1,24 @@
|
|||||||
import esphomeyaml.config_validation as cv
|
from esphome.components import binary_sensor
|
||||||
from esphomeyaml.components import binary_sensor
|
import esphome.config_validation as cv
|
||||||
from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME
|
from esphome.const import CONF_ID, CONF_NAME
|
||||||
from esphomeyaml.cpp_generator import variable
|
from esphome.cpp_generator import Pvariable
|
||||||
from esphomeyaml.cpp_helpers import setup_component
|
from esphome.cpp_helpers import setup_component
|
||||||
from esphomeyaml.cpp_types import Application, Component, App
|
from esphome.cpp_types import App, Component
|
||||||
|
|
||||||
|
|
||||||
MakeStatusBinarySensor = Application.struct('MakeStatusBinarySensor')
|
|
||||||
StatusBinarySensor = binary_sensor.binary_sensor_ns.class_('StatusBinarySensor',
|
StatusBinarySensor = binary_sensor.binary_sensor_ns.class_('StatusBinarySensor',
|
||||||
binary_sensor.BinarySensor,
|
binary_sensor.BinarySensor,
|
||||||
Component)
|
Component)
|
||||||
|
|
||||||
PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeStatusBinarySensor),
|
|
||||||
cv.GenerateID(): cv.declare_variable_id(StatusBinarySensor),
|
cv.GenerateID(): cv.declare_variable_id(StatusBinarySensor),
|
||||||
}).extend(cv.COMPONENT_SCHEMA.schema))
|
}).extend(cv.COMPONENT_SCHEMA.schema))
|
||||||
|
|
||||||
|
|
||||||
def to_code(config):
|
def to_code(config):
|
||||||
rhs = App.make_status_binary_sensor(config[CONF_NAME])
|
rhs = App.make_status_binary_sensor(config[CONF_NAME])
|
||||||
status = variable(config[CONF_MAKE_ID], rhs)
|
status = Pvariable(config[CONF_ID], rhs)
|
||||||
binary_sensor.setup_binary_sensor(status.Pstatus, status.Pmqtt, config)
|
binary_sensor.setup_binary_sensor(status, config)
|
||||||
setup_component(status.Pstatus, config)
|
setup_component(status, config)
|
||||||
|
|
||||||
|
|
||||||
BUILD_FLAGS = '-DUSE_STATUS_BINARY_SENSOR'
|
BUILD_FLAGS = '-DUSE_STATUS_BINARY_SENSOR'
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from esphome.automation import ACTION_REGISTRY
|
||||||
|
from esphome.components import binary_sensor
|
||||||
|
import esphome.config_validation as cv
|
||||||
|
from esphome.const import CONF_ID, CONF_LAMBDA, CONF_NAME, CONF_STATE
|
||||||
|
from esphome.cpp_generator import Pvariable, add, get_variable, process_lambda, templatable
|
||||||
|
from esphome.cpp_helpers import setup_component
|
||||||
|
from esphome.cpp_types import Action, App, Component, bool_, optional
|
||||||
|
|
||||||
|
TemplateBinarySensor = binary_sensor.binary_sensor_ns.class_('TemplateBinarySensor',
|
||||||
|
binary_sensor.BinarySensor,
|
||||||
|
Component)
|
||||||
|
BinarySensorPublishAction = binary_sensor.binary_sensor_ns.class_('BinarySensorPublishAction',
|
||||||
|
Action)
|
||||||
|
|
||||||
|
PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend({
|
||||||
|
cv.GenerateID(): cv.declare_variable_id(TemplateBinarySensor),
|
||||||
|
vol.Optional(CONF_LAMBDA): cv.lambda_,
|
||||||
|
}).extend(cv.COMPONENT_SCHEMA.schema))
|
||||||
|
|
||||||
|
|
||||||
|
def to_code(config):
|
||||||
|
rhs = App.make_template_binary_sensor(config[CONF_NAME])
|
||||||
|
var = Pvariable(config[CONF_ID], rhs)
|
||||||
|
binary_sensor.setup_binary_sensor(var, config)
|
||||||
|
setup_component(var, config)
|
||||||
|
|
||||||
|
if CONF_LAMBDA in config:
|
||||||
|
for template_ in process_lambda(config[CONF_LAMBDA], [],
|
||||||
|
return_type=optional.template(bool_)):
|
||||||
|
yield
|
||||||
|
add(var.set_template(template_))
|
||||||
|
|
||||||
|
|
||||||
|
BUILD_FLAGS = '-DUSE_TEMPLATE_BINARY_SENSOR'
|
||||||
|
|
||||||
|
CONF_BINARY_SENSOR_TEMPLATE_PUBLISH = 'binary_sensor.template.publish'
|
||||||
|
BINARY_SENSOR_TEMPLATE_PUBLISH_ACTION_SCHEMA = vol.Schema({
|
||||||
|
vol.Required(CONF_ID): cv.use_variable_id(binary_sensor.BinarySensor),
|
||||||
|
vol.Required(CONF_STATE): cv.templatable(cv.boolean),
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ACTION_REGISTRY.register(CONF_BINARY_SENSOR_TEMPLATE_PUBLISH,
|
||||||
|
BINARY_SENSOR_TEMPLATE_PUBLISH_ACTION_SCHEMA)
|
||||||
|
def binary_sensor_template_publish_to_code(config, action_id, arg_type, template_arg):
|
||||||
|
for var in get_variable(config[CONF_ID]):
|
||||||
|
yield None
|
||||||
|
rhs = var.make_binary_sensor_publish_action(template_arg)
|
||||||
|
type = BinarySensorPublishAction.template(arg_type)
|
||||||
|
action = Pvariable(action_id, rhs, type=type)
|
||||||
|
for template_ in templatable(config[CONF_STATE], arg_type, bool_):
|
||||||
|
yield None
|
||||||
|
add(action.set_state(template_))
|
||||||
|
yield action
|
||||||
|
|
||||||
|
|
||||||
|
def to_hass_config(data, config):
|
||||||
|
return binary_sensor.core_to_hass_config(data, config)
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user