Skip to content

Commit

Permalink
release to the wild
Browse files Browse the repository at this point in the history
  • Loading branch information
dentra committed Feb 7, 2022
1 parent 5038bd2 commit 2ad3e18
Show file tree
Hide file tree
Showing 43 changed files with 3,467 additions and 19 deletions.
25 changes: 25 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM esphome/esphome-lint:dev

ARG esphome_version
ARG apt_deps

RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y --no-install-recommends sudo $apt_deps \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# pyparsing needed to fix https://github.com/esphome/issues/issues/2540
RUN pip3 --disable-pip-version-check --no-cache-dir install esphome==$esphome_version pyparsing==2.2.0 \
&& rm -rf /tmp/pip-tmp

RUN echo "alias ll='ls -l'" >> /etc/bash.bashrc \
&& echo "alias la='ls -A'" >> /etc/bash.bashrc \
&& echo "alias l='ls -CF'" >> /etc/bash.bashrc

RUN useradd -m -s /bin/bash -G sudo vscode \
&& echo "vscode ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/vscode \
&& chmod 0440 /etc/sudoers.d/vscode

RUN mv /root/.platformio /home/vscode && chown -R vscode:vscode /home/vscode/.platformio /esphome /piolibs

82 changes: 82 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"dockerFile": "Dockerfile",
"build": {
"args": {
// ESPHome version
"esphome_version": "2022.1.2",
// additional APT dependicies
"apt_deps": "bash-completion less libmbedtls-dev gdb"
}
},
"runArgs": [
"-e",
"ESPHOME_DASHBOARD_USE_PING=1"
],
//"appPort": 6052,
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"diffEditor.ignoreTrimWhitespace": true,
"files.autoSave": "onFocusChange",
"files.trimTrailingWhitespace": true,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.formatOnPaste": false,
"python.pythonPath": "/usr/bin/python3",
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.languageServer": "Pylance",
"python.formatting.provider": "black",
"yaml.customTags": [
"!secret scalar",
"!lambda scalar",
"!include_dir_named scalar",
"!include_dir_list scalar",
"!include_dir_merge_list scalar",
"!include_dir_merge_named scalar"
],
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
"**/*.pyc": {
"when": "$(basename).py"
},
"**/__pycache__": true,
".esphome": true,
".pio": true
},
"files.associations": {
"**/.vscode/*.json": "jsonc"
},
"C_Cpp.clang_format_path": "/usr/bin/clang-format-11",
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
// cpp
"ms-vscode.cpptools",
// python
"ms-python.python",
"ms-python.vscode-pylance",
"visualstudioexptteam.vscodeintellicode",
// yaml
"redhat.vscode-yaml",
// esphome yaml
"esphome.esphome-vscode",
// editorconfig
"editorconfig.editorconfig",
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
"postCreateCommand": [
".devcontainer/post-create.sh"
],
"postStartCommand": [
".devcontainer/post-start.sh"
],
// Comment out this line to run as root instead.
"remoteUser": "vscode",
"mounts": [
"source=vscode-${containerWorkspaceFolderBasename},target=${containerWorkspaceFolder}/.esphome,type=volume",
"source=vscode-${containerWorkspaceFolderBasename},target=${containerWorkspaceFolder}/.pio,type=volume",
]
}
46 changes: 46 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

set -e

# take ownership of mounted folders
files=(.esphome .pio)
for f in "${files[@]}" ; do
if [ ! -d "$f" ]; then
mkdir "$f"
else
sudo chown -R vscode:vscode "$f"
fi
done

pio_ini=platformio.ini

files=($pio_ini .clang-format .clang-tidy .editorconfig)

for f in "${files[@]}" ; do
if [ ! -f "$f" ]; then
curl -Ls "https://github.com/esphome/esphome/raw/dev/$f" -o ".esphome/$f"
ln -sv ".esphome/$f" "$f"
fi
done


# replace "esphome" to "." in src_dir. esphome linked at post-start.sh
sed -i -e "/src_dir/s/esphome/\./" $pio_ini
# replace ".temp" to ".esphome in "sdkconfig_path"
sed -i -e "/sdkconfig_path/s/.temp/.esphome/" $pio_ini

cpp_json=.vscode/c_cpp_properties.json
if [ ! -f $cpp_json ]; then
pio init --ide vscode --silent -e esp32
sed -i "/\\/workspaces\/esphome\/include/d" $cpp_json
rm CMakeLists.txt components/CMakeLists.txt
else
echo "Cpp environment already configured. To reconfigure it you could run one the following commands:"
echo " pio init --ide vscode -e esp8266"
echo " pio init --ide vscode -e esp32"
echo " pio init --ide vscode -e esp32-idf"
fi

# additionally remove annoying pio ide recomendations
sed -i "/platformio.platformio-ide/d" .vscode/extensions.json

9 changes: 9 additions & 0 deletions .devcontainer/post-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -e

if [ ! -L esphome ]; then
ln -sv $(python3 -c 'import esphome as _; print(_.__path__[0])') esphome
fi

find . -type d \( -name .esphome -or -name .pio \) -exec sudo chown -R vscode:vscode {} \;
36 changes: 17 additions & 19 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
.DS_Store

/.esphome/
**/.pioenvs/
**/.piolibdeps/
**/.pio/
**/src/
**/lib/
**/platformio.ini
**/partitions.csv

*.pyc

/secrets.yaml

/esphome
/.pio
secrets.yaml

/.vscode/

/esphome
/.esphome/
/.pio/
/include/
/src/
/lib/
/platformio.ini
/partitions.csv
CMakeListsPrivate.txt
CMakeLists.txt
compile_commands.json
.clang_complete
.gcc-flags.json
.temp-clang-tidy.cpp

/compile_commands.json
/.clang_complete
/.gcc-flags.json
/.temp-clang-tidy.cpp
/.clang-format
/.clang-tidy
/.editorconfig
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Dennis Trachuk

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
127 changes: 127 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
[![Open in Visual Studio Code][open-in-vscode-shield]][open-in-vscode]
[![PayPal.Me][paypal-me-shield]][paypal-me]

[open-in-vscode-shield]: https://open.vscode.dev/badges/open-in-vscode.svg
[open-in-vscode]: https://open.vscode.dev/dentra/esphome-components

[paypal-me-shield]: https://img.shields.io/static/v1.svg?label=%20&message=PayPal.Me&logo=paypal
[paypal-me]: https://paypal.me/dentra0

# Tion

This is a ESPHome component to control `Tion 4s` and `Tion Lite` Breezers from ESP32 via BLE protocol.

At this moment the componet is build using climate platform and allows to control:

* On/Off
* Heater On/Off
* Fan speed
* Buzzer
* Led
* Inflow/Recirculation (4s Only)
* Boost Mode (4s Only)
* Boost Time (4s Only)

And additionaly monitor:

* Temperature inside
* Temperature outside
* Heater power
* Filter days left
* Filter warnout state
* Airflow counter
* Version

## Usage
> Everything that you do, you do at your own risk
### Sample configuration for Tion 4s
```yaml
external_components:
- source: github://dentra/[email protected]

ota:
on_begin:
then:
- lambda: id(ble_client_tion).set_enabled(false);

esp32_ble_tracker:

ble_client:
- mac_address: $mac_tion
id: ble_client_tion

climate:
- platform: tion_4s
ble_client_id: ble_client_tion
name: "$name"
buzzer:
name: "$name Buzzer"
led:
name: "$name Led"
recirculation:
name: "$name Recirculation"
temp_in:
name: "$name Temp in"
temp_out:
name: "$name Temp out"
heater_power:
name: "$name Heater power"
airflow_counter:
name: "$name Airflow counter"
filter_days_left:
name: "$name Filter Days Left"
filter_warnout:
name: "$name Filter Warnout"
boost_time:
name: "$name Boost Time"
version:
name: "$name Version"
```
### Sample configuration for Tion Lite
```yaml
external_components:
- source: github://dentra/[email protected]

ota:
on_begin:
then:
- lambda: id(ble_client_tion).set_enabled(false);

esp32_ble_tracker:

ble_client:
- mac_address: $mac_tion
id: ble_client_tion

climate:
- platform: tion_lt
ble_client_id: ble_client_tion1
name: "$name"
buzzer:
name: "$name Buzzer"
led:
name: "$name Led"
temp_in:
name: "$name Temp in"
temp_out:
name: "$name Temp out"
heater_power:
name: "$name Heater power"
airflow_counter:
name: "$name Airflow counter"
filter_days_left:
name: "$name Filter Days Left"
filter_warnout:
name: "$name Filter Warnout"
version:
name: "$name Version"
```
## Issue reporting
Feel free to open issues for bug reporting and feature requests. Will accept English and Russian language.
## Your thanks
If this project was useful to you, you can [buy me](https://paypal.me/dentra0) a Cup of coffee :)
Empty file added components/tion-api/__init__.py
Empty file.
Loading

0 comments on commit 2ad3e18

Please sign in to comment.