├── ESP8266_MINI.bin
├── images
├── Athom_CB01.png
├── Athom_CB02.png
├── Athom_7w_Bulb.png
├── Athom_EU_Plug.png
├── Athom_UK_Plug.png
├── Athom_US_Plug.png
├── Athom_15w_Bulb.png
├── Athom_BR30_Bulb.png
├── Athom_GU10_Bulb.png
├── Athom_AU_Plug_V2.png
├── Athom_BR_Plug_V2.png
├── Athom_EU_Plug_V2.png
├── Athom_IL_Plug_V2.png
├── Athom_IT_Plug_V2.png
├── Athom_Mini_Relay.png
├── Athom_UK_Plug_V2.png
├── Athom_US_Plug_V2.png
├── Athom_Wall_Outlet.png
├── Athom_RGB_Controller.png
├── Athom_1Gang_Key_Switch.png
├── Athom_1Gang_US_Switch.png
├── Athom_2Gang_Key_Switch.png
├── Athom_3Gang_Key_Switch.png
├── Athom_3Pin_Controller.png
├── Athom_4Pin_Controller.png
├── Athom_Presence_Sensor.png
├── Athom_RGBW_Controller.png
├── Athom_1Gang_Touch_Switch.png
├── Athom_2Gang_Touch_Switch.png
├── Athom_3Gang_Touch_Switch.png
├── Athom_4Gang_Touch_Swtich.png
└── Athom_Garage_Door_Opener.png
├── tasmota-minimal.bin.gz
├── .github
├── dependabot.yml
└── workflows
│ ├── publish-firmware.yml
│ ├── ci.yml
│ └── publish-pages.yml
├── static
├── _config.yml
└── index.md
├── .gitignore
├── LICENSE
├── athom-ws2812b.yaml
├── athom-ls-4p-3wire.yaml
├── athom-ls-4p-4wire.yaml
├── README.md
├── athom-relay-board-x1.yaml
├── athom-relay-board-x2.yaml
├── athom-relay-board-x4.yaml
├── athom-rgb-light.yaml
├── athom-rgbw-light.yaml
├── athom-relay-board-x8.yaml
├── athom-garage-door.yaml
├── athom-cb02.yaml
├── athom-sw01.yaml
├── athom-sw01-v2.yaml
├── athom-mini-switch.yaml
├── athom-sw02.yaml
├── athom-sw02-v2.yaml
├── athom-sw04.yaml
├── athom-rgbww-light.yaml
├── athom-rgbct-light.yaml
├── athom-without-relay-plug.yaml
├── athom-sw03.yaml
├── athom-wall-outlet.yaml
└── athom-smart-plug-v2.yaml
/ESP8266_MINI.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/ESP8266_MINI.bin
--------------------------------------------------------------------------------
/images/Athom_CB01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_CB01.png
--------------------------------------------------------------------------------
/images/Athom_CB02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_CB02.png
--------------------------------------------------------------------------------
/images/Athom_7w_Bulb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_7w_Bulb.png
--------------------------------------------------------------------------------
/images/Athom_EU_Plug.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_EU_Plug.png
--------------------------------------------------------------------------------
/images/Athom_UK_Plug.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_UK_Plug.png
--------------------------------------------------------------------------------
/images/Athom_US_Plug.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_US_Plug.png
--------------------------------------------------------------------------------
/tasmota-minimal.bin.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/tasmota-minimal.bin.gz
--------------------------------------------------------------------------------
/images/Athom_15w_Bulb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_15w_Bulb.png
--------------------------------------------------------------------------------
/images/Athom_BR30_Bulb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_BR30_Bulb.png
--------------------------------------------------------------------------------
/images/Athom_GU10_Bulb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_GU10_Bulb.png
--------------------------------------------------------------------------------
/images/Athom_AU_Plug_V2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_AU_Plug_V2.png
--------------------------------------------------------------------------------
/images/Athom_BR_Plug_V2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_BR_Plug_V2.png
--------------------------------------------------------------------------------
/images/Athom_EU_Plug_V2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_EU_Plug_V2.png
--------------------------------------------------------------------------------
/images/Athom_IL_Plug_V2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_IL_Plug_V2.png
--------------------------------------------------------------------------------
/images/Athom_IT_Plug_V2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_IT_Plug_V2.png
--------------------------------------------------------------------------------
/images/Athom_Mini_Relay.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_Mini_Relay.png
--------------------------------------------------------------------------------
/images/Athom_UK_Plug_V2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_UK_Plug_V2.png
--------------------------------------------------------------------------------
/images/Athom_US_Plug_V2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_US_Plug_V2.png
--------------------------------------------------------------------------------
/images/Athom_Wall_Outlet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_Wall_Outlet.png
--------------------------------------------------------------------------------
/images/Athom_RGB_Controller.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_RGB_Controller.png
--------------------------------------------------------------------------------
/images/Athom_1Gang_Key_Switch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_1Gang_Key_Switch.png
--------------------------------------------------------------------------------
/images/Athom_1Gang_US_Switch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_1Gang_US_Switch.png
--------------------------------------------------------------------------------
/images/Athom_2Gang_Key_Switch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_2Gang_Key_Switch.png
--------------------------------------------------------------------------------
/images/Athom_3Gang_Key_Switch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_3Gang_Key_Switch.png
--------------------------------------------------------------------------------
/images/Athom_3Pin_Controller.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_3Pin_Controller.png
--------------------------------------------------------------------------------
/images/Athom_4Pin_Controller.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_4Pin_Controller.png
--------------------------------------------------------------------------------
/images/Athom_Presence_Sensor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_Presence_Sensor.png
--------------------------------------------------------------------------------
/images/Athom_RGBW_Controller.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_RGBW_Controller.png
--------------------------------------------------------------------------------
/images/Athom_1Gang_Touch_Switch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_1Gang_Touch_Switch.png
--------------------------------------------------------------------------------
/images/Athom_2Gang_Touch_Switch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_2Gang_Touch_Switch.png
--------------------------------------------------------------------------------
/images/Athom_3Gang_Touch_Switch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_3Gang_Touch_Switch.png
--------------------------------------------------------------------------------
/images/Athom_4Gang_Touch_Swtich.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_4Gang_Touch_Swtich.png
--------------------------------------------------------------------------------
/images/Athom_Garage_Door_Opener.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/athom-tech/athom-configs/HEAD/images/Athom_Garage_Door_Opener.png
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "github-actions"
4 | directory: "/"
5 | schedule:
6 | interval: "weekly"
--------------------------------------------------------------------------------
/static/_config.yml:
--------------------------------------------------------------------------------
1 | # CHANGEME: Set these variable to your liking
2 | title: Athom Technology ESPHome Project
3 | description: Powered by ESPHome and ESP Web Tools
4 | theme: jekyll-theme-slate
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Gitignore settings for ESPHome
2 | # This is an example and may include too much for your use-case.
3 | # You can modify this file to suit your needs.
4 | /.esphome/
5 | **/.pioenvs/
6 | **/.piolibdeps/
7 | **/lib/
8 | **/src/
9 | **/platformio.ini
10 | /secrets.yaml
11 |
--------------------------------------------------------------------------------
/static/index.md:
--------------------------------------------------------------------------------
1 | # About
2 |
3 | ESPhome project by Shenzhen Athom Technology Co., Ltd., China.
4 |
5 | # Installation
6 |
7 | You can use the button below to install the pre-built firmware directly to your device via USB from the browser.
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Jesse Hills
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/.github/workflows/publish-firmware.yml:
--------------------------------------------------------------------------------
1 | name: Publish Firmware
2 |
3 | on:
4 | release:
5 | types: [published]
6 |
7 | permissions:
8 | contents: write
9 |
10 | jobs:
11 | build-firmware:
12 | name: Build Firmware
13 | uses: esphome/workflows/.github/workflows/build.yml@2025.8.1
14 | with:
15 | #### Modify below here to match your project ####
16 | files: |
17 | athom-cb02.yaml
18 | athom-garage-door.yaml
19 | athom-mini-switch.yaml
20 | athom-presence-sensor.yaml
21 | athom-relay-board-x1.yaml
22 | athom-relay-board-x2.yaml
23 | athom-relay-board-x4.yaml
24 | athom-relay-board-x8.yaml
25 | athom-rgb-light.yaml
26 | athom-rgbct-light.yaml
27 | athom-rgbw-light.yaml
28 | athom-rgbww-light.yaml
29 | athom-smart-plug-v2.yaml
30 | athom-smart-plug.yaml
31 | athom-sw01-v2.yaml
32 | athom-sw01.yaml
33 | athom-sw02-v2.yaml
34 | athom-sw02.yaml
35 | athom-sw03.yaml
36 | athom-sw04.yaml
37 | athom-wall-outlet.yaml
38 | athom-without-relay-plug.yaml
39 | esphome-version: 2025.8.0
40 | combined-name: project-template
41 | #### Modify above here to match your project ####
42 |
43 | release-summary: ${{ github.event.release.body }}
44 | release-url: ${{ github.event.release.html_url }}
45 | release-version: ${{ github.event.release.tag_name }}
46 |
47 | upload-to-release:
48 | name: Upload to Release
49 | uses: esphome/workflows/.github/workflows/upload-to-gh-release.yml@2025.8.1
50 | needs:
51 | - build-firmware
52 | with:
53 | version: ${{ github.event.release.tag_name }}
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on:
4 | pull_request:
5 | paths:
6 | - '*.yaml'
7 | - '.github/workflows/ci.yml'
8 | schedule:
9 | - cron: '0 0 * * *'
10 |
11 | concurrency:
12 | group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
13 | cancel-in-progress: true
14 |
15 | jobs:
16 | ci:
17 | name: Building ${{ matrix.file }} / ${{ matrix.esphome-version }}
18 | runs-on: ubuntu-latest
19 | strategy:
20 | fail-fast: false
21 | max-parallel: 3
22 | matrix:
23 | #### Modify below here to match your project ####
24 | file:
25 | - athom-cb02
26 | - athom-garage-door
27 | - athom-mini-switch
28 | - athom-presence-sensor
29 | - athom-relay-board-x1
30 | - athom-relay-board-x2
31 | - athom-relay-board-x4
32 | - athom-relay-board-x8
33 | - athom-rgb-light
34 | - athom-rgbct-light
35 | - athom-rgbw-light
36 | - athom-rgbww-light
37 | - athom-smart-plug-v2
38 | - athom-smart-plug
39 | - athom-sw01-v2
40 | - athom-sw01
41 | - athom-sw02-v2
42 | - athom-sw02
43 | - athom-sw03
44 | - athom-sw04
45 | - athom-wall-outlet
46 | - athom-without-relay-plug
47 | #### Modify above here to match your project ####
48 |
49 | esphome-version:
50 | - stable
51 | - beta
52 | - dev
53 | steps:
54 | - name: Checkout source code
55 | uses: actions/checkout@v5
56 | - name: ESPHome ${{ matrix.esphome-version }}
57 | uses: esphome/build-action@v7
58 | with:
59 | yaml-file: ${{ matrix.file }}.yaml
60 | version: ${{ matrix.esphome-version }}
--------------------------------------------------------------------------------
/.github/workflows/publish-pages.yml:
--------------------------------------------------------------------------------
1 | name: Publish Pages
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | paths:
8 | - 'static/**'
9 | - '.github/workflows/publish-pages.yml'
10 | workflow_run:
11 | workflows:
12 | - Publish Firmware
13 | types:
14 | - completed
15 | pull_request:
16 | paths:
17 | - 'static/**'
18 | - '.github/workflows/publish-pages.yml'
19 |
20 |
21 | concurrency:
22 | group: ${{ github.workflow }}-${{ github.ref }}
23 | cancel-in-progress: true
24 |
25 | jobs:
26 | build:
27 | name: Build
28 | runs-on: ubuntu-latest
29 | steps:
30 | - name: Checkout source code
31 | uses: actions/checkout@v5
32 |
33 | - run: mkdir -p output/firmware
34 |
35 | - name: Build
36 | uses: actions/jekyll-build-pages@v1
37 | with:
38 | source: ./static
39 | destination: ./output
40 |
41 | - name: Fetch firmware files
42 | uses: robinraju/release-downloader@v1
43 | with:
44 | latest: true
45 | fileName: '*'
46 | out-file-path: output/firmware
47 |
48 | - name: Upload artifact
49 | uses: actions/upload-pages-artifact@v4
50 | with:
51 | path: output
52 | retention-days: 1
53 |
54 | publish:
55 | if: github.event_name != 'pull_request'
56 | name: Publish
57 | runs-on: ubuntu-latest
58 | needs:
59 | - build
60 | permissions:
61 | pages: write
62 | id-token: write
63 | environment:
64 | name: github-pages
65 | url: ${{ steps.deployment.outputs.page_url }}
66 | steps:
67 | - name: Setup Pages
68 | uses: actions/configure-pages@v5
69 |
70 | - name: Deploy to GitHub Pages
71 | id: deployment
72 | uses: actions/deploy-pages@v4
--------------------------------------------------------------------------------
/athom-ws2812b.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | device_name: "athom-ws2812b"
3 | project_name: "China Athom Technology.WS2812B Controller"
4 | project_version: "1.1.2"
5 | button_toggle: "true"
6 | led_restore_mode: RESTORE_DEFAULT_OFF
7 | number_of_leds: '150'
8 | led_rgb_order: GRB
9 | led_chipset: WS2811
10 |
11 | esphome:
12 | name: "${device_name}"
13 | friendly_name: ""
14 | name_add_mac_suffix: true
15 | min_version: 2024.6.0
16 | project:
17 | name: "${project_name}"
18 | version: "${project_version}"
19 | platformio_options:
20 | board_upload.flash_size: 2MB
21 | board_upload.maximum_size: 2097152
22 | board_build.ldscript: eagle.flash.2m.ld
23 |
24 | esp8266:
25 | board: esp8285
26 | restore_from_flash: true
27 | framework:
28 | version: 2.7.4
29 |
30 | preferences:
31 | flash_write_interval: 1min
32 |
33 | api:
34 |
35 | ota:
36 | - platform: esphome
37 |
38 | logger:
39 | baud_rate: 0
40 |
41 | web_server:
42 | port: 80
43 |
44 | wifi:
45 | ap: {} # This spawns an AP with the device name and mac address with no password.
46 |
47 | mdns:
48 | disabled: false
49 |
50 | captive_portal:
51 |
52 | dashboard_import:
53 | package_import_url: github://athom-tech/athom-configs/athom-ws2812b.yaml
54 |
55 | binary_sensor:
56 | - platform: status
57 | name: "Status"
58 |
59 | - platform: gpio
60 | pin:
61 | number: 0
62 | mode: INPUT_PULLUP
63 | inverted: true
64 | name: "Power Button"
65 | disabled_by_default: true
66 | on_multi_click:
67 | - timing:
68 | - ON for at most 1s
69 | - OFF for at least 0.2s
70 | then:
71 | - light.toggle: leds
72 | - timing:
73 | - ON for at least 4s
74 | then:
75 | - button.press: Reset
76 |
77 | sensor:
78 | - platform: uptime
79 | name: "Uptime Sensor"
80 |
81 | - platform: wifi_signal
82 | name: "WiFi Signal"
83 | update_interval: 60s
84 |
85 | button:
86 | - platform: factory_reset
87 | name: "Reset"
88 | id: Reset
89 |
90 | - platform: safe_mode
91 | name: "Safe Mode"
92 | internal: false
93 |
94 | light:
95 | - platform: fastled_clockless
96 | pin: GPIO1
97 | id: leds
98 | name: "WS2812B Controller"
99 | chipset: ${led_chipset}
100 | num_leds: ${number_of_leds}
101 | rgb_order: ${led_rgb_order}
102 | restore_mode: ${led_restore_mode}
103 | effects:
104 | - addressable_rainbow:
105 | - addressable_scan:
106 |
107 | text_sensor:
108 | - platform: wifi_info
109 | ip_address:
110 | name: "IP Address"
111 | ssid:
112 | name: "Connected SSID"
113 | mac_address:
114 | name: "Mac Address"
115 |
116 | time:
117 | - platform: sntp
118 | id: sntp_time
119 |
--------------------------------------------------------------------------------
/athom-ls-4p-3wire.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | device_name: "athom-ls-4p-3wire"
3 | project_name: "China Athom Technology.LS 4P 3Wire"
4 | project_version: "1.1.2"
5 | button_toggle: "true"
6 | led_restore_mode: RESTORE_DEFAULT_OFF
7 | number_of_leds: '150'
8 | led_rgb_order: GRB
9 | led_chipset: WS2811
10 |
11 | esphome:
12 | name: "${device_name}"
13 | friendly_name: ""
14 | name_add_mac_suffix: true
15 | min_version: 2024.6.0
16 | platformio_options:
17 | board_upload.flash_size: 2MB
18 | board_upload.maximum_size: 2097152
19 | board_build.ldscript: eagle.flash.2m.ld
20 | project:
21 | name: "${project_name}"
22 | version: "${project_version}"
23 |
24 | esp8266:
25 | board: esp8285
26 | restore_from_flash: true
27 | framework:
28 | version: 2.7.4
29 |
30 | api:
31 |
32 | ota:
33 | - platform: esphome
34 |
35 | logger:
36 | baud_rate: 0
37 |
38 | web_server:
39 | port: 80
40 |
41 | wifi:
42 | ap: {} # This spawns an AP with the device name and mac address with no password.
43 |
44 | mdns:
45 | disabled: false
46 |
47 | captive_portal:
48 |
49 | dashboard_import:
50 | package_import_url: github://athom-tech/athom-configs/athom-ls-4p-3wire.yaml
51 |
52 | binary_sensor:
53 | - platform: status
54 | name: "Status"
55 |
56 | - platform: gpio
57 | pin:
58 | number: 0
59 | mode: INPUT_PULLUP
60 | inverted: true
61 | name: "Power Button"
62 | disabled_by_default: true
63 | on_multi_click:
64 | - timing:
65 | - ON for at most 1s
66 | - OFF for at least 0.2s
67 | then:
68 | - light.toggle: leds
69 | - timing:
70 | - ON for at least 4s
71 | then:
72 | - button.press: Reset
73 |
74 | sensor:
75 | - platform: uptime
76 | name: "Uptime Sensor"
77 |
78 | - platform: wifi_signal
79 | name: "WiFi Signal"
80 | update_interval: 60s
81 |
82 | button:
83 | - platform: factory_reset
84 | name: "Reset"
85 | id: Reset
86 |
87 | - platform: safe_mode
88 | name: "Safe Mode"
89 | internal: false
90 |
91 | power_supply:
92 | - id: relay
93 | pin: GPIO12
94 |
95 | light:
96 | - platform: fastled_clockless
97 | pin: GPIO1
98 | id: leds
99 | name: "Light strip controller"
100 | power_supply: relay
101 | chipset: ${led_chipset}
102 | num_leds: ${number_of_leds}
103 | rgb_order: ${led_rgb_order}
104 | restore_mode: ${led_restore_mode}
105 | effects:
106 | - addressable_rainbow:
107 | - addressable_scan:
108 |
109 | text_sensor:
110 | - platform: wifi_info
111 | ip_address:
112 | name: "IP Address"
113 | ssid:
114 | name: "Connected SSID"
115 | mac_address:
116 | name: "Mac Address"
117 |
118 | time:
119 | - platform: sntp
120 | id: sntp_time
121 |
--------------------------------------------------------------------------------
/athom-ls-4p-4wire.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | device_name: "athom-ls-4p-4wire"
3 | project_name: "China Athom Technology.LS 4P 4Wire"
4 | project_version: "1.1.2"
5 | button_toggle: "true"
6 | light_restore_mode: RESTORE_DEFAULT_OFF
7 | number_of_leds: '150'
8 | led_chipset: WS2801
9 | led_rgb_order: GRB
10 |
11 | esphome:
12 | name: "${device_name}"
13 | friendly_name: ""
14 | name_add_mac_suffix: true
15 | min_version: 2024.6.0
16 | project:
17 | name: "${project_name}"
18 | version: "${project_version}"
19 | platformio_options:
20 | board_upload.flash_size: 2MB
21 | board_upload.maximum_size: 2097152
22 | board_build.ldscript: eagle.flash.2m.ld
23 |
24 | esp8266:
25 | board: esp8285
26 | restore_from_flash: true
27 | framework:
28 | version: 2.7.4
29 |
30 | api:
31 |
32 | ota:
33 | - platform: esphome
34 |
35 | logger:
36 | baud_rate: 0
37 |
38 | web_server:
39 | port: 80
40 |
41 | wifi:
42 | ap: {} # This spawns an AP with the device name and mac address with no password.
43 |
44 | mdns:
45 | disabled: false
46 |
47 | captive_portal:
48 |
49 | dashboard_import:
50 | package_import_url: github://athom-tech/athom-configs/athom-ls-4p-4wire.yaml
51 |
52 | binary_sensor:
53 | - platform: status
54 | name: "Status"
55 |
56 | - platform: gpio
57 | pin:
58 | number: 0
59 | mode: INPUT_PULLUP
60 | inverted: true
61 | name: "Power Button"
62 | disabled_by_default: true
63 | on_multi_click:
64 | - timing:
65 | - ON for at most 1s
66 | - OFF for at least 0.2s
67 | then:
68 | - light.toggle: leds
69 | - timing:
70 | - ON for at least 4s
71 | then:
72 | - button.press: Reset
73 |
74 | sensor:
75 | - platform: uptime
76 | name: "Uptime Sensor"
77 |
78 | - platform: wifi_signal
79 | name: "WiFi Signal"
80 | update_interval: 60s
81 |
82 | button:
83 | - platform: factory_reset
84 | name: "Reset"
85 | id: Reset
86 |
87 | - platform: safe_mode
88 | name: "Safe Mode"
89 | internal: false
90 |
91 | power_supply:
92 | - id: relay
93 | pin: GPIO12
94 |
95 | light:
96 | - platform: fastled_spi
97 | data_pin: GPIO1
98 | clock_pin: GPIO3
99 | id: leds
100 | name: "Light strip controller"
101 | power_supply: relay
102 | chipset: ${led_chipset}
103 | num_leds: ${number_of_leds}
104 | rgb_order: ${led_rgb_order}
105 | restore_mode: ${light_restore_mode}
106 | effects:
107 | - addressable_rainbow:
108 | - addressable_scan:
109 |
110 | text_sensor:
111 | - platform: wifi_info
112 | ip_address:
113 | name: "IP Address"
114 | ssid:
115 | name: "Connected SSID"
116 | mac_address:
117 | name: "Mac Address"
118 |
119 | time:
120 | - platform: sntp
121 | id: sntp_time
122 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Only applicable to ESP8285,[Please click for ESP32 devices](https://github.com/athom-tech/esp32-configs)
2 |
3 | ### Athom ESPHome configurations
4 |
5 | This repository contains a bunch of ESPHome configurations for https://athom.tech devices.
6 |
7 | If you are prompted that there is not enough space, you should upgrade `ESP8266_MINI.bin` first
8 |
9 | - mini is a transit firmware, after running, it will generate a hotspot of "ESP_UPDATE_XXXXXX"
10 | - Connect to the hotspot and visit `http://192.168.4.1/update` in the browser
11 | - Upload updated ESPHome firmware
12 |
13 | ### Migrating to Tasmota
14 |
15 | - Select firmware upgrade, upload `tasmota.bin.gz` and click Update, ***Please don't choose `tasmota.bin`***
16 | - Download Tasmota firmware here http://ota.tasmota.com/tasmota/release/tasmota.bin.gz
17 |
18 | ### Migrating from Tasmota
19 |
20 | - First execute `SetOption78 1` in the console of Tasmota
21 | - Select firmware upgrade, upload `tasmota-minimal.bin.gz` and click start upgrade
22 | - Select the firmware upgrade again, upload the firmware of ESPHome and click to start upgrade
23 |
24 | ### Device List
25 | device|picture|file name|notice
26 | :---:|:---:|:---:|:---:
27 | Athom_Plug_V2|





|athom-smart-plug-v2.yaml
28 | Athom_Wall_Outlet|
|athom-wall-outlet.yaml
29 | Athom_1Gang_Switch|

|athom-sw01.yaml
30 | Athom_2Gang_Switch|
|athom-sw02.yaml
31 | Athom_3Gang_Switch|
|athom-sw03.yaml
32 | Athom_4Gang_Switch|
|athom-sw04.yaml
33 | Athom_7W_Bulb
Athom_GU10_Bulb|
|athom-rgbww-light.yaml
34 | Athom_15W_Bulb|
|athom-rgbct-light.yaml
35 | Athom_12W_Bulb|
|athom-rgbct-light.yaml|
Temporarily discontinued
36 | Athom_RGB_Controller|
|athom-rgb-light.yaml
37 | Athom_Addressable_Light_Strip_Controller|
|athom-ws2812b.yaml
38 | Athom_High_Power_RGBW_Light_Strip_Controller|
|athom-rgbw-light.yaml
39 | Athom_High_Power_Addressable_Light_Strip_Controller|
|athom-ls-4p-3wire.yaml
40 | Athom_Mini_Switch|
|athom-mini-switch.yaml
41 | Athom_CB02_Switch|
|athom-cb02.yaml
42 | Athom_Presence_Sensor|
|athom-presence-sensor.yaml
43 | Athom_Garage_Door_Opener|
|athom-garage-door.yaml
44 | Athom_Plug|
|athom-smart-plug.yaml|Discontinued
45 |
--------------------------------------------------------------------------------
/athom-relay-board-x1.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | # Default name
3 | name: "athom-1ch-relay"
4 | # Default friendly name
5 | friendly_name: "Athom 1CH Relay"
6 | # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
7 | room: ""
8 | # Description as appears in ESPHome & top of webserver page
9 | device_description: "athom esp8266 1ch relay board"
10 | # Project Name
11 | project_name: "China Athom Technology.Athom 1CH Relay Board"
12 | # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
13 | project_version: "v1.0.4"
14 | # Restore the relay (GPO switch) upon reboot to state:
15 | relay_restore_mode: RESTORE_DEFAULT_OFF
16 | # Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
17 | dns_domain: ".local"
18 | # Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
19 | timezone: ""
20 | # Set the duration between the sntp service polling ntp.org servers for an update
21 | sntp_update_interval: 6h
22 | # Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
23 | sntp_server_1: "0.pool.ntp.org"
24 | sntp_server_2: "1.pool.ntp.org"
25 | sntp_server_3: "2.pool.ntp.org"
26 | # Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
27 | wifi_fast_connect: "false"
28 | # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
29 | log_level: "DEBUG"
30 | # Enable or disable the use of IPv6 networking on the device
31 | ipv6_enable: "false"
32 |
33 | esphome:
34 | name: "${name}"
35 | friendly_name: "${friendly_name}"
36 | comment: "${device_description}"
37 | area: "${room}"
38 | name_add_mac_suffix: true
39 | min_version: 2024.6.0
40 | project:
41 | name: "${project_name}"
42 | version: "${project_version}"
43 | platformio_options:
44 | board_upload.flash_size: 2MB
45 | board_upload.maximum_size: 2097152
46 | board_build.ldscript: eagle.flash.2m.ld
47 |
48 | esp8266:
49 | board: esp8285
50 | restore_from_flash: true
51 |
52 | preferences:
53 | flash_write_interval: 1min
54 |
55 | api:
56 |
57 | ota:
58 | - platform: esphome
59 |
60 | logger:
61 | level: ${log_level}
62 | baud_rate: 115200
63 |
64 | web_server:
65 | port: 80
66 |
67 | network:
68 | enable_ipv6: ${ipv6_enable}
69 |
70 | wifi:
71 | # This spawns an AP with the device name and mac address with no password.
72 | ap: {}
73 | # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
74 | fast_connect: "${wifi_fast_connect}"
75 | # Define dns domain / suffix to add to hostname
76 | domain: "${dns_domain}"
77 |
78 | mdns:
79 | disabled: false
80 |
81 | captive_portal:
82 |
83 | dashboard_import:
84 | package_import_url: github://athom-tech/athom-configs/athom-relay-board-x1.yaml
85 |
86 | binary_sensor:
87 | - platform: status
88 | name: "Status"
89 | entity_category: diagnostic
90 |
91 | sensor:
92 | - platform: uptime
93 | name: "Uptime Sensor"
94 | id: uptime_sensor
95 | entity_category: diagnostic
96 | internal: true
97 |
98 | - platform: wifi_signal
99 | name: "WiFi Signal dB"
100 | id: wifi_signal_db
101 | update_interval: 60s
102 | entity_category: "diagnostic"
103 |
104 | - platform: copy
105 | source_id: wifi_signal_db
106 | name: "WiFi Signal Percent"
107 | filters:
108 | - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
109 | unit_of_measurement: "Signal %"
110 | entity_category: "diagnostic"
111 | device_class: ""
112 |
113 | button:
114 | - platform: restart
115 | name: "Restart"
116 | entity_category: config
117 |
118 | - platform: factory_reset
119 | name: "Factory Reset"
120 | id: Reset
121 | entity_category: config
122 |
123 | - platform: safe_mode
124 | name: "Safe Mode"
125 | internal: false
126 | entity_category: config
127 |
128 | switch:
129 | # Relay
130 | - platform: gpio
131 | name: "Relay"
132 | pin: GPIO5
133 | id: relay1
134 | restore_mode: ${relay_restore_mode}
135 |
136 | light:
137 | - platform: status_led
138 | name: "Status LED"
139 | disabled_by_default: true
140 | pin:
141 | inverted: true
142 | number: GPIO16
143 |
144 | text_sensor:
145 | - platform: wifi_info
146 | ip_address:
147 | name: "IP Address"
148 | entity_category: diagnostic
149 | ssid:
150 | name: "Connected SSID"
151 | entity_category: diagnostic
152 | mac_address:
153 | name: "Mac Address"
154 | entity_category: diagnostic
155 |
156 | # Creates a sensor showing when the device was last restarted
157 | - platform: template
158 | name: 'Last Restart'
159 | id: device_last_restart
160 | icon: mdi:clock
161 | entity_category: diagnostic
162 | # device_class: timestamp
163 |
164 | # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
165 | - platform: template
166 | name: "Uptime"
167 | entity_category: diagnostic
168 | lambda: |-
169 | int seconds = (id(uptime_sensor).state);
170 | int days = seconds / (24 * 3600);
171 | seconds = seconds % (24 * 3600);
172 | int hours = seconds / 3600;
173 | seconds = seconds % 3600;
174 | int minutes = seconds / 60;
175 | seconds = seconds % 60;
176 | if ( days > 3650 ) {
177 | return { "Starting up" };
178 | } else if ( days ) {
179 | return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
180 | } else if ( hours ) {
181 | return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
182 | } else if ( minutes ) {
183 | return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
184 | } else {
185 | return { (String(seconds) +"s").c_str() };
186 | }
187 | icon: mdi:clock-start
188 |
189 | time:
190 | - platform: sntp
191 | id: sntp_time
192 | # Define the timezone of the device
193 | timezone: "${timezone}"
194 | # Change sync interval from default 5min to 6 hours (or as set in substitutions)
195 | update_interval: ${sntp_update_interval}
196 | # Set specific sntp servers to use
197 | servers:
198 | - "${sntp_server_1}"
199 | - "${sntp_server_2}"
200 | - "${sntp_server_3}"
201 | # Publish the time the device was last restarted
202 | on_time_sync:
203 | then:
204 | # Update last restart time, but only once.
205 | - if:
206 | condition:
207 | lambda: 'return id(device_last_restart).state == "";'
208 | then:
209 | - text_sensor.template.publish:
210 | id: device_last_restart
211 | state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
212 |
--------------------------------------------------------------------------------
/athom-relay-board-x2.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | # Default name
3 | name: "athom-2ch-relay"
4 | # Default friendly name
5 | friendly_name: "Athom 2CH Relay"
6 | # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
7 | room: ""
8 | # Description as appears in ESPHome & top of webserver page
9 | device_description: "athom esp8266 2ch relay board"
10 | # Project Name
11 | project_name: "China Athom Technology.Athom 2CH Relay Board"
12 | # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
13 | project_version: "v1.0.4"
14 | # Restore the relay (GPO switch) upon reboot to state:
15 | relay1_restore_mode: RESTORE_DEFAULT_OFF
16 | relay2_restore_mode: RESTORE_DEFAULT_OFF
17 | # Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
18 | dns_domain: ".local"
19 | # Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
20 | timezone: ""
21 | # Set the duration between the sntp service polling ntp.org servers for an update
22 | sntp_update_interval: 6h
23 | # Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
24 | sntp_server_1: "0.pool.ntp.org"
25 | sntp_server_2: "1.pool.ntp.org"
26 | sntp_server_3: "2.pool.ntp.org"
27 | # Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
28 | wifi_fast_connect: "false"
29 | # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
30 | log_level: "DEBUG"
31 | # Enable or disable the use of IPv6 networking on the device
32 | ipv6_enable: "false"
33 |
34 | esphome:
35 | name: "${name}"
36 | friendly_name: "${friendly_name}"
37 | comment: "${device_description}"
38 | area: "${room}"
39 | name_add_mac_suffix: true
40 | min_version: 2024.6.0
41 | project:
42 | name: "${project_name}"
43 | version: "${project_version}"
44 | platformio_options:
45 | board_upload.flash_size: 2MB
46 | board_upload.maximum_size: 2097152
47 | board_build.ldscript: eagle.flash.2m.ld
48 |
49 | esp8266:
50 | board: esp8285
51 | restore_from_flash: true
52 |
53 | preferences:
54 | flash_write_interval: 1min
55 |
56 | api:
57 |
58 | ota:
59 | - platform: esphome
60 |
61 | logger:
62 | level: ${log_level}
63 | baud_rate: 115200
64 |
65 | web_server:
66 | port: 80
67 |
68 | network:
69 | enable_ipv6: ${ipv6_enable}
70 |
71 | wifi:
72 | # This spawns an AP with the device name and mac address with no password.
73 | ap: {}
74 | # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
75 | fast_connect: "${wifi_fast_connect}"
76 | # Define dns domain / suffix to add to hostname
77 | domain: "${dns_domain}"
78 |
79 | mdns:
80 | disabled: false
81 |
82 | captive_portal:
83 |
84 | dashboard_import:
85 | package_import_url: github://athom-tech/athom-configs/athom-relay-board-x2.yaml
86 |
87 | binary_sensor:
88 | - platform: status
89 | name: "Status"
90 | entity_category: diagnostic
91 |
92 | sensor:
93 | - platform: uptime
94 | name: "Uptime Sensor"
95 | id: uptime_sensor
96 | entity_category: diagnostic
97 | internal: true
98 |
99 | - platform: wifi_signal
100 | name: "WiFi Signal dB"
101 | id: wifi_signal_db
102 | update_interval: 60s
103 | entity_category: "diagnostic"
104 |
105 | - platform: copy
106 | source_id: wifi_signal_db
107 | name: "WiFi Signal Percent"
108 | filters:
109 | - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
110 | unit_of_measurement: "Signal %"
111 | entity_category: "diagnostic"
112 | device_class: ""
113 |
114 | button:
115 | - platform: restart
116 | name: "Restart"
117 | entity_category: config
118 |
119 | - platform: factory_reset
120 | name: "Factory Reset"
121 | id: Reset
122 | entity_category: config
123 |
124 | - platform: safe_mode
125 | name: "Safe Mode"
126 | internal: false
127 | entity_category: config
128 |
129 | switch:
130 | # Relay
131 | - platform: gpio
132 | name: "Relay1"
133 | pin: GPIO5
134 | id: relay1
135 | restore_mode: ${relay1_restore_mode}
136 |
137 | - platform: gpio
138 | name: "Relay2"
139 | pin: GPIO4
140 | id: relay2
141 | restore_mode: ${relay2_restore_mode}
142 |
143 | light:
144 | - platform: status_led
145 | name: "Status LED"
146 | disabled_by_default: true
147 | pin:
148 | inverted: true
149 | number: GPIO16
150 |
151 | text_sensor:
152 | - platform: wifi_info
153 | ip_address:
154 | name: "IP Address"
155 | entity_category: diagnostic
156 | ssid:
157 | name: "Connected SSID"
158 | entity_category: diagnostic
159 | mac_address:
160 | name: "Mac Address"
161 | entity_category: diagnostic
162 |
163 | # Creates a sensor showing when the device was last restarted
164 | - platform: template
165 | name: 'Last Restart'
166 | id: device_last_restart
167 | icon: mdi:clock
168 | entity_category: diagnostic
169 | # device_class: timestamp
170 |
171 | # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
172 | - platform: template
173 | name: "Uptime"
174 | entity_category: diagnostic
175 | lambda: |-
176 | int seconds = (id(uptime_sensor).state);
177 | int days = seconds / (24 * 3600);
178 | seconds = seconds % (24 * 3600);
179 | int hours = seconds / 3600;
180 | seconds = seconds % 3600;
181 | int minutes = seconds / 60;
182 | seconds = seconds % 60;
183 | if ( days > 3650 ) {
184 | return { "Starting up" };
185 | } else if ( days ) {
186 | return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
187 | } else if ( hours ) {
188 | return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
189 | } else if ( minutes ) {
190 | return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
191 | } else {
192 | return { (String(seconds) +"s").c_str() };
193 | }
194 | icon: mdi:clock-start
195 |
196 | time:
197 | - platform: sntp
198 | id: sntp_time
199 | # Define the timezone of the device
200 | timezone: "${timezone}"
201 | # Change sync interval from default 5min to 6 hours (or as set in substitutions)
202 | update_interval: ${sntp_update_interval}
203 | # Set specific sntp servers to use
204 | servers:
205 | - "${sntp_server_1}"
206 | - "${sntp_server_2}"
207 | - "${sntp_server_3}"
208 | # Publish the time the device was last restarted
209 | on_time_sync:
210 | then:
211 | # Update last restart time, but only once.
212 | - if:
213 | condition:
214 | lambda: 'return id(device_last_restart).state == "";'
215 | then:
216 | - text_sensor.template.publish:
217 | id: device_last_restart
218 | state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
219 |
--------------------------------------------------------------------------------
/athom-relay-board-x4.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | # Default name
3 | name: "athom-4ch-relay"
4 | # Default friendly name
5 | friendly_name: "Athom 4CH Relay"
6 | # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
7 | room: ""
8 | # Description as appears in ESPHome & top of webserver page
9 | device_description: "athom esp8266 4ch relay board"
10 | # Project Name
11 | project_name: "China Athom Technology.Athom 4CH Relay Board"
12 | # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
13 | project_version: "v1.0.4"
14 | # Restore the relay (GPO switch) upon reboot to state:
15 | relay1_restore_mode: RESTORE_DEFAULT_OFF
16 | relay2_restore_mode: RESTORE_DEFAULT_OFF
17 | relay3_restore_mode: RESTORE_DEFAULT_OFF
18 | relay4_restore_mode: RESTORE_DEFAULT_OFF
19 | # Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
20 | dns_domain: ".local"
21 | # Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
22 | timezone: ""
23 | # Set the duration between the sntp service polling ntp.org servers for an update
24 | sntp_update_interval: 6h
25 | # Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
26 | sntp_server_1: "0.pool.ntp.org"
27 | sntp_server_2: "1.pool.ntp.org"
28 | sntp_server_3: "2.pool.ntp.org"
29 | # Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
30 | wifi_fast_connect: "false"
31 | # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
32 | log_level: "DEBUG"
33 | # Enable or disable the use of IPv6 networking on the device
34 | ipv6_enable: "false"
35 |
36 | esphome:
37 | name: "${name}"
38 | friendly_name: "${friendly_name}"
39 | comment: "${device_description}"
40 | area: "${room}"
41 | name_add_mac_suffix: true
42 | min_version: 2024.6.0
43 | project:
44 | name: "${project_name}"
45 | version: "${project_version}"
46 | platformio_options:
47 | board_upload.flash_size: 2MB
48 | board_upload.maximum_size: 2097152
49 | board_build.ldscript: eagle.flash.2m.ld
50 |
51 | esp8266:
52 | board: esp8285
53 | restore_from_flash: true
54 |
55 | preferences:
56 | flash_write_interval: 1min
57 |
58 | api:
59 |
60 | ota:
61 | - platform: esphome
62 |
63 | logger:
64 | level: ${log_level}
65 | baud_rate: 115200
66 |
67 | web_server:
68 | port: 80
69 |
70 | network:
71 | enable_ipv6: ${ipv6_enable}
72 |
73 | wifi:
74 | # This spawns an AP with the device name and mac address with no password.
75 | ap: {}
76 | # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
77 | fast_connect: "${wifi_fast_connect}"
78 | # Define dns domain / suffix to add to hostname
79 | domain: "${dns_domain}"
80 |
81 | mdns:
82 | disabled: false
83 |
84 | captive_portal:
85 |
86 | dashboard_import:
87 | package_import_url: github://athom-tech/athom-configs/athom-relay-board-x4.yaml
88 |
89 | binary_sensor:
90 | - platform: status
91 | name: "Status"
92 | entity_category: diagnostic
93 |
94 | sensor:
95 | - platform: uptime
96 | name: "Uptime Sensor"
97 | id: uptime_sensor
98 | entity_category: diagnostic
99 | internal: true
100 |
101 | - platform: wifi_signal
102 | name: "WiFi Signal dB"
103 | id: wifi_signal_db
104 | update_interval: 60s
105 | entity_category: "diagnostic"
106 |
107 | - platform: copy
108 | source_id: wifi_signal_db
109 | name: "WiFi Signal Percent"
110 | filters:
111 | - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
112 | unit_of_measurement: "Signal %"
113 | entity_category: "diagnostic"
114 | device_class: ""
115 |
116 | button:
117 | - platform: restart
118 | name: "Restart"
119 | entity_category: config
120 |
121 | - platform: factory_reset
122 | name: "Factory Reset"
123 | id: Reset
124 | entity_category: config
125 |
126 | - platform: safe_mode
127 | name: "Safe Mode"
128 | internal: false
129 | entity_category: config
130 |
131 | switch:
132 | - platform: gpio
133 | name: "Relay1"
134 | pin: GPIO16
135 | id: relay1
136 | restore_mode: ${relay1_restore_mode}
137 |
138 | - platform: gpio
139 | name: "Relay2"
140 | pin: GPIO14
141 | id: relay2
142 | restore_mode: ${relay2_restore_mode}
143 |
144 | - platform: gpio
145 | name: "Relay3"
146 | pin: GPIO12
147 | id: relay3
148 | restore_mode: ${relay3_restore_mode}
149 |
150 | - platform: gpio
151 | name: "Relay4"
152 | pin: GPIO13
153 | id: relay4
154 | restore_mode: ${relay4_restore_mode}
155 |
156 | light:
157 | - platform: status_led
158 | name: "Status LED"
159 | disabled_by_default: true
160 | pin:
161 | inverted: true
162 | number: GPIO5
163 |
164 | text_sensor:
165 | - platform: wifi_info
166 | ip_address:
167 | name: "IP Address"
168 | entity_category: diagnostic
169 | ssid:
170 | name: "Connected SSID"
171 | entity_category: diagnostic
172 | mac_address:
173 | name: "Mac Address"
174 | entity_category: diagnostic
175 |
176 | # Creates a sensor showing when the device was last restarted
177 | - platform: template
178 | name: 'Last Restart'
179 | id: device_last_restart
180 | icon: mdi:clock
181 | entity_category: diagnostic
182 | # device_class: timestamp
183 |
184 | # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
185 | - platform: template
186 | name: "Uptime"
187 | entity_category: diagnostic
188 | lambda: |-
189 | int seconds = (id(uptime_sensor).state);
190 | int days = seconds / (24 * 3600);
191 | seconds = seconds % (24 * 3600);
192 | int hours = seconds / 3600;
193 | seconds = seconds % 3600;
194 | int minutes = seconds / 60;
195 | seconds = seconds % 60;
196 | if ( days > 3650 ) {
197 | return { "Starting up" };
198 | } else if ( days ) {
199 | return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
200 | } else if ( hours ) {
201 | return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
202 | } else if ( minutes ) {
203 | return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
204 | } else {
205 | return { (String(seconds) +"s").c_str() };
206 | }
207 | icon: mdi:clock-start
208 |
209 | time:
210 | - platform: sntp
211 | id: sntp_time
212 | # Define the timezone of the device
213 | timezone: "${timezone}"
214 | # Change sync interval from default 5min to 6 hours (or as set in substitutions)
215 | update_interval: ${sntp_update_interval}
216 | # Set specific sntp servers to use
217 | servers:
218 | - "${sntp_server_1}"
219 | - "${sntp_server_2}"
220 | - "${sntp_server_3}"
221 | # Publish the time the device was last restarted
222 | on_time_sync:
223 | then:
224 | # Update last restart time, but only once.
225 | - if:
226 | condition:
227 | lambda: 'return id(device_last_restart).state == "";'
228 | then:
229 | - text_sensor.template.publish:
230 | id: device_last_restart
231 | state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
232 |
--------------------------------------------------------------------------------
/athom-rgb-light.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | # Default name
3 | name: "athom-rgb-light"
4 | # Default friendly name
5 | friendly_name: "Athom RGB Controller"
6 | # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
7 | room: ""
8 | # Description as appears in ESPHome & top of webserver page
9 | device_description: "athom rgb light strip controller"
10 | # Project Name
11 | project_name: "China Athom Technology.Athom RGB Controller"
12 | # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
13 | project_version: "v1.1.4"
14 | # Restore the light (GPO switch) upon reboot to state:
15 | light_restore_mode: RESTORE_DEFAULT_OFF
16 | # Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
17 | dns_domain: ".local"
18 | # Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
19 | timezone: ""
20 | # Set the duration between the sntp service polling ntp.org servers for an update
21 | sntp_update_interval: 6h
22 | # Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
23 | sntp_server_1: "0.pool.ntp.org"
24 | sntp_server_2: "1.pool.ntp.org"
25 | sntp_server_3: "2.pool.ntp.org"
26 | # Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
27 | wifi_fast_connect: "false"
28 | # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
29 | log_level: "DEBUG"
30 | # Enable or disable the use of IPv6 networking on the device
31 | ipv6_enable: "false"
32 |
33 | esphome:
34 | name: "${name}"
35 | friendly_name: "${friendly_name}"
36 | comment: "${device_description}"
37 | area: "${room}"
38 | name_add_mac_suffix: true
39 | min_version: 2024.6.0
40 | project:
41 | name: "${project_name}"
42 | version: "${project_version}"
43 | platformio_options:
44 | board_upload.flash_size: 2MB
45 | board_upload.maximum_size: 2097152
46 | board_build.ldscript: eagle.flash.2m.ld
47 |
48 | esp8266:
49 | board: esp8285
50 | restore_from_flash: true
51 |
52 | preferences:
53 | flash_write_interval: 1min
54 |
55 | api:
56 |
57 | ota:
58 | - platform: esphome
59 |
60 | logger:
61 | level: ${log_level}
62 | baud_rate: 115200
63 |
64 | web_server:
65 | port: 80
66 |
67 | network:
68 | enable_ipv6: ${ipv6_enable}
69 |
70 | wifi:
71 | # This spawns an AP with the device name and mac address with no password.
72 | ap: {}
73 | # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
74 | fast_connect: "${wifi_fast_connect}"
75 | # Define dns domain / suffix to add to hostname
76 | domain: "${dns_domain}"
77 |
78 | mdns:
79 | disabled: false
80 |
81 | captive_portal:
82 |
83 | dashboard_import:
84 | package_import_url: github://athom-tech/athom-configs/athom-rgb-light.yaml
85 |
86 | binary_sensor:
87 | - platform: status
88 | name: "Status"
89 | entity_category: diagnostic
90 |
91 | - platform: gpio
92 | pin:
93 | number: 0
94 | mode: INPUT_PULLUP
95 | inverted: true
96 | name: "Power Button"
97 | disabled_by_default: true
98 | on_multi_click:
99 | - timing:
100 | - ON for at most 1s
101 | - OFF for at least 0.2s
102 | then:
103 | - light.toggle: led
104 | - timing:
105 | - ON for at least 4s
106 | then:
107 | - button.press: Reset
108 |
109 | sensor:
110 | - platform: uptime
111 | name: "Uptime Sensor"
112 | id: uptime_sensor
113 | entity_category: diagnostic
114 | internal: true
115 |
116 | - platform: wifi_signal
117 | name: "WiFi Signal dB"
118 | id: wifi_signal_db
119 | update_interval: 60s
120 | entity_category: "diagnostic"
121 |
122 | - platform: copy
123 | source_id: wifi_signal_db
124 | name: "WiFi Signal Percent"
125 | filters:
126 | - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
127 | unit_of_measurement: "Signal %"
128 | entity_category: "diagnostic"
129 | device_class: ""
130 |
131 | button:
132 | - platform: restart
133 | name: "Restart"
134 | entity_category: config
135 |
136 | - platform: factory_reset
137 | name: "Factory Reset"
138 | id: Reset
139 | entity_category: config
140 |
141 | - platform: safe_mode
142 | name: "Safe Mode"
143 | internal: false
144 | entity_category: config
145 |
146 | output:
147 | - platform: esp8266_pwm
148 | id: red_output
149 | pin: GPIO12
150 | - platform: esp8266_pwm
151 | id: green_output
152 | pin: GPIO4
153 | - platform: esp8266_pwm
154 | id: blue_output
155 | pin: GPIO14
156 |
157 | light:
158 | - platform: rgb
159 | name: "RGB Light Strip"
160 | restore_mode: ${light_restore_mode}
161 | red: red_output
162 | green: green_output
163 | blue: blue_output
164 | id: led
165 |
166 | text_sensor:
167 | - platform: wifi_info
168 | ip_address:
169 | name: "IP Address"
170 | entity_category: diagnostic
171 | ssid:
172 | name: "Connected SSID"
173 | entity_category: diagnostic
174 | mac_address:
175 | name: "Mac Address"
176 | entity_category: diagnostic
177 |
178 | # Creates a sensor showing when the device was last restarted
179 | - platform: template
180 | name: 'Last Restart'
181 | id: device_last_restart
182 | icon: mdi:clock
183 | entity_category: diagnostic
184 | # device_class: timestamp
185 |
186 | # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
187 | - platform: template
188 | name: "Uptime"
189 | entity_category: diagnostic
190 | lambda: |-
191 | int seconds = (id(uptime_sensor).state);
192 | int days = seconds / (24 * 3600);
193 | seconds = seconds % (24 * 3600);
194 | int hours = seconds / 3600;
195 | seconds = seconds % 3600;
196 | int minutes = seconds / 60;
197 | seconds = seconds % 60;
198 | if ( days > 3650 ) {
199 | return { "Starting up" };
200 | } else if ( days ) {
201 | return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
202 | } else if ( hours ) {
203 | return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
204 | } else if ( minutes ) {
205 | return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
206 | } else {
207 | return { (String(seconds) +"s").c_str() };
208 | }
209 | icon: mdi:clock-start
210 |
211 | time:
212 | - platform: sntp
213 | id: sntp_time
214 | # Define the timezone of the device
215 | timezone: "${timezone}"
216 | # Change sync interval from default 5min to 6 hours (or as set in substitutions)
217 | update_interval: ${sntp_update_interval}
218 | # Set specific sntp servers to use
219 | servers:
220 | - "${sntp_server_1}"
221 | - "${sntp_server_2}"
222 | - "${sntp_server_3}"
223 | # Publish the time the device was last restarted
224 | on_time_sync:
225 | then:
226 | # Update last restart time, but only once.
227 | - if:
228 | condition:
229 | lambda: 'return id(device_last_restart).state == "";'
230 | then:
231 | - text_sensor.template.publish:
232 | id: device_last_restart
233 | state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
234 |
--------------------------------------------------------------------------------
/athom-rgbw-light.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | # Default name
3 | name: "athom-rgbw-light"
4 | # Default friendly name
5 | friendly_name: "Athom RGBW Light"
6 | # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
7 | room: ""
8 | # Description as appears in ESPHome & top of webserver page
9 | device_description: "athom rgbw light strip controller"
10 | # Project Name
11 | project_name: "China Athom Technology.RGBW Light Strip Controller"
12 | # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
13 | project_version: "v1.1.4"
14 | # Restore the light (GPO switch) upon reboot to state:
15 | light_restore_mode: RESTORE_DEFAULT_ON
16 | # Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
17 | dns_domain: ".local"
18 | # Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
19 | timezone: ""
20 | # Set the duration between the sntp service polling ntp.org servers for an update
21 | sntp_update_interval: 6h
22 | # Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
23 | sntp_server_1: "0.pool.ntp.org"
24 | sntp_server_2: "1.pool.ntp.org"
25 | sntp_server_3: "2.pool.ntp.org"
26 | # Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
27 | wifi_fast_connect: "false"
28 | # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
29 | log_level: "DEBUG"
30 | # Enable or disable the use of IPv6 networking on the device
31 | ipv6_enable: "false"
32 | color_interlock: "true"
33 |
34 | esphome:
35 | name: "${name}"
36 | friendly_name: "${friendly_name}"
37 | comment: "${device_description}"
38 | area: "${room}"
39 | name_add_mac_suffix: true
40 | min_version: 2024.6.0
41 | project:
42 | name: "${project_name}"
43 | version: "${project_version}"
44 | platformio_options:
45 | board_upload.flash_size: 2MB
46 | board_upload.maximum_size: 2097152
47 | board_build.ldscript: eagle.flash.2m.ld
48 |
49 | esp8266:
50 | board: esp8285
51 | restore_from_flash: true
52 |
53 | api:
54 |
55 | ota:
56 | - platform: esphome
57 |
58 | logger:
59 | level: ${log_level}
60 | baud_rate: 115200
61 |
62 | web_server:
63 | port: 80
64 |
65 | network:
66 | enable_ipv6: ${ipv6_enable}
67 |
68 | wifi:
69 | # This spawns an AP with the device name and mac address with no password.
70 | ap: {}
71 | # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
72 | fast_connect: "${wifi_fast_connect}"
73 | # Define dns domain / suffix to add to hostname
74 | domain: "${dns_domain}"
75 |
76 | mdns:
77 | disabled: false
78 |
79 | captive_portal:
80 |
81 | dashboard_import:
82 | package_import_url: github://athom-tech/athom-configs/athom-rgbw-light.yaml
83 |
84 | binary_sensor:
85 | - platform: status
86 | name: "Status"
87 | entity_category: diagnostic
88 |
89 | - platform: gpio
90 | pin:
91 | number: 0
92 | mode: INPUT_PULLUP
93 | inverted: true
94 | name: "Power Button"
95 | disabled_by_default: true
96 | on_multi_click:
97 | - timing:
98 | - ON for at most 1s
99 | - OFF for at least 0.2s
100 | then:
101 | - light.toggle: leds
102 | - timing:
103 | - ON for at least 4s
104 | then:
105 | - button.press: Reset
106 |
107 | sensor:
108 | - platform: uptime
109 | name: "Uptime Sensor"
110 | id: uptime_sensor
111 | entity_category: diagnostic
112 | internal: true
113 |
114 | - platform: wifi_signal
115 | name: "WiFi Signal dB"
116 | id: wifi_signal_db
117 | update_interval: 60s
118 | entity_category: "diagnostic"
119 |
120 | - platform: copy
121 | source_id: wifi_signal_db
122 | name: "WiFi Signal Percent"
123 | filters:
124 | - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
125 | unit_of_measurement: "Signal %"
126 | entity_category: "diagnostic"
127 | device_class: ""
128 |
129 | button:
130 | - platform: restart
131 | name: "Restart"
132 | entity_category: config
133 |
134 | - platform: factory_reset
135 | name: "Factory Reset"
136 | id: Reset
137 | entity_category: config
138 |
139 | - platform: safe_mode
140 | name: "Safe Mode"
141 | internal: false
142 | entity_category: config
143 |
144 | output:
145 | - platform: esp8266_pwm
146 | id: output_red
147 | pin: GPIO4
148 |
149 | - platform: esp8266_pwm
150 | id: output_green
151 | pin: GPIO12
152 |
153 | - platform: esp8266_pwm
154 | id: output_blue
155 | pin: GPIO14
156 |
157 | - platform: esp8266_pwm
158 | id: output_white
159 | pin: GPIO13
160 |
161 | light:
162 | - platform: rgbw
163 | name: "RGBW_Controller"
164 | id: leds
165 | red: output_red
166 | green: output_green
167 | blue: output_blue
168 | white: output_white
169 | color_interlock: ${color_interlock}
170 |
171 | text_sensor:
172 | - platform: wifi_info
173 | ip_address:
174 | name: "IP Address"
175 | entity_category: diagnostic
176 | ssid:
177 | name: "Connected SSID"
178 | entity_category: diagnostic
179 | mac_address:
180 | name: "Mac Address"
181 | entity_category: diagnostic
182 |
183 | # Creates a sensor showing when the device was last restarted
184 | - platform: template
185 | name: 'Last Restart'
186 | id: device_last_restart
187 | icon: mdi:clock
188 | entity_category: diagnostic
189 | # device_class: timestamp
190 |
191 | # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
192 | - platform: template
193 | name: "Uptime"
194 | entity_category: diagnostic
195 | lambda: |-
196 | int seconds = (id(uptime_sensor).state);
197 | int days = seconds / (24 * 3600);
198 | seconds = seconds % (24 * 3600);
199 | int hours = seconds / 3600;
200 | seconds = seconds % 3600;
201 | int minutes = seconds / 60;
202 | seconds = seconds % 60;
203 | if ( days > 3650 ) {
204 | return { "Starting up" };
205 | } else if ( days ) {
206 | return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
207 | } else if ( hours ) {
208 | return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
209 | } else if ( minutes ) {
210 | return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
211 | } else {
212 | return { (String(seconds) +"s").c_str() };
213 | }
214 | icon: mdi:clock-start
215 |
216 | time:
217 | - platform: sntp
218 | id: sntp_time
219 | # Define the timezone of the device
220 | timezone: "${timezone}"
221 | # Change sync interval from default 5min to 6 hours (or as set in substitutions)
222 | update_interval: ${sntp_update_interval}
223 | # Set specific sntp servers to use
224 | servers:
225 | - "${sntp_server_1}"
226 | - "${sntp_server_2}"
227 | - "${sntp_server_3}"
228 | # Publish the time the device was last restarted
229 | on_time_sync:
230 | then:
231 | # Update last restart time, but only once.
232 | - if:
233 | condition:
234 | lambda: 'return id(device_last_restart).state == "";'
235 | then:
236 | - text_sensor.template.publish:
237 | id: device_last_restart
238 | state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
239 |
--------------------------------------------------------------------------------
/athom-relay-board-x8.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | # Default name
3 | name: "athom-8ch-relay"
4 | # Default friendly name
5 | friendly_name: "Athom 8CH Relay"
6 | # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
7 | room: ""
8 | # Description as appears in ESPHome & top of webserver page
9 | device_description: "athom esp8266 8ch relay board"
10 | # Project Name
11 | project_name: "China Athom Technology.Athom 8CH Relay Board"
12 | # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
13 | project_version: "v1.0.4"
14 | # Restore the relay (GPO switch) upon reboot to state:
15 | relay1_restore_mode: RESTORE_DEFAULT_OFF
16 | relay2_restore_mode: RESTORE_DEFAULT_OFF
17 | relay3_restore_mode: RESTORE_DEFAULT_OFF
18 | relay4_restore_mode: RESTORE_DEFAULT_OFF
19 | relay5_restore_mode: RESTORE_DEFAULT_OFF
20 | relay6_restore_mode: RESTORE_DEFAULT_OFF
21 | relay7_restore_mode: RESTORE_DEFAULT_OFF
22 | relay8_restore_mode: RESTORE_DEFAULT_OFF
23 | # Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
24 | dns_domain: ".local"
25 | # Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
26 | timezone: ""
27 | # Set the duration between the sntp service polling ntp.org servers for an update
28 | sntp_update_interval: 6h
29 | # Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
30 | sntp_server_1: "0.pool.ntp.org"
31 | sntp_server_2: "1.pool.ntp.org"
32 | sntp_server_3: "2.pool.ntp.org"
33 | # Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
34 | wifi_fast_connect: "false"
35 | # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
36 | log_level: "DEBUG"
37 | # Enable or disable the use of IPv6 networking on the device
38 | ipv6_enable: "false"
39 |
40 | esphome:
41 | name: "${name}"
42 | friendly_name: "${friendly_name}"
43 | comment: "${device_description}"
44 | area: "${room}"
45 | name_add_mac_suffix: true
46 | min_version: 2024.6.0
47 | project:
48 | name: "${project_name}"
49 | version: "${project_version}"
50 | platformio_options:
51 | board_upload.flash_size: 2MB
52 | board_upload.maximum_size: 2097152
53 | board_build.ldscript: eagle.flash.2m.ld
54 |
55 | esp8266:
56 | board: esp8285
57 | restore_from_flash: true
58 |
59 | preferences:
60 | flash_write_interval: 1min
61 |
62 | api:
63 |
64 | ota:
65 | - platform: esphome
66 |
67 | logger:
68 | level: ${log_level}
69 | baud_rate: 115200
70 |
71 | web_server:
72 | port: 80
73 |
74 | network:
75 | enable_ipv6: ${ipv6_enable}
76 |
77 | wifi:
78 | # This spawns an AP with the device name and mac address with no password.
79 | ap: {}
80 | # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
81 | fast_connect: "${wifi_fast_connect}"
82 | # Define dns domain / suffix to add to hostname
83 | domain: "${dns_domain}"
84 |
85 | mdns:
86 | disabled: false
87 |
88 | captive_portal:
89 |
90 | dashboard_import:
91 | package_import_url: github://athom-tech/athom-configs/athom-relay-board-x8.yaml
92 |
93 | binary_sensor:
94 | - platform: status
95 | name: "Status"
96 | entity_category: diagnostic
97 |
98 | sensor:
99 | - platform: uptime
100 | name: "Uptime Sensor"
101 | id: uptime_sensor
102 | entity_category: diagnostic
103 | internal: true
104 |
105 | - platform: wifi_signal
106 | name: "WiFi Signal dB"
107 | id: wifi_signal_db
108 | update_interval: 60s
109 | entity_category: "diagnostic"
110 |
111 | - platform: copy
112 | source_id: wifi_signal_db
113 | name: "WiFi Signal Percent"
114 | filters:
115 | - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
116 | unit_of_measurement: "Signal %"
117 | entity_category: "diagnostic"
118 | device_class: ""
119 |
120 | button:
121 | - platform: restart
122 | name: "Restart"
123 | entity_category: config
124 |
125 | - platform: factory_reset
126 | name: "Factory Reset"
127 | id: Reset
128 | entity_category: config
129 |
130 | - platform: safe_mode
131 | name: "Safe Mode"
132 | internal: false
133 | entity_category: config
134 |
135 | switch:
136 | - platform: gpio
137 | name: "Relay1"
138 | pin: GPIO16
139 | id: relay1
140 | restore_mode: ${relay1_restore_mode}
141 |
142 | - platform: gpio
143 | name: "Relay2"
144 | pin: GPIO14
145 | id: relay2
146 | restore_mode: ${relay2_restore_mode}
147 |
148 | - platform: gpio
149 | name: "Relay3"
150 | pin: GPIO12
151 | id: relay3
152 | restore_mode: ${relay3_restore_mode}
153 |
154 | - platform: gpio
155 | name: "Relay4"
156 | pin: GPIO13
157 | id: relay4
158 | restore_mode: ${relay4_restore_mode}
159 |
160 | - platform: gpio
161 | name: "Relay5"
162 | pin: GPIO15
163 | id: relay5
164 | restore_mode: ${relay5_restore_mode}
165 |
166 | - platform: gpio
167 | name: "Relay6"
168 | pin: GPIO0
169 | id: relay6
170 | restore_mode: ${relay6_restore_mode}
171 |
172 | - platform: gpio
173 | name: "Relay7"
174 | pin: GPIO4
175 | id: relay7
176 | restore_mode: ${relay7_restore_mode}
177 |
178 | - platform: gpio
179 | name: "Relay8"
180 | pin: GPIO5
181 | id: relay8
182 | restore_mode: ${relay8_restore_mode}
183 |
184 | light:
185 | - platform: status_led
186 | name: "Status LED"
187 | disabled_by_default: true
188 | pin:
189 | inverted: true
190 | number: GPIO2
191 |
192 | text_sensor:
193 | - platform: wifi_info
194 | ip_address:
195 | name: "IP Address"
196 | entity_category: diagnostic
197 | ssid:
198 | name: "Connected SSID"
199 | entity_category: diagnostic
200 | mac_address:
201 | name: "Mac Address"
202 | entity_category: diagnostic
203 |
204 | # Creates a sensor showing when the device was last restarted
205 | - platform: template
206 | name: 'Last Restart'
207 | id: device_last_restart
208 | icon: mdi:clock
209 | entity_category: diagnostic
210 | # device_class: timestamp
211 |
212 | # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
213 | - platform: template
214 | name: "Uptime"
215 | entity_category: diagnostic
216 | lambda: |-
217 | int seconds = (id(uptime_sensor).state);
218 | int days = seconds / (24 * 3600);
219 | seconds = seconds % (24 * 3600);
220 | int hours = seconds / 3600;
221 | seconds = seconds % 3600;
222 | int minutes = seconds / 60;
223 | seconds = seconds % 60;
224 | if ( days > 3650 ) {
225 | return { "Starting up" };
226 | } else if ( days ) {
227 | return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
228 | } else if ( hours ) {
229 | return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
230 | } else if ( minutes ) {
231 | return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
232 | } else {
233 | return { (String(seconds) +"s").c_str() };
234 | }
235 | icon: mdi:clock-start
236 |
237 | time:
238 | - platform: sntp
239 | id: sntp_time
240 | # Define the timezone of the device
241 | timezone: "${timezone}"
242 | # Change sync interval from default 5min to 6 hours (or as set in substitutions)
243 | update_interval: ${sntp_update_interval}
244 | # Set specific sntp servers to use
245 | servers:
246 | - "${sntp_server_1}"
247 | - "${sntp_server_2}"
248 | - "${sntp_server_3}"
249 | # Publish the time the device was last restarted
250 | on_time_sync:
251 | then:
252 | # Update last restart time, but only once.
253 | - if:
254 | condition:
255 | lambda: 'return id(device_last_restart).state == "";'
256 | then:
257 | - text_sensor.template.publish:
258 | id: device_last_restart
259 | state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
260 |
--------------------------------------------------------------------------------
/athom-garage-door.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | # Default name
3 | name: "athom-garage-door"
4 | # Default friendly name
5 | friendly_name: "Athom Garage Door"
6 | # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
7 | room: ""
8 | # Description as appears in ESPHome & top of webserver page
9 | device_description: "athom garage door opener"
10 | # Project Name
11 | project_name: "China Athom Technology.Athom Garage Door Opener"
12 | # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
13 | project_version: "v1.2.4"
14 | # Status inverted
15 | status_inverted: "true"
16 | # Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
17 | dns_domain: ".local"
18 | # Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
19 | timezone: ""
20 | # Set the duration between the sntp service polling ntp.org servers for an update
21 | sntp_update_interval: 6h
22 | # Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
23 | sntp_server_1: "0.pool.ntp.org"
24 | sntp_server_2: "1.pool.ntp.org"
25 | sntp_server_3: "2.pool.ntp.org"
26 | # Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
27 | wifi_fast_connect: "false"
28 | # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
29 | log_level: "DEBUG"
30 | # Enable or disable the use of IPv6 networking on the device
31 | ipv6_enable: "false"
32 |
33 | esphome:
34 | name: "${name}"
35 | friendly_name: "${friendly_name}"
36 | comment: "${device_description}"
37 | area: "${room}"
38 | name_add_mac_suffix: true
39 | min_version: 2024.6.0
40 | platformio_options:
41 | board_upload.flash_size: 2MB
42 | board_upload.maximum_size: 2097152
43 | board_build.ldscript: eagle.flash.2m.ld
44 | project:
45 | name: "${project_name}"
46 | version: "${project_version}"
47 |
48 | esp8266:
49 | board: esp8285
50 |
51 | api:
52 |
53 | ota:
54 | - platform: esphome
55 |
56 | logger:
57 | level: ${log_level}
58 | baud_rate: 115200
59 |
60 | web_server:
61 | port: 80
62 |
63 | network:
64 | enable_ipv6: ${ipv6_enable}
65 |
66 | wifi:
67 | # This spawns an AP with the device name and mac address with no password.
68 | ap: {}
69 | # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
70 | fast_connect: "${wifi_fast_connect}"
71 | # Define dns domain / suffix to add to hostname
72 | domain: "${dns_domain}"
73 |
74 | mdns:
75 | disabled: false
76 |
77 | captive_portal:
78 |
79 | dashboard_import:
80 | package_import_url: github://athom-tech/athom-configs/athom-garage-door.yaml
81 |
82 | sensor:
83 | - platform: uptime
84 | name: "Uptime Sensor"
85 | id: uptime_sensor
86 | entity_category: diagnostic
87 | internal: true
88 |
89 | - platform: wifi_signal
90 | name: "WiFi Signal dB"
91 | id: wifi_signal_db
92 | update_interval: 60s
93 | entity_category: "diagnostic"
94 |
95 | - platform: copy
96 | source_id: wifi_signal_db
97 | name: "WiFi Signal Percent"
98 | filters:
99 | - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
100 | unit_of_measurement: "Signal %"
101 | entity_category: "diagnostic"
102 | device_class: ""
103 |
104 | binary_sensor:
105 | - platform: status
106 | name: "Status"
107 |
108 | - platform: gpio
109 | name: "Contact"
110 | disabled_by_default: true
111 | device_class: garage_door
112 | id: contact
113 | pin:
114 | number: GPIO4
115 | inverted: "${status_inverted}"
116 | filters:
117 | - delayed_on: 20ms
118 |
119 | - platform: gpio
120 | pin:
121 | number: GPIO14
122 | mode: INPUT_PULLUP
123 | inverted: true
124 | name: "Button"
125 | disabled_by_default: true
126 | on_multi_click:
127 | - timing:
128 | - ON for at most 1s
129 | - OFF for at least 0.2s
130 | then:
131 | - switch.turn_on: relay
132 | - timing:
133 | - ON for at least 4s
134 | then:
135 | - button.press: Reset
136 |
137 | button:
138 | - platform: restart
139 | name: "Restart"
140 | entity_category: config
141 |
142 | - platform: factory_reset
143 | name: "Factory Reset"
144 | id: Reset
145 | entity_category: config
146 |
147 | - platform: safe_mode
148 | name: "Safe Mode"
149 | internal: false
150 | entity_category: config
151 |
152 | switch:
153 | - platform: gpio
154 | pin: GPIO5
155 | name: "Relay"
156 | id: relay
157 | disabled_by_default: true
158 | on_turn_on:
159 | - light.turn_on: wifi_led
160 | - delay: 1s
161 | - switch.turn_off: relay
162 | - light.turn_off: wifi_led
163 |
164 | light:
165 | - platform: status_led
166 | name: "Status LED"
167 | id: wifi_led
168 | disabled_by_default: true
169 | pin:
170 | inverted: true
171 | number: GPIO12
172 |
173 | cover:
174 | - platform: template
175 | device_class: garage
176 | name: "Garage Door"
177 | lambda: "return id(contact).state ? COVER_OPEN : COVER_CLOSED;"
178 | open_action:
179 | then:
180 | - if:
181 | condition:
182 | lambda: 'return !id(contact).state;'
183 | then:
184 | - switch.turn_on: relay
185 | stop_action:
186 | - switch.turn_on: relay
187 | close_action:
188 | then:
189 | - if:
190 | condition:
191 | lambda: 'return id(contact).state;'
192 | then:
193 | - switch.turn_on: relay
194 |
195 | text_sensor:
196 | - platform: wifi_info
197 | ip_address:
198 | name: "IP Address"
199 | entity_category: diagnostic
200 | ssid:
201 | name: "Connected SSID"
202 | entity_category: diagnostic
203 | mac_address:
204 | name: "Mac Address"
205 | entity_category: diagnostic
206 |
207 | # Creates a sensor showing when the device was last restarted
208 | - platform: template
209 | name: 'Last Restart'
210 | id: device_last_restart
211 | icon: mdi:clock
212 | entity_category: diagnostic
213 | # device_class: timestamp
214 |
215 | # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
216 | - platform: template
217 | name: "Uptime"
218 | entity_category: diagnostic
219 | lambda: |-
220 | int seconds = (id(uptime_sensor).state);
221 | int days = seconds / (24 * 3600);
222 | seconds = seconds % (24 * 3600);
223 | int hours = seconds / 3600;
224 | seconds = seconds % 3600;
225 | int minutes = seconds / 60;
226 | seconds = seconds % 60;
227 | if ( days > 3650 ) {
228 | return { "Starting up" };
229 | } else if ( days ) {
230 | return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
231 | } else if ( hours ) {
232 | return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
233 | } else if ( minutes ) {
234 | return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
235 | } else {
236 | return { (String(seconds) +"s").c_str() };
237 | }
238 | icon: mdi:clock-start
239 |
240 | time:
241 | - platform: sntp
242 | id: sntp_time
243 | # Define the timezone of the device
244 | timezone: "${timezone}"
245 | # Change sync interval from default 5min to 6 hours (or as set in substitutions)
246 | update_interval: ${sntp_update_interval}
247 | # Set specific sntp servers to use
248 | servers:
249 | - "${sntp_server_1}"
250 | - "${sntp_server_2}"
251 | - "${sntp_server_3}"
252 | # Publish the time the device was last restarted
253 | on_time_sync:
254 | then:
255 | # Update last restart time, but only once.
256 | - if:
257 | condition:
258 | lambda: 'return id(device_last_restart).state == "";'
259 | then:
260 | - text_sensor.template.publish:
261 | id: device_last_restart
262 | state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
263 |
--------------------------------------------------------------------------------
/athom-cb02.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | # Default name
3 | name: "athom-cb02-switch"
4 | # Default friendly name
5 | friendly_name: "Athom Relay Switch"
6 | # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
7 | room: ""
8 | # Description as appears in ESPHome & top of webserver page
9 | device_description: "athom cb02 relay switch"
10 | # Project Name
11 | project_name: "China Athom Technology.CB02 Relay Switch"
12 | # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
13 | project_version: "v1.1.4"
14 | # Restore the relay (GPO switch) upon reboot to state:
15 | relay_restore_mode: RESTORE_DEFAULT_OFF
16 | # Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
17 | dns_domain: ".local"
18 | # Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
19 | timezone: ""
20 | # Set the duration between the sntp service polling ntp.org servers for an update
21 | sntp_update_interval: 6h
22 | # Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
23 | sntp_server_1: "0.pool.ntp.org"
24 | sntp_server_2: "1.pool.ntp.org"
25 | sntp_server_3: "2.pool.ntp.org"
26 | # Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
27 | wifi_fast_connect: "false"
28 | # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
29 | log_level: "DEBUG"
30 | # Enable or disable the use of IPv6 networking on the device
31 | ipv6_enable: "false"
32 |
33 | esphome:
34 | name: "${name}"
35 | friendly_name: "${friendly_name}"
36 | comment: "${device_description}"
37 | area: "${room}"
38 | name_add_mac_suffix: true
39 | min_version: 2024.6.0
40 | project:
41 | name: "${project_name}"
42 | version: "${project_version}"
43 | platformio_options:
44 | board_upload.flash_size: 2MB
45 | board_upload.maximum_size: 2097152
46 | board_build.ldscript: eagle.flash.2m.ld
47 | on_boot:
48 | - priority: 600
49 | then:
50 | - select.set_index:
51 | id: power_mode
52 | index: !lambda |-
53 | return id(restore_mode)-1;
54 | - lambda: |-
55 | switch(id(restore_mode))
56 | {
57 | case 1:{
58 | id(relay).turn_off();
59 | break;
60 | }
61 | case 2:{
62 | id(relay).turn_on();
63 | break;
64 | }
65 | default:{
66 | break;
67 | }
68 | }
69 |
70 | esp8266:
71 | board: esp8285
72 | restore_from_flash: true
73 |
74 | preferences:
75 | flash_write_interval: 1min
76 |
77 | api:
78 |
79 | ota:
80 | - platform: esphome
81 |
82 | logger:
83 | level: ${log_level}
84 | baud_rate: 115200
85 |
86 | web_server:
87 | port: 80
88 |
89 | network:
90 | enable_ipv6: ${ipv6_enable}
91 |
92 | wifi:
93 | # This spawns an AP with the device name and mac address with no password.
94 | ap: {}
95 | # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
96 | fast_connect: "${wifi_fast_connect}"
97 | # Define dns domain / suffix to add to hostname
98 | domain: "${dns_domain}"
99 |
100 | mdns:
101 | disabled: false
102 |
103 | captive_portal:
104 |
105 | dashboard_import:
106 | package_import_url: github://athom-tech/athom-configs/athom-cb02.yaml
107 |
108 | globals:
109 | - id: restore_mode
110 | type: int
111 | restore_value: yes
112 | initial_value: "3"
113 |
114 | select:
115 | - platform: template
116 | name: "Power On State"
117 | id: "power_mode"
118 | optimistic: true
119 | options:
120 | - Always Off
121 | - Always On
122 | - Restore Power Off State
123 | on_value:
124 | then:
125 | - lambda: |-
126 | id(restore_mode)=i+1;
127 |
128 | binary_sensor:
129 | - platform: status
130 | name: "Status"
131 | entity_category: diagnostic
132 |
133 | - platform: gpio
134 | pin:
135 | number: GPIO3
136 | mode: INPUT_PULLUP
137 | inverted: true
138 | name: "Power Button"
139 | disabled_by_default: true
140 | on_multi_click:
141 | - timing:
142 | - ON for at most 1s
143 | - OFF for at least 0.2s
144 | then:
145 | - switch.toggle: relay
146 | - timing:
147 | - ON for at least 4s
148 | then:
149 | - button.press: Reset
150 |
151 | sensor:
152 | - platform: uptime
153 | name: "Uptime Sensor"
154 | id: uptime_sensor
155 | entity_category: diagnostic
156 | internal: true
157 |
158 | - platform: wifi_signal
159 | name: "WiFi Signal dB"
160 | id: wifi_signal_db
161 | update_interval: 60s
162 | entity_category: "diagnostic"
163 |
164 | - platform: copy
165 | source_id: wifi_signal_db
166 | name: "WiFi Signal Percent"
167 | filters:
168 | - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
169 | unit_of_measurement: "Signal %"
170 | entity_category: "diagnostic"
171 | device_class: ""
172 |
173 | button:
174 | - platform: restart
175 | name: "Restart"
176 | entity_category: config
177 |
178 | - platform: factory_reset
179 | name: "Factory Reset"
180 | id: Reset
181 | entity_category: config
182 |
183 | - platform: safe_mode
184 | name: "Safe Mode"
185 | internal: false
186 | entity_category: config
187 |
188 | switch:
189 | - platform: gpio
190 | name: "Relay"
191 | pin: GPIO13
192 | id: relay
193 | restore_mode: ${relay_restore_mode}
194 | on_turn_on:
195 | - light.turn_on: blue_led
196 | on_turn_off:
197 | - light.turn_off: blue_led
198 |
199 | light:
200 | - platform: status_led
201 | name: "Status LED"
202 | id: blue_led
203 | disabled_by_default: true
204 | pin:
205 | inverted: true
206 | number: GPIO4
207 |
208 | text_sensor:
209 | - platform: wifi_info
210 | ip_address:
211 | name: "IP Address"
212 | entity_category: diagnostic
213 | ssid:
214 | name: "Connected SSID"
215 | entity_category: diagnostic
216 | mac_address:
217 | name: "Mac Address"
218 | entity_category: diagnostic
219 |
220 | # Creates a sensor showing when the device was last restarted
221 | - platform: template
222 | name: 'Last Restart'
223 | id: device_last_restart
224 | icon: mdi:clock
225 | entity_category: diagnostic
226 | # device_class: timestamp
227 |
228 | # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
229 | - platform: template
230 | name: "Uptime"
231 | entity_category: diagnostic
232 | lambda: |-
233 | int seconds = (id(uptime_sensor).state);
234 | int days = seconds / (24 * 3600);
235 | seconds = seconds % (24 * 3600);
236 | int hours = seconds / 3600;
237 | seconds = seconds % 3600;
238 | int minutes = seconds / 60;
239 | seconds = seconds % 60;
240 | if ( days > 3650 ) {
241 | return { "Starting up" };
242 | } else if ( days ) {
243 | return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
244 | } else if ( hours ) {
245 | return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
246 | } else if ( minutes ) {
247 | return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
248 | } else {
249 | return { (String(seconds) +"s").c_str() };
250 | }
251 | icon: mdi:clock-start
252 |
253 | time:
254 | - platform: sntp
255 | id: sntp_time
256 | # Define the timezone of the device
257 | timezone: "${timezone}"
258 | # Change sync interval from default 5min to 6 hours (or as set in substitutions)
259 | update_interval: ${sntp_update_interval}
260 | # Set specific sntp servers to use
261 | servers:
262 | - "${sntp_server_1}"
263 | - "${sntp_server_2}"
264 | - "${sntp_server_3}"
265 | # Publish the time the device was last restarted
266 | on_time_sync:
267 | then:
268 | # Update last restart time, but only once.
269 | - if:
270 | condition:
271 | lambda: 'return id(device_last_restart).state == "";'
272 | then:
273 | - text_sensor.template.publish:
274 | id: device_last_restart
275 | state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
276 |
--------------------------------------------------------------------------------
/athom-sw01.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | # Default name
3 | name: "athom-1gang-switch"
4 | # Default friendly name
5 | friendly_name: "1Gang Switch"
6 | # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
7 | room: ""
8 | # Description as appears in ESPHome & top of webserver page
9 | device_description: "athom 1gang switch"
10 | # Project Name
11 | project_name: "China Athom Technology.1Gang Switch"
12 | # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
13 | project_version: "v1.1.4"
14 | # Restore the relay (GPO switch) upon reboot to state:
15 | light_restore_mode: RESTORE_DEFAULT_OFF
16 | # Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
17 | dns_domain: ".local"
18 | # Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
19 | timezone: ""
20 | # Set the duration between the sntp service polling ntp.org servers for an update
21 | sntp_update_interval: 6h
22 | # Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
23 | sntp_server_1: "0.pool.ntp.org"
24 | sntp_server_2: "1.pool.ntp.org"
25 | sntp_server_3: "2.pool.ntp.org"
26 | # Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
27 | wifi_fast_connect: "false"
28 | # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
29 | log_level: "DEBUG"
30 | # Enable or disable the use of IPv6 networking on the device
31 | ipv6_enable: "false"
32 |
33 | esphome:
34 | name: "${name}"
35 | friendly_name: "${friendly_name}"
36 | comment: "${device_description}"
37 | area: "${room}"
38 | name_add_mac_suffix: true
39 | min_version: 2024.6.0
40 | project:
41 | name: "${project_name}"
42 | version: "${project_version}"
43 | platformio_options:
44 | board_upload.flash_size: 2MB
45 | board_upload.maximum_size: 2097152
46 | board_build.ldscript: eagle.flash.2m.ld
47 | on_boot:
48 | - priority: 600
49 | then:
50 | - select.set_index:
51 | id: power_mode
52 | index: !lambda |-
53 | return id(restore_mode)-1;
54 | - lambda: |-
55 | switch(id(restore_mode))
56 | {
57 | case 1:{
58 | id(light1).turn_off();
59 | break;
60 | }
61 | case 2:{
62 | id(light1).turn_on();
63 | break;
64 | }
65 | default:{
66 | break;
67 | }
68 | }
69 |
70 | esp8266:
71 | board: esp8285
72 | restore_from_flash: true
73 |
74 | preferences:
75 | flash_write_interval: 1min
76 |
77 | api:
78 |
79 | ota:
80 | - platform: esphome
81 |
82 | logger:
83 | level: ${log_level}
84 | baud_rate: 115200
85 |
86 | web_server:
87 | port: 80
88 |
89 | network:
90 | enable_ipv6: ${ipv6_enable}
91 |
92 | wifi:
93 | # This spawns an AP with the device name and mac address with no password.
94 | ap: {}
95 | # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
96 | fast_connect: "${wifi_fast_connect}"
97 | # Define dns domain / suffix to add to hostname
98 | domain: "${dns_domain}"
99 |
100 | mdns:
101 | disabled: false
102 |
103 | captive_portal:
104 |
105 | dashboard_import:
106 | package_import_url: github://athom-tech/athom-configs/athom-sw01.yaml
107 |
108 | globals:
109 | - id: restore_mode
110 | type: int
111 | restore_value: yes
112 | initial_value: "3"
113 |
114 | select:
115 | - platform: template
116 | name: "Power On State"
117 | id: "power_mode"
118 | optimistic: true
119 | options:
120 | - Always Off
121 | - Always On
122 | - Restore Power Off State
123 | on_value:
124 | then:
125 | - lambda: |-
126 | id(restore_mode)=i+1;
127 |
128 | binary_sensor:
129 | - platform: status
130 | name: "Status"
131 | entity_category: diagnostic
132 |
133 | # Touch Button
134 | - platform: gpio
135 | pin:
136 | inverted: true
137 | number: GPIO3
138 | mode:
139 | input: true
140 | pullup: true
141 | name: "Button"
142 | id: button1
143 | disabled_by_default: true
144 | on_multi_click:
145 | - timing:
146 | - ON for at most 0.5s
147 | - OFF for at least 0.2s
148 | then:
149 | - light.toggle: light1
150 | - timing:
151 | - ON for at least 4s
152 | then:
153 | - button.press: Reset
154 |
155 | sensor:
156 | - platform: uptime
157 | name: "Uptime Sensor"
158 | id: uptime_sensor
159 | entity_category: diagnostic
160 | internal: true
161 |
162 | - platform: wifi_signal
163 | name: "WiFi Signal dB"
164 | id: wifi_signal_db
165 | update_interval: 60s
166 | entity_category: "diagnostic"
167 |
168 | - platform: copy
169 | source_id: wifi_signal_db
170 | name: "WiFi Signal Percent"
171 | filters:
172 | - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
173 | unit_of_measurement: "Signal %"
174 | entity_category: "diagnostic"
175 | device_class: ""
176 |
177 | button:
178 | - platform: restart
179 | name: "Restart"
180 | entity_category: config
181 |
182 | - platform: factory_reset
183 | name: "Factory Reset"
184 | id: Reset
185 | entity_category: config
186 |
187 | - platform: safe_mode
188 | name: "Safe Mode"
189 | internal: false
190 | entity_category: config
191 |
192 | output:
193 | # Relay
194 | - platform: gpio
195 | pin: GPIO13
196 | id: relay1
197 |
198 | # Button LED (1.0 = Blue / 0.0 = Red)
199 | - platform: esp8266_pwm
200 | pin: GPIO14
201 | inverted: true
202 | id: button_led1
203 |
204 | light:
205 | - platform: status_led
206 | name: "Status LED"
207 | disabled_by_default: true
208 | pin:
209 | number: GPIO0
210 | inverted: true
211 |
212 | # Relay
213 | - platform: binary
214 | name: "Light"
215 | id: light1
216 | output: relay1
217 | restore_mode: ${light_restore_mode}
218 | on_turn_on:
219 | - light.turn_on: led1
220 | on_turn_off:
221 | - light.turn_off: led1
222 |
223 | # Button LED
224 | - platform: monochromatic
225 | name: "LED"
226 | disabled_by_default: true
227 | id: led1
228 | output: button_led1
229 | default_transition_length: 500ms
230 |
231 | text_sensor:
232 | - platform: wifi_info
233 | ip_address:
234 | name: "IP Address"
235 | entity_category: diagnostic
236 | ssid:
237 | name: "Connected SSID"
238 | entity_category: diagnostic
239 | mac_address:
240 | name: "Mac Address"
241 | entity_category: diagnostic
242 |
243 | # Creates a sensor showing when the device was last restarted
244 | - platform: template
245 | name: 'Last Restart'
246 | id: device_last_restart
247 | icon: mdi:clock
248 | entity_category: diagnostic
249 | # device_class: timestamp
250 |
251 | # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
252 | - platform: template
253 | name: "Uptime"
254 | entity_category: diagnostic
255 | lambda: |-
256 | int seconds = (id(uptime_sensor).state);
257 | int days = seconds / (24 * 3600);
258 | seconds = seconds % (24 * 3600);
259 | int hours = seconds / 3600;
260 | seconds = seconds % 3600;
261 | int minutes = seconds / 60;
262 | seconds = seconds % 60;
263 | if ( days > 3650 ) {
264 | return { "Starting up" };
265 | } else if ( days ) {
266 | return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
267 | } else if ( hours ) {
268 | return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
269 | } else if ( minutes ) {
270 | return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
271 | } else {
272 | return { (String(seconds) +"s").c_str() };
273 | }
274 | icon: mdi:clock-start
275 |
276 | time:
277 | - platform: sntp
278 | id: sntp_time
279 | # Define the timezone of the device
280 | timezone: "${timezone}"
281 | # Change sync interval from default 5min to 6 hours (or as set in substitutions)
282 | update_interval: ${sntp_update_interval}
283 | # Set specific sntp servers to use
284 | servers:
285 | - "${sntp_server_1}"
286 | - "${sntp_server_2}"
287 | - "${sntp_server_3}"
288 | # Publish the time the device was last restarted
289 | on_time_sync:
290 | then:
291 | # Update last restart time, but only once.
292 | - if:
293 | condition:
294 | lambda: 'return id(device_last_restart).state == "";'
295 | then:
296 | - text_sensor.template.publish:
297 | id: device_last_restart
298 | state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
299 |
--------------------------------------------------------------------------------
/athom-sw01-v2.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | # Default name
3 | name: "athom-1gang-switch-v2"
4 | # Default friendly name
5 | friendly_name: "1Gang Switch"
6 | # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
7 | room: ""
8 | # Description as appears in ESPHome & top of webserver page
9 | device_description: "athom 1gang switch v2"
10 | # Project Name
11 | project_name: "China Athom Technology.1Gang Switch V2"
12 | # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
13 | project_version: "v1.1.4"
14 | # Restore the relay (GPO switch) upon reboot to state:
15 | light_restore_mode: RESTORE_DEFAULT_OFF
16 | # Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
17 | dns_domain: ".local"
18 | # Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
19 | timezone: ""
20 | # Set the duration between the sntp service polling ntp.org servers for an update
21 | sntp_update_interval: 6h
22 | # Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
23 | sntp_server_1: "0.pool.ntp.org"
24 | sntp_server_2: "1.pool.ntp.org"
25 | sntp_server_3: "2.pool.ntp.org"
26 | # Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
27 | wifi_fast_connect: "false"
28 | # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
29 | log_level: "DEBUG"
30 | # Enable or disable the use of IPv6 networking on the device
31 | ipv6_enable: "false"
32 |
33 | esphome:
34 | name: "${name}"
35 | friendly_name: "${friendly_name}"
36 | comment: "${device_description}"
37 | area: "${room}"
38 | name_add_mac_suffix: true
39 | min_version: 2024.6.0
40 | project:
41 | name: "${project_name}"
42 | version: "${project_version}"
43 | platformio_options:
44 | board_upload.flash_size: 2MB
45 | board_upload.maximum_size: 2097152
46 | board_build.ldscript: eagle.flash.2m.ld
47 | on_boot:
48 | - priority: 600
49 | then:
50 | - select.set_index:
51 | id: power_mode
52 | index: !lambda |-
53 | return id(restore_mode)-1;
54 | - lambda: |-
55 | switch(id(restore_mode))
56 | {
57 | case 1:{
58 | id(light1).turn_off();
59 | break;
60 | }
61 | case 2:{
62 | id(light1).turn_on();
63 | break;
64 | }
65 | default:{
66 | break;
67 | }
68 | }
69 |
70 | esp8266:
71 | board: esp8285
72 | restore_from_flash: true
73 |
74 | preferences:
75 | flash_write_interval: 1min
76 |
77 | api:
78 |
79 | ota:
80 | - platform: esphome
81 |
82 | logger:
83 | level: ${log_level}
84 | baud_rate: 115200
85 |
86 | web_server:
87 | port: 80
88 |
89 | network:
90 | enable_ipv6: ${ipv6_enable}
91 |
92 | wifi:
93 | # This spawns an AP with the device name and mac address with no password.
94 | ap: {}
95 | # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
96 | fast_connect: "${wifi_fast_connect}"
97 | # Define dns domain / suffix to add to hostname
98 | domain: "${dns_domain}"
99 |
100 | mdns:
101 | disabled: false
102 |
103 | captive_portal:
104 |
105 | dashboard_import:
106 | package_import_url: github://athom-tech/athom-configs/athom-sw01-v2.yaml
107 |
108 | globals:
109 | - id: restore_mode
110 | type: int
111 | restore_value: yes
112 | initial_value: "3"
113 |
114 | select:
115 | - platform: template
116 | name: "Power On State"
117 | id: "power_mode"
118 | optimistic: true
119 | options:
120 | - Always Off
121 | - Always On
122 | - Restore Power Off State
123 | on_value:
124 | then:
125 | - lambda: |-
126 | id(restore_mode)=i+1;
127 |
128 | binary_sensor:
129 | - platform: status
130 | name: "Status"
131 | entity_category: diagnostic
132 |
133 | # Touch Button
134 | - platform: gpio
135 | pin:
136 | inverted: true
137 | number: GPIO3
138 | mode:
139 | input: true
140 | pullup: true
141 | name: "Button"
142 | id: button1
143 | disabled_by_default: true
144 | on_multi_click:
145 | - timing:
146 | - ON for at most 0.5s
147 | - OFF for at least 0.2s
148 | then:
149 | - light.toggle: light1
150 | - timing:
151 | - ON for at least 4s
152 | then:
153 | - button.press: Reset
154 |
155 | sensor:
156 | - platform: uptime
157 | name: "Uptime Sensor"
158 | id: uptime_sensor
159 | entity_category: diagnostic
160 | internal: true
161 |
162 | - platform: wifi_signal
163 | name: "WiFi Signal dB"
164 | id: wifi_signal_db
165 | update_interval: 60s
166 | entity_category: "diagnostic"
167 |
168 | - platform: copy
169 | source_id: wifi_signal_db
170 | name: "WiFi Signal Percent"
171 | filters:
172 | - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
173 | unit_of_measurement: "Signal %"
174 | entity_category: "diagnostic"
175 | device_class: ""
176 |
177 | button:
178 | - platform: restart
179 | name: "Restart"
180 | entity_category: config
181 |
182 | - platform: factory_reset
183 | name: "Factory Reset"
184 | id: Reset
185 | entity_category: config
186 |
187 | - platform: safe_mode
188 | name: "Safe Mode"
189 | internal: false
190 | entity_category: config
191 |
192 | output:
193 | # Relay
194 | - platform: gpio
195 | pin: GPIO13
196 | id: relay1
197 |
198 | # Button LED (1.0 = Blue / 0.0 = Red)
199 | - platform: esp8266_pwm
200 | pin: GPIO16
201 | inverted: true
202 | id: button_led1
203 |
204 | light:
205 | - platform: status_led
206 | name: "Status LED"
207 | disabled_by_default: true
208 | pin:
209 | number: GPIO0
210 | inverted: true
211 |
212 | # Relay
213 | - platform: binary
214 | name: "Light"
215 | id: light1
216 | output: relay1
217 | restore_mode: ${light_restore_mode}
218 | on_turn_on:
219 | - light.turn_on: led1
220 | on_turn_off:
221 | - light.turn_off: led1
222 |
223 | # Button LED
224 | - platform: monochromatic
225 | name: "LED"
226 | disabled_by_default: true
227 | id: led1
228 | output: button_led1
229 | default_transition_length: 500ms
230 |
231 | text_sensor:
232 | - platform: wifi_info
233 | ip_address:
234 | name: "IP Address"
235 | entity_category: diagnostic
236 | ssid:
237 | name: "Connected SSID"
238 | entity_category: diagnostic
239 | mac_address:
240 | name: "Mac Address"
241 | entity_category: diagnostic
242 |
243 | # Creates a sensor showing when the device was last restarted
244 | - platform: template
245 | name: 'Last Restart'
246 | id: device_last_restart
247 | icon: mdi:clock
248 | entity_category: diagnostic
249 | # device_class: timestamp
250 |
251 | # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
252 | - platform: template
253 | name: "Uptime"
254 | entity_category: diagnostic
255 | lambda: |-
256 | int seconds = (id(uptime_sensor).state);
257 | int days = seconds / (24 * 3600);
258 | seconds = seconds % (24 * 3600);
259 | int hours = seconds / 3600;
260 | seconds = seconds % 3600;
261 | int minutes = seconds / 60;
262 | seconds = seconds % 60;
263 | if ( days > 3650 ) {
264 | return { "Starting up" };
265 | } else if ( days ) {
266 | return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
267 | } else if ( hours ) {
268 | return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
269 | } else if ( minutes ) {
270 | return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
271 | } else {
272 | return { (String(seconds) +"s").c_str() };
273 | }
274 | icon: mdi:clock-start
275 |
276 | time:
277 | - platform: sntp
278 | id: sntp_time
279 | # Define the timezone of the device
280 | timezone: "${timezone}"
281 | # Change sync interval from default 5min to 6 hours (or as set in substitutions)
282 | update_interval: ${sntp_update_interval}
283 | # Set specific sntp servers to use
284 | servers:
285 | - "${sntp_server_1}"
286 | - "${sntp_server_2}"
287 | - "${sntp_server_3}"
288 | # Publish the time the device was last restarted
289 | on_time_sync:
290 | then:
291 | # Update last restart time, but only once.
292 | - if:
293 | condition:
294 | lambda: 'return id(device_last_restart).state == "";'
295 | then:
296 | - text_sensor.template.publish:
297 | id: device_last_restart
298 | state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
299 |
--------------------------------------------------------------------------------
/athom-mini-switch.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | # Default name
3 | name: "athom-mini-switch"
4 | # Default friendly name
5 | friendly_name: "Athom Relay Switch"
6 | # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
7 | room: ""
8 | # Description as appears in ESPHome & top of webserver page
9 | device_description: "athom mini relay switch module"
10 | # Project Name
11 | project_name: "China Athom Technology.Mini Relay Switch"
12 | # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
13 | project_version: "v1.1.4"
14 | # Restore the relay (GPO switch) upon reboot to state:
15 | light_restore_mode: RESTORE_DEFAULT_OFF
16 | # Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
17 | dns_domain: ".local"
18 | # Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
19 | timezone: ""
20 | # Set the duration between the sntp service polling ntp.org servers for an update
21 | sntp_update_interval: 6h
22 | # Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
23 | sntp_server_1: "0.pool.ntp.org"
24 | sntp_server_2: "1.pool.ntp.org"
25 | sntp_server_3: "2.pool.ntp.org"
26 | # Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
27 | wifi_fast_connect: "false"
28 | # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
29 | log_level: "DEBUG"
30 | # Enable or disable the use of IPv6 networking on the device
31 | ipv6_enable: "false"
32 |
33 | esphome:
34 | name: "${name}"
35 | friendly_name: "${friendly_name}"
36 | comment: "${device_description}"
37 | area: "${room}"
38 | name_add_mac_suffix: true
39 | min_version: 2024.6.0
40 | project:
41 | name: "${project_name}"
42 | version: "${project_version}"
43 | platformio_options:
44 | board_upload.flash_size: 2MB
45 | board_upload.maximum_size: 2097152
46 | board_build.ldscript: eagle.flash.2m.ld
47 | on_boot:
48 | - priority: 600
49 | then:
50 | - select.set_index:
51 | id: power_mode
52 | index: !lambda |-
53 | return id(restore_mode)-1;
54 | - lambda: |-
55 | switch(id(restore_mode))
56 | {
57 | case 1:{
58 | id(mini_relay).turn_off();
59 | break;
60 | }
61 | case 2:{
62 | id(mini_relay).turn_on();
63 | break;
64 | }
65 | default:{
66 | break;
67 | }
68 | }
69 |
70 | esp8266:
71 | board: esp8285
72 | restore_from_flash: true
73 |
74 | preferences:
75 | flash_write_interval: 1min
76 |
77 | api:
78 |
79 | ota:
80 | - platform: esphome
81 |
82 | logger:
83 | level: ${log_level}
84 | baud_rate: 115200
85 |
86 | web_server:
87 | port: 80
88 |
89 | network:
90 | enable_ipv6: ${ipv6_enable}
91 |
92 | wifi:
93 | # This spawns an AP with the device name and mac address with no password.
94 | ap: {}
95 | # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
96 | fast_connect: "${wifi_fast_connect}"
97 | # Define dns domain / suffix to add to hostname
98 | domain: "${dns_domain}"
99 |
100 | mdns:
101 | disabled: false
102 |
103 | captive_portal:
104 |
105 | dashboard_import:
106 | package_import_url: github://athom-tech/athom-configs/athom-mini-switch.yaml
107 |
108 | globals:
109 | - id: restore_mode
110 | type: int
111 | restore_value: yes
112 | initial_value: "3"
113 |
114 | select:
115 | - platform: template
116 | name: "Power On State"
117 | id: "power_mode"
118 | optimistic: true
119 | options:
120 | - Always Off
121 | - Always On
122 | - Restore Power Off State
123 | on_value:
124 | then:
125 | - lambda: |-
126 | id(restore_mode)=i+1;
127 |
128 | button:
129 | - platform: restart
130 | name: "Restart"
131 | entity_category: config
132 |
133 | - platform: factory_reset
134 | name: "Factory Reset"
135 | id: Reset
136 | entity_category: config
137 |
138 | - platform: safe_mode
139 | name: "Safe Mode"
140 | internal: false
141 | entity_category: config
142 |
143 | output:
144 | - platform: gpio
145 | id: relay_output
146 | pin: GPIO13
147 |
148 | light:
149 | - platform: status_led
150 | id: led
151 | name: "Blue LED"
152 | disabled_by_default: true
153 | pin:
154 | number: GPIO4
155 | inverted: true
156 |
157 | - platform: binary
158 | id: mini_relay
159 | output: relay_output
160 | name: "Mini Switch"
161 | restore_mode: ${light_restore_mode}
162 | on_turn_on:
163 | - light.turn_on: led
164 | on_turn_off:
165 | - light.turn_off: led
166 |
167 | sensor:
168 | - platform: uptime
169 | name: "Uptime Sensor"
170 | id: uptime_sensor
171 | entity_category: diagnostic
172 | internal: true
173 |
174 | - platform: wifi_signal
175 | name: "WiFi Signal dB"
176 | id: wifi_signal_db
177 | update_interval: 60s
178 | entity_category: "diagnostic"
179 |
180 | - platform: copy
181 | source_id: wifi_signal_db
182 | name: "WiFi Signal Percent"
183 | filters:
184 | - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
185 | unit_of_measurement: "Signal %"
186 | entity_category: "diagnostic"
187 | device_class: ""
188 |
189 | binary_sensor:
190 | # Wired switch
191 | - platform: gpio
192 | id: the_switch
193 | name: "Power Switch"
194 | disabled_by_default: true
195 | pin:
196 | number: GPIO14
197 | mode: INPUT_PULLUP
198 | on_state:
199 | - light.toggle: mini_relay
200 | on_multi_click:
201 | - timing:
202 | - ON for at most 0.5s
203 | - OFF for at most 0.5s
204 | - ON for at most 0.5s
205 | - OFF for at most 0.5s
206 | - ON for at most 0.5s
207 | - OFF for at most 0.5s
208 | - ON for at most 0.5s
209 | - OFF for at most 0.5s
210 | then:
211 | - button.press: Reset
212 |
213 | # Button on mini switch
214 | - platform: gpio
215 | pin:
216 | number: GPIO3
217 | mode: INPUT_PULLUP
218 | inverted: true
219 | name: "Power Button"
220 | disabled_by_default: true
221 | on_multi_click:
222 | - timing:
223 | - ON for at most 1s
224 | - OFF for at least 0.2s
225 | then:
226 | - light.toggle: mini_relay
227 | - timing:
228 | - ON for at least 4s
229 | then:
230 | - button.press: Reset
231 |
232 | - platform: status
233 | name: "Status"
234 | entity_category: diagnostic
235 |
236 | text_sensor:
237 | - platform: wifi_info
238 | ip_address:
239 | name: "IP Address"
240 | entity_category: diagnostic
241 | ssid:
242 | name: "Connected SSID"
243 | entity_category: diagnostic
244 | mac_address:
245 | name: "Mac Address"
246 | entity_category: diagnostic
247 |
248 | # Creates a sensor showing when the device was last restarted
249 | - platform: template
250 | name: 'Last Restart'
251 | id: device_last_restart
252 | icon: mdi:clock
253 | entity_category: diagnostic
254 | # device_class: timestamp
255 |
256 | # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
257 | - platform: template
258 | name: "Uptime"
259 | entity_category: diagnostic
260 | lambda: |-
261 | int seconds = (id(uptime_sensor).state);
262 | int days = seconds / (24 * 3600);
263 | seconds = seconds % (24 * 3600);
264 | int hours = seconds / 3600;
265 | seconds = seconds % 3600;
266 | int minutes = seconds / 60;
267 | seconds = seconds % 60;
268 | if ( days > 3650 ) {
269 | return { "Starting up" };
270 | } else if ( days ) {
271 | return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
272 | } else if ( hours ) {
273 | return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
274 | } else if ( minutes ) {
275 | return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
276 | } else {
277 | return { (String(seconds) +"s").c_str() };
278 | }
279 | icon: mdi:clock-start
280 |
281 | time:
282 | - platform: sntp
283 | id: sntp_time
284 | # Define the timezone of the device
285 | timezone: "${timezone}"
286 | # Change sync interval from default 5min to 6 hours (or as set in substitutions)
287 | update_interval: ${sntp_update_interval}
288 | # Set specific sntp servers to use
289 | servers:
290 | - "${sntp_server_1}"
291 | - "${sntp_server_2}"
292 | - "${sntp_server_3}"
293 | # Publish the time the device was last restarted
294 | on_time_sync:
295 | then:
296 | # Update last restart time, but only once.
297 | - if:
298 | condition:
299 | lambda: 'return id(device_last_restart).state == "";'
300 | then:
301 | - text_sensor.template.publish:
302 | id: device_last_restart
303 | state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
304 |
--------------------------------------------------------------------------------
/athom-sw02.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | # Default name
3 | name: "athom-2gang-switch"
4 | # Default friendly name
5 | friendly_name: "2Gang Switch"
6 | # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
7 | room: ""
8 | # Description as appears in ESPHome & top of webserver page
9 | device_description: "athom 2gang switch"
10 | # Project Name
11 | project_name: "China Athom Technology.2Gang Switch"
12 | # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
13 | project_version: "v1.1.4"
14 | # Restore the relay (GPO switch) upon reboot to state:
15 | light1_restore_mode: RESTORE_DEFAULT_OFF
16 | light2_restore_mode: RESTORE_DEFAULT_OFF
17 | # Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
18 | dns_domain: ".local"
19 | # Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
20 | timezone: ""
21 | # Set the duration between the sntp service polling ntp.org servers for an update
22 | sntp_update_interval: 6h
23 | # Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
24 | sntp_server_1: "0.pool.ntp.org"
25 | sntp_server_2: "1.pool.ntp.org"
26 | sntp_server_3: "2.pool.ntp.org"
27 | # Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
28 | wifi_fast_connect: "false"
29 | # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
30 | log_level: "DEBUG"
31 | # Enable or disable the use of IPv6 networking on the device
32 | ipv6_enable: "false"
33 |
34 | esphome:
35 | name: "${name}"
36 | friendly_name: "${friendly_name}"
37 | comment: "${device_description}"
38 | area: "${room}"
39 | name_add_mac_suffix: true
40 | min_version: 2024.6.0
41 | project:
42 | name: "${project_name}"
43 | version: "${project_version}"
44 | platformio_options:
45 | board_upload.flash_size: 2MB
46 | board_upload.maximum_size: 2097152
47 | board_build.ldscript: eagle.flash.2m.ld
48 | on_boot:
49 | - priority: 600
50 | then:
51 | - select.set_index:
52 | id: power_mode
53 | index: !lambda |-
54 | return id(restore_mode)-1;
55 | - lambda: |-
56 | switch(id(restore_mode))
57 | {
58 | case 1:{
59 | id(light1).turn_off();
60 | id(light2).turn_off();
61 | break;
62 | }
63 | case 2:{
64 | id(light1).turn_on();
65 | id(light2).turn_on();
66 | break;
67 | }
68 | default:{
69 | break;
70 | }
71 | }
72 |
73 | esp8266:
74 | board: esp8285
75 | restore_from_flash: true
76 |
77 | preferences:
78 | flash_write_interval: 1min
79 |
80 | api:
81 |
82 | ota:
83 | - platform: esphome
84 |
85 | logger:
86 | level: ${log_level}
87 | baud_rate: 115200
88 |
89 | web_server:
90 | port: 80
91 |
92 | network:
93 | enable_ipv6: ${ipv6_enable}
94 |
95 | wifi:
96 | # This spawns an AP with the device name and mac address with no password.
97 | ap: {}
98 | # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
99 | fast_connect: "${wifi_fast_connect}"
100 | # Define dns domain / suffix to add to hostname
101 | domain: "${dns_domain}"
102 |
103 | mdns:
104 | disabled: false
105 |
106 | captive_portal:
107 |
108 | dashboard_import:
109 | package_import_url: github://athom-tech/athom-configs/athom-sw02.yaml
110 |
111 | globals:
112 | - id: restore_mode
113 | type: int
114 | restore_value: yes
115 | initial_value: "3"
116 |
117 | select:
118 | - platform: template
119 | name: "Power On State"
120 | id: "power_mode"
121 | optimistic: true
122 | options:
123 | - Always Off
124 | - Always On
125 | - Restore Power Off State
126 | on_value:
127 | then:
128 | - lambda: |-
129 | id(restore_mode)=i+1;
130 |
131 | binary_sensor:
132 | - platform: status
133 | name: "Status"
134 | entity_category: diagnostic
135 |
136 | # Touch Buttons
137 | - platform: gpio
138 | pin:
139 | inverted: true
140 | number: GPIO3
141 | mode:
142 | input: true
143 | pullup: true
144 | name: "Button1"
145 | id: button1
146 | disabled_by_default: true
147 | on_multi_click:
148 | - timing:
149 | - ON for at most 0.5s
150 | - OFF for at least 0.2s
151 | then:
152 | - light.toggle: light1
153 | - timing:
154 | - ON for at least 4s
155 | then:
156 | - button.press: Reset
157 |
158 | - platform: gpio
159 | pin:
160 | inverted: true
161 | number: GPIO5
162 | mode:
163 | input: true
164 | pullup: true
165 | name: "Button2"
166 | id: button2
167 | disabled_by_default: true
168 | on_click:
169 | max_length: 0.5s
170 | then:
171 | - light.toggle: light2
172 |
173 | sensor:
174 | - platform: uptime
175 | name: "Uptime Sensor"
176 | id: uptime_sensor
177 | entity_category: diagnostic
178 | internal: true
179 |
180 | - platform: wifi_signal
181 | name: "WiFi Signal dB"
182 | id: wifi_signal_db
183 | update_interval: 60s
184 | entity_category: "diagnostic"
185 |
186 | - platform: copy
187 | source_id: wifi_signal_db
188 | name: "WiFi Signal Percent"
189 | filters:
190 | - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
191 | unit_of_measurement: "Signal %"
192 | entity_category: "diagnostic"
193 | device_class: ""
194 |
195 | button:
196 | - platform: restart
197 | name: "Restart"
198 | entity_category: config
199 |
200 | - platform: factory_reset
201 | name: "Factory Reset"
202 | id: Reset
203 | entity_category: config
204 |
205 | - platform: safe_mode
206 | name: "Safe Mode"
207 | internal: false
208 | entity_category: config
209 |
210 | output:
211 | # Relays
212 | - platform: gpio
213 | pin: GPIO13
214 | id: relay1
215 | - platform: gpio
216 | pin: GPIO4
217 | id: relay2
218 |
219 | # Button LEDs (1.0 = Blue / 0.0 = Red)
220 | - platform: esp8266_pwm
221 | pin: GPIO14
222 | inverted: true
223 | id: button_led1
224 | - platform: esp8266_pwm
225 | pin: GPIO1
226 | inverted: true
227 | id: button_led2
228 |
229 | light:
230 | - platform: status_led
231 | name: "Status LED"
232 | disabled_by_default: true
233 | pin:
234 | number: GPIO0
235 | inverted: true
236 |
237 | # Relays
238 | - platform: binary
239 | name: "Light1"
240 | id: light1
241 | output: relay1
242 | restore_mode: ${light1_restore_mode}
243 | on_turn_on:
244 | - light.turn_on: led1
245 | on_turn_off:
246 | - light.turn_off: led1
247 |
248 | - platform: binary
249 | name: "Light2"
250 | id: light2
251 | output: relay2
252 | restore_mode: ${light2_restore_mode}
253 | on_turn_on:
254 | - light.turn_on: led2
255 | on_turn_off:
256 | - light.turn_off: led2
257 |
258 | # Button LEDs
259 | - platform: monochromatic
260 | name: "LED1"
261 | disabled_by_default: true
262 | id: led1
263 | output: button_led1
264 | default_transition_length: 500ms
265 | - platform: monochromatic
266 | name: "LED2"
267 | disabled_by_default: true
268 | id: led2
269 | output: button_led2
270 | default_transition_length: 500ms
271 |
272 | text_sensor:
273 | - platform: wifi_info
274 | ip_address:
275 | name: "IP Address"
276 | entity_category: diagnostic
277 | ssid:
278 | name: "Connected SSID"
279 | entity_category: diagnostic
280 | mac_address:
281 | name: "Mac Address"
282 | entity_category: diagnostic
283 |
284 | # Creates a sensor showing when the device was last restarted
285 | - platform: template
286 | name: 'Last Restart'
287 | id: device_last_restart
288 | icon: mdi:clock
289 | entity_category: diagnostic
290 | # device_class: timestamp
291 |
292 | # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
293 | - platform: template
294 | name: "Uptime"
295 | entity_category: diagnostic
296 | lambda: |-
297 | int seconds = (id(uptime_sensor).state);
298 | int days = seconds / (24 * 3600);
299 | seconds = seconds % (24 * 3600);
300 | int hours = seconds / 3600;
301 | seconds = seconds % 3600;
302 | int minutes = seconds / 60;
303 | seconds = seconds % 60;
304 | if ( days > 3650 ) {
305 | return { "Starting up" };
306 | } else if ( days ) {
307 | return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
308 | } else if ( hours ) {
309 | return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
310 | } else if ( minutes ) {
311 | return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
312 | } else {
313 | return { (String(seconds) +"s").c_str() };
314 | }
315 | icon: mdi:clock-start
316 |
317 | time:
318 | - platform: sntp
319 | id: sntp_time
320 | # Define the timezone of the device
321 | timezone: "${timezone}"
322 | # Change sync interval from default 5min to 6 hours (or as set in substitutions)
323 | update_interval: ${sntp_update_interval}
324 | # Set specific sntp servers to use
325 | servers:
326 | - "${sntp_server_1}"
327 | - "${sntp_server_2}"
328 | - "${sntp_server_3}"
329 | # Publish the time the device was last restarted
330 | on_time_sync:
331 | then:
332 | # Update last restart time, but only once.
333 | - if:
334 | condition:
335 | lambda: 'return id(device_last_restart).state == "";'
336 | then:
337 | - text_sensor.template.publish:
338 | id: device_last_restart
339 | state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
340 |
--------------------------------------------------------------------------------
/athom-sw02-v2.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | # Default name
3 | name: "athom-2gang-switch-v2"
4 | # Default friendly name
5 | friendly_name: "2Gang Switch V2"
6 | # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
7 | room: ""
8 | # Description as appears in ESPHome & top of webserver page
9 | device_description: "athom 2gang switch v2"
10 | # Project Name
11 | project_name: "China Athom Technology.2Gang Switch V2"
12 | # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
13 | project_version: "v1.1.4"
14 | # Restore the relay (GPO switch) upon reboot to state:
15 | light1_restore_mode: RESTORE_DEFAULT_OFF
16 | light2_restore_mode: RESTORE_DEFAULT_OFF
17 | # Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
18 | dns_domain: ".local"
19 | # Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
20 | timezone: ""
21 | # Set the duration between the sntp service polling ntp.org servers for an update
22 | sntp_update_interval: 6h
23 | # Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
24 | sntp_server_1: "0.pool.ntp.org"
25 | sntp_server_2: "1.pool.ntp.org"
26 | sntp_server_3: "2.pool.ntp.org"
27 | # Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
28 | wifi_fast_connect: "false"
29 | # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
30 | log_level: "DEBUG"
31 | # Enable or disable the use of IPv6 networking on the device
32 | ipv6_enable: "false"
33 |
34 | esphome:
35 | name: "${name}"
36 | friendly_name: "${friendly_name}"
37 | comment: "${device_description}"
38 | area: "${room}"
39 | name_add_mac_suffix: true
40 | min_version: 2024.6.0
41 | project:
42 | name: "${project_name}"
43 | version: "${project_version}"
44 | platformio_options:
45 | board_upload.flash_size: 2MB
46 | board_upload.maximum_size: 2097152
47 | board_build.ldscript: eagle.flash.2m.ld
48 | on_boot:
49 | - priority: 600
50 | then:
51 | - select.set_index:
52 | id: power_mode
53 | index: !lambda |-
54 | return id(restore_mode)-1;
55 | - lambda: |-
56 | switch(id(restore_mode))
57 | {
58 | case 1:{
59 | id(light1).turn_off();
60 | id(light2).turn_off();
61 | break;
62 | }
63 | case 2:{
64 | id(light1).turn_on();
65 | id(light2).turn_on();
66 | break;
67 | }
68 | default:{
69 | break;
70 | }
71 | }
72 |
73 | esp8266:
74 | board: esp8285
75 | restore_from_flash: true
76 |
77 | preferences:
78 | flash_write_interval: 1min
79 |
80 | api:
81 |
82 | ota:
83 | - platform: esphome
84 |
85 | logger:
86 | level: ${log_level}
87 | baud_rate: 115200
88 |
89 | web_server:
90 | port: 80
91 |
92 | network:
93 | enable_ipv6: ${ipv6_enable}
94 |
95 | wifi:
96 | # This spawns an AP with the device name and mac address with no password.
97 | ap: {}
98 | # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
99 | fast_connect: "${wifi_fast_connect}"
100 | # Define dns domain / suffix to add to hostname
101 | domain: "${dns_domain}"
102 |
103 | mdns:
104 | disabled: false
105 |
106 | captive_portal:
107 |
108 | dashboard_import:
109 | package_import_url: github://athom-tech/athom-configs/athom-sw02-v2.yaml
110 |
111 | globals:
112 | - id: restore_mode
113 | type: int
114 | restore_value: yes
115 | initial_value: "3"
116 |
117 | select:
118 | - platform: template
119 | name: "Power On State"
120 | id: "power_mode"
121 | optimistic: true
122 | options:
123 | - Always Off
124 | - Always On
125 | - Restore Power Off State
126 | on_value:
127 | then:
128 | - lambda: |-
129 | id(restore_mode)=i+1;
130 |
131 | binary_sensor:
132 | - platform: status
133 | name: "Status"
134 | entity_category: diagnostic
135 |
136 | # Touch Buttons
137 | - platform: gpio
138 | pin:
139 | inverted: true
140 | number: GPIO3
141 | mode:
142 | input: true
143 | pullup: true
144 | name: "Button1"
145 | id: button1
146 | disabled_by_default: true
147 | on_multi_click:
148 | - timing:
149 | - ON for at most 0.5s
150 | - OFF for at least 0.2s
151 | then:
152 | - light.toggle: light1
153 | - timing:
154 | - ON for at least 4s
155 | then:
156 | - button.press: Reset
157 |
158 | - platform: gpio
159 | pin:
160 | inverted: true
161 | number: GPIO5
162 | mode:
163 | input: true
164 | pullup: true
165 | name: "Button2"
166 | id: button2
167 | disabled_by_default: true
168 | on_click:
169 | max_length: 0.5s
170 | then:
171 | - light.toggle: light2
172 |
173 | sensor:
174 | - platform: uptime
175 | name: "Uptime Sensor"
176 | id: uptime_sensor
177 | entity_category: diagnostic
178 | internal: true
179 |
180 | - platform: wifi_signal
181 | name: "WiFi Signal dB"
182 | id: wifi_signal_db
183 | update_interval: 60s
184 | entity_category: "diagnostic"
185 |
186 | - platform: copy
187 | source_id: wifi_signal_db
188 | name: "WiFi Signal Percent"
189 | filters:
190 | - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
191 | unit_of_measurement: "Signal %"
192 | entity_category: "diagnostic"
193 | device_class: ""
194 |
195 | button:
196 | - platform: restart
197 | name: "Restart"
198 | entity_category: config
199 |
200 | - platform: factory_reset
201 | name: "Factory Reset"
202 | id: Reset
203 | entity_category: config
204 |
205 | - platform: safe_mode
206 | name: "Safe Mode"
207 | internal: false
208 | entity_category: config
209 |
210 | output:
211 | # Relays
212 | - platform: gpio
213 | pin: GPIO13
214 | id: relay1
215 | - platform: gpio
216 | pin: GPIO4
217 | id: relay2
218 |
219 | # - platform: gpio
220 | # pin: GPIO16
221 | # id: io16
222 |
223 | # Button LEDs (1.0 = Blue / 0.0 = Red)
224 | - platform: esp8266_pwm
225 | pin: GPIO16
226 | inverted: true
227 | id: button_led1
228 | - platform: esp8266_pwm
229 | pin: GPIO1
230 | inverted: true
231 | id: button_led2
232 |
233 | light:
234 | - platform: status_led
235 | name: "Status LED"
236 | disabled_by_default: true
237 | pin:
238 | number: GPIO0
239 | inverted: true
240 |
241 | # Relays
242 | - platform: binary
243 | name: "Light1"
244 | id: light1
245 | output: relay1
246 | restore_mode: ${light1_restore_mode}
247 | on_turn_on:
248 | - light.turn_on: led1
249 | on_turn_off:
250 | - light.turn_off: led1
251 |
252 | - platform: binary
253 | name: "Light2"
254 | id: light2
255 | output: relay2
256 | restore_mode: ${light2_restore_mode}
257 | on_turn_on:
258 | - light.turn_on: led2
259 | on_turn_off:
260 | - light.turn_off: led2
261 |
262 | # Button LEDs
263 | - platform: monochromatic
264 | name: "LED1"
265 | disabled_by_default: true
266 | id: led1
267 | output: button_led1
268 | default_transition_length: 500ms
269 |
270 | - platform: monochromatic
271 | name: "LED2"
272 | disabled_by_default: true
273 | id: led2
274 | output: button_led2
275 | default_transition_length: 500ms
276 |
277 | text_sensor:
278 | - platform: wifi_info
279 | ip_address:
280 | name: "IP Address"
281 | entity_category: diagnostic
282 | ssid:
283 | name: "Connected SSID"
284 | entity_category: diagnostic
285 | mac_address:
286 | name: "Mac Address"
287 | entity_category: diagnostic
288 |
289 | # Creates a sensor showing when the device was last restarted
290 | - platform: template
291 | name: 'Last Restart'
292 | id: device_last_restart
293 | icon: mdi:clock
294 | entity_category: diagnostic
295 | # device_class: timestamp
296 |
297 | # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
298 | - platform: template
299 | name: "Uptime"
300 | entity_category: diagnostic
301 | lambda: |-
302 | int seconds = (id(uptime_sensor).state);
303 | int days = seconds / (24 * 3600);
304 | seconds = seconds % (24 * 3600);
305 | int hours = seconds / 3600;
306 | seconds = seconds % 3600;
307 | int minutes = seconds / 60;
308 | seconds = seconds % 60;
309 | if ( days > 3650 ) {
310 | return { "Starting up" };
311 | } else if ( days ) {
312 | return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
313 | } else if ( hours ) {
314 | return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
315 | } else if ( minutes ) {
316 | return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
317 | } else {
318 | return { (String(seconds) +"s").c_str() };
319 | }
320 | icon: mdi:clock-start
321 |
322 | time:
323 | - platform: sntp
324 | id: sntp_time
325 | # Define the timezone of the device
326 | timezone: "${timezone}"
327 | # Change sync interval from default 5min to 6 hours (or as set in substitutions)
328 | update_interval: ${sntp_update_interval}
329 | # Set specific sntp servers to use
330 | servers:
331 | - "${sntp_server_1}"
332 | - "${sntp_server_2}"
333 | - "${sntp_server_3}"
334 | # Publish the time the device was last restarted
335 | on_time_sync:
336 | then:
337 | # Update last restart time, but only once.
338 | - if:
339 | condition:
340 | lambda: 'return id(device_last_restart).state == "";'
341 | then:
342 | - text_sensor.template.publish:
343 | id: device_last_restart
344 | state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
345 |
--------------------------------------------------------------------------------
/athom-sw04.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | # Default name
3 | name: "athom-4gang-switch"
4 | # Default friendly name
5 | friendly_name: "4Gang Switch"
6 | # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
7 | room: ""
8 | # Description as appears in ESPHome & top of webserver page
9 | device_description: "athom 4gang switch"
10 | # Project Name
11 | project_name: "China Athom Technology.4Gang Switch"
12 | # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
13 | project_version: "v1.1.4"
14 | # Restore the relay (GPO switch) upon reboot to state:
15 | light1_restore_mode: RESTORE_DEFAULT_OFF
16 | light2_restore_mode: RESTORE_DEFAULT_OFF
17 | light3_restore_mode: RESTORE_DEFAULT_OFF
18 | light4_restore_mode: RESTORE_DEFAULT_OFF
19 | # Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
20 | dns_domain: ".local"
21 | # Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
22 | timezone: ""
23 | # Set the duration between the sntp service polling ntp.org servers for an update
24 | sntp_update_interval: 6h
25 | # Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
26 | sntp_server_1: "0.pool.ntp.org"
27 | sntp_server_2: "1.pool.ntp.org"
28 | sntp_server_3: "2.pool.ntp.org"
29 | # Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
30 | wifi_fast_connect: "false"
31 | # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
32 | log_level: "DEBUG"
33 | # Enable or disable the use of IPv6 networking on the device
34 | ipv6_enable: "false"
35 |
36 | esphome:
37 | name: "${name}"
38 | friendly_name: "${friendly_name}"
39 | comment: "${device_description}"
40 | area: "${room}"
41 | name_add_mac_suffix: true
42 | min_version: 2024.6.0
43 | project:
44 | name: "${project_name}"
45 | version: "${project_version}"
46 | platformio_options:
47 | board_upload.flash_size: 2MB
48 | board_upload.maximum_size: 2097152
49 | board_build.ldscript: eagle.flash.2m.ld
50 | on_boot:
51 | - priority: 600
52 | then:
53 | - select.set_index:
54 | id: power_mode
55 | index: !lambda |-
56 | return id(restore_mode)-1;
57 | - lambda: |-
58 | switch(id(restore_mode))
59 | {
60 | case 1:{
61 | id(light1).turn_off();
62 | id(light2).turn_off();
63 | id(light3).turn_off();
64 | id(light4).turn_off();
65 | break;
66 | }
67 | case 2:{
68 | id(light1).turn_on();
69 | id(light2).turn_on();
70 | id(light3).turn_on();
71 | id(light4).turn_on();
72 | break;
73 | }
74 | default:{
75 | break;
76 | }
77 | }
78 |
79 | esp8266:
80 | board: esp8285
81 | restore_from_flash: true
82 |
83 | preferences:
84 | flash_write_interval: 1min
85 |
86 | api:
87 |
88 | ota:
89 | - platform: esphome
90 |
91 | logger:
92 | level: ${log_level}
93 | baud_rate: 115200
94 |
95 | web_server:
96 | port: 80
97 |
98 | network:
99 | enable_ipv6: ${ipv6_enable}
100 |
101 | wifi:
102 | # This spawns an AP with the device name and mac address with no password.
103 | ap: {}
104 | # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
105 | fast_connect: "${wifi_fast_connect}"
106 | # Define dns domain / suffix to add to hostname
107 | domain: "${dns_domain}"
108 |
109 | mdns:
110 | disabled: false
111 |
112 | captive_portal:
113 |
114 | dashboard_import:
115 | package_import_url: github://athom-tech/athom-configs/athom-sw04.yaml
116 |
117 | globals:
118 | - id: restore_mode
119 | type: int
120 | restore_value: yes
121 | initial_value: "3"
122 |
123 | select:
124 | - platform: template
125 | name: "Power On State"
126 | id: "power_mode"
127 | optimistic: true
128 | options:
129 | - Always Off
130 | - Always On
131 | - Restore Power Off State
132 | on_value:
133 | then:
134 | - lambda: |-
135 | id(restore_mode)=i+1;
136 |
137 | binary_sensor:
138 | - platform: status
139 | name: "Status"
140 | entity_category: diagnostic
141 |
142 | # Touch Buttons
143 | - platform: gpio
144 | pin:
145 | inverted: true
146 | number: GPIO12
147 | name: "Button1"
148 | disabled_by_default: true
149 | on_multi_click:
150 | - timing:
151 | - ON for at most 0.5s
152 | - OFF for at least 0.2s
153 | then:
154 | - light.toggle: light1
155 | - timing:
156 | - ON for at least 4s
157 | then:
158 | - button.press: Reset
159 |
160 | - platform: gpio
161 | pin:
162 | inverted: true
163 | number: GPIO3
164 | name: "Button2"
165 | disabled_by_default: true
166 | on_click:
167 | max_length: 0.5s
168 | then:
169 | - light.toggle: light2
170 |
171 | - platform: gpio
172 | pin:
173 | inverted: true
174 | number: GPIO5
175 | name: "Button3"
176 | disabled_by_default: true
177 | on_click:
178 | max_length: 0.5s
179 | then:
180 | - light.toggle: light3
181 |
182 | - platform: gpio
183 | pin:
184 | inverted: true
185 | number: GPIO16
186 | name: "Button4"
187 | disabled_by_default: true
188 | on_click:
189 | max_length: 0.5s
190 | then:
191 | - light.toggle: light4
192 |
193 | sensor:
194 | - platform: uptime
195 | name: "Uptime Sensor"
196 | id: uptime_sensor
197 | entity_category: diagnostic
198 | internal: true
199 |
200 | - platform: wifi_signal
201 | name: "WiFi Signal dB"
202 | id: wifi_signal_db
203 | update_interval: 60s
204 | entity_category: "diagnostic"
205 |
206 | - platform: copy
207 | source_id: wifi_signal_db
208 | name: "WiFi Signal Percent"
209 | filters:
210 | - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
211 | unit_of_measurement: "Signal %"
212 | entity_category: "diagnostic"
213 | device_class: ""
214 |
215 | button:
216 | - platform: restart
217 | name: "Restart"
218 | entity_category: config
219 |
220 | - platform: factory_reset
221 | name: "Factory Reset"
222 | id: Reset
223 | entity_category: config
224 |
225 | - platform: safe_mode
226 | name: "Safe Mode"
227 | internal: false
228 | entity_category: config
229 |
230 | output:
231 | # Relays
232 | - platform: gpio
233 | pin: GPIO13
234 | id: relay1
235 | - platform: gpio
236 | pin: GPIO4
237 | id: relay2
238 | - platform: gpio
239 | pin: GPIO15
240 | id: relay3
241 | - platform: gpio
242 | pin: GPIO14
243 | id: relay4
244 |
245 | light:
246 | - platform: status_led
247 | name: "Status LED"
248 | disabled_by_default: true
249 | pin:
250 | number: GPIO0
251 | inverted: true
252 |
253 | # Relays
254 | - platform: binary
255 | name: "Light1"
256 | id: light1
257 | output: relay1
258 | restore_mode: ${light1_restore_mode}
259 | - platform: binary
260 | name: "Light2"
261 | id: light2
262 | output: relay2
263 | restore_mode: ${light2_restore_mode}
264 | - platform: binary
265 | name: "Light3"
266 | id: light3
267 | output: relay3
268 | restore_mode: ${light3_restore_mode}
269 | - platform: binary
270 | name: "Light4"
271 | id: light4
272 | output: relay4
273 | restore_mode: ${light4_restore_mode}
274 |
275 | text_sensor:
276 | - platform: wifi_info
277 | ip_address:
278 | name: "IP Address"
279 | entity_category: diagnostic
280 | ssid:
281 | name: "Connected SSID"
282 | entity_category: diagnostic
283 | mac_address:
284 | name: "Mac Address"
285 | entity_category: diagnostic
286 |
287 | # Creates a sensor showing when the device was last restarted
288 | - platform: template
289 | name: 'Last Restart'
290 | id: device_last_restart
291 | icon: mdi:clock
292 | entity_category: diagnostic
293 | # device_class: timestamp
294 |
295 | # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
296 | - platform: template
297 | name: "Uptime"
298 | entity_category: diagnostic
299 | lambda: |-
300 | int seconds = (id(uptime_sensor).state);
301 | int days = seconds / (24 * 3600);
302 | seconds = seconds % (24 * 3600);
303 | int hours = seconds / 3600;
304 | seconds = seconds % 3600;
305 | int minutes = seconds / 60;
306 | seconds = seconds % 60;
307 | if ( days > 3650 ) {
308 | return { "Starting up" };
309 | } else if ( days ) {
310 | return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
311 | } else if ( hours ) {
312 | return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
313 | } else if ( minutes ) {
314 | return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
315 | } else {
316 | return { (String(seconds) +"s").c_str() };
317 | }
318 | icon: mdi:clock-start
319 |
320 | time:
321 | - platform: sntp
322 | id: sntp_time
323 | # Define the timezone of the device
324 | timezone: "${timezone}"
325 | # Change sync interval from default 5min to 6 hours (or as set in substitutions)
326 | update_interval: ${sntp_update_interval}
327 | # Set specific sntp servers to use
328 | servers:
329 | - "${sntp_server_1}"
330 | - "${sntp_server_2}"
331 | - "${sntp_server_3}"
332 | # Publish the time the device was last restarted
333 | on_time_sync:
334 | then:
335 | # Update last restart time, but only once.
336 | - if:
337 | condition:
338 | lambda: 'return id(device_last_restart).state == "";'
339 | then:
340 | - text_sensor.template.publish:
341 | id: device_last_restart
342 | state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
343 |
--------------------------------------------------------------------------------
/athom-rgbww-light.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | # Default name
3 | name: "athom-rgbcw-bulb"
4 | # Default friendly name
5 | friendly_name: "Athom RGBCW Bulb"
6 | # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
7 | room: ""
8 | # Description as appears in ESPHome & top of webserver page
9 | device_description: "athom 7w rgbcw light bulb"
10 | # Project Name
11 | project_name: "China Athom Technology.Athom RGBCW Bulb"
12 | # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
13 | project_version: "v1.1.4"
14 | # Restore the light (GPO switch) upon reboot to state:
15 | light_restore_mode: RESTORE_DEFAULT_ON
16 | # Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
17 | dns_domain: ".local"
18 | # Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
19 | timezone: ""
20 | # Set the duration between the sntp service polling ntp.org servers for an update
21 | sntp_update_interval: 6h
22 | # Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
23 | sntp_server_1: "0.pool.ntp.org"
24 | sntp_server_2: "1.pool.ntp.org"
25 | sntp_server_3: "2.pool.ntp.org"
26 | # Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
27 | wifi_fast_connect: "false"
28 | # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
29 | log_level: "DEBUG"
30 | # Enable or disable the use of IPv6 networking on the device
31 | ipv6_enable: "false"
32 | color_interlock: "true"
33 |
34 | globals:
35 | - id: fast_boot
36 | type: int
37 | restore_value: yes
38 | initial_value: '0'
39 |
40 | - id: restore_mode
41 | type: int
42 | restore_value: yes
43 | initial_value: "1"
44 |
45 | select:
46 | - platform: template
47 | name: "Power On State"
48 | id: "power_mode"
49 | optimistic: true
50 | options:
51 | - Always Off
52 | - Always On
53 | - Restore Power Off State
54 | on_value:
55 | then:
56 | - lambda: |-
57 | id(restore_mode)=i+1;
58 |
59 | esphome:
60 | name: "${name}"
61 | friendly_name: "${friendly_name}"
62 | comment: "${device_description}"
63 | area: "${room}"
64 | name_add_mac_suffix: true
65 | min_version: 2024.6.0
66 | project:
67 | name: "${project_name}"
68 | version: "${project_version}"
69 | platformio_options:
70 | board_upload.flash_size: 2MB
71 | board_upload.maximum_size: 2097152
72 | board_build.ldscript: eagle.flash.2m.ld
73 | on_boot:
74 | then:
75 | - script.execute: fast_boot_script
76 | - select.set_index:
77 | id: power_mode
78 | index: !lambda |-
79 | return id(restore_mode)-1;
80 | - lambda: |-
81 | switch(id(restore_mode))
82 | {
83 | case 1:{
84 | auto call = id(rgbww_light).turn_off();
85 | call.perform();
86 | break;
87 | }
88 | case 2:{
89 | auto call = id(rgbww_light).turn_on();
90 | call.set_color_mode(ColorMode::WHITE);
91 | call.set_brightness(1.0);
92 | call.perform();
93 | break;
94 | }
95 | default:{
96 | break;
97 | }
98 | }
99 |
100 | esp8266:
101 | board: esp8285
102 | restore_from_flash: true
103 |
104 | preferences:
105 | flash_write_interval: 1min
106 |
107 | api:
108 |
109 | ota:
110 | - platform: esphome
111 |
112 | logger:
113 | level: ${log_level}
114 | baud_rate: 115200
115 |
116 | web_server:
117 | port: 80
118 |
119 | network:
120 | enable_ipv6: ${ipv6_enable}
121 |
122 | wifi:
123 | # This spawns an AP with the device name and mac address with no password.
124 | ap: {}
125 | # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
126 | fast_connect: "${wifi_fast_connect}"
127 | # Define dns domain / suffix to add to hostname
128 | domain: "${dns_domain}"
129 |
130 | mdns:
131 | disabled: false
132 |
133 | captive_portal:
134 |
135 | dashboard_import:
136 | package_import_url: github://athom-tech/athom-configs/athom-rgbww-light.yaml
137 |
138 | binary_sensor:
139 | - platform: status
140 | name: "Status"
141 | entity_category: diagnostic
142 |
143 | sensor:
144 | - platform: uptime
145 | name: "Uptime Sensor"
146 | id: uptime_sensor
147 | entity_category: diagnostic
148 | internal: true
149 |
150 | - platform: wifi_signal
151 | name: "WiFi Signal dB"
152 | id: wifi_signal_db
153 | update_interval: 60s
154 | entity_category: "diagnostic"
155 |
156 | - platform: copy
157 | source_id: wifi_signal_db
158 | name: "WiFi Signal Percent"
159 | filters:
160 | - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
161 | unit_of_measurement: "Signal %"
162 | entity_category: "diagnostic"
163 | device_class: ""
164 |
165 | button:
166 | - platform: restart
167 | name: "Restart"
168 | entity_category: config
169 |
170 | - platform: factory_reset
171 | name: "Factory Reset"
172 | id: Reset
173 | entity_category: config
174 |
175 | - platform: safe_mode
176 | name: "Safe Mode"
177 | internal: false
178 | entity_category: config
179 |
180 | output:
181 | - platform: esp8266_pwm
182 | id: red_output
183 | pin: GPIO4
184 | min_power: 0.000499
185 | max_power: 1
186 | - platform: esp8266_pwm
187 | id: green_output
188 | pin: GPIO12
189 | min_power: 0.000499
190 | max_power: 1
191 | - platform: esp8266_pwm
192 | id: blue_output
193 | pin: GPIO14
194 | min_power: 0.000499
195 | max_power: 1
196 | - platform: esp8266_pwm
197 | id: warm_white_output
198 | pin: GPIO13
199 | min_power: 0.000499
200 | max_power: 0.9
201 | - platform: esp8266_pwm
202 | id: white_output
203 | pin: GPIO5
204 | min_power: 0.000499
205 | max_power: 0.9
206 |
207 | light:
208 | - platform: rgbww
209 | id: rgbww_light
210 | name: "RGBCW_Bulb"
211 | restore_mode: ${light_restore_mode}
212 | red: red_output
213 | green: green_output
214 | blue: blue_output
215 | warm_white: warm_white_output
216 | cold_white: white_output
217 | cold_white_color_temperature: 6000 K
218 | warm_white_color_temperature: 3000 K
219 | color_interlock: ${color_interlock}
220 |
221 | text_sensor:
222 | - platform: wifi_info
223 | ip_address:
224 | name: "IP Address"
225 | entity_category: diagnostic
226 | ssid:
227 | name: "Connected SSID"
228 | entity_category: diagnostic
229 | mac_address:
230 | name: "Mac Address"
231 | entity_category: diagnostic
232 |
233 | # Creates a sensor showing when the device was last restarted
234 | - platform: template
235 | name: 'Last Restart'
236 | id: device_last_restart
237 | icon: mdi:clock
238 | entity_category: diagnostic
239 | # device_class: timestamp
240 |
241 | # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
242 | - platform: template
243 | name: "Uptime"
244 | entity_category: diagnostic
245 | lambda: |-
246 | int seconds = (id(uptime_sensor).state);
247 | int days = seconds / (24 * 3600);
248 | seconds = seconds % (24 * 3600);
249 | int hours = seconds / 3600;
250 | seconds = seconds % 3600;
251 | int minutes = seconds / 60;
252 | seconds = seconds % 60;
253 | if ( days > 3650 ) {
254 | return { "Starting up" };
255 | } else if ( days ) {
256 | return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
257 | } else if ( hours ) {
258 | return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
259 | } else if ( minutes ) {
260 | return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
261 | } else {
262 | return { (String(seconds) +"s").c_str() };
263 | }
264 | icon: mdi:clock-start
265 |
266 | time:
267 | - platform: sntp
268 | id: sntp_time
269 | # Define the timezone of the device
270 | timezone: "${timezone}"
271 | # Change sync interval from default 5min to 6 hours (or as set in substitutions)
272 | update_interval: ${sntp_update_interval}
273 | # Set specific sntp servers to use
274 | servers:
275 | - "${sntp_server_1}"
276 | - "${sntp_server_2}"
277 | - "${sntp_server_3}"
278 | # Publish the time the device was last restarted
279 | on_time_sync:
280 | then:
281 | # Update last restart time, but only once.
282 | - if:
283 | condition:
284 | lambda: 'return id(device_last_restart).state == "";'
285 | then:
286 | - text_sensor.template.publish:
287 | id: device_last_restart
288 | state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
289 |
290 | script:
291 | - id: fast_boot_script
292 | then:
293 | - if:
294 | condition:
295 | lambda: return ( id(fast_boot) >= 3 );
296 | then:
297 | - lambda: |-
298 | ESP_LOGD("athom-rgbww-light.yaml", "Now the counter is greater than or equal to 3, perform reset device and reboot");
299 | id(fast_boot) = 0;
300 | fast_boot->loop();
301 | global_preferences->sync();
302 | auto call = id(rgbww_light).turn_on();
303 | call.set_transition_length(500);
304 | call.set_brightness(1.0);
305 | call.set_color_mode(ColorMode::RGB);
306 | call.set_rgb(0.0, 0.0, 1.0);
307 | call.perform();
308 | - delay: 5s
309 | - button.press: Reset
310 | - lambda: |-
311 | id(fast_boot) += 1;
312 | fast_boot->loop();
313 | global_preferences->sync();
314 | ESP_LOGD("athom-rgbww-light.yaml", "Now the counter is %d. Reset the device when the counter is greater than or equal to 3", id(fast_boot));
315 | - delay: 10s
316 | - lambda: |-
317 | ESP_LOGD("athom-rgbww-light.yaml", "Reset counter");
318 | id(fast_boot) = 0;
319 | fast_boot->loop();
320 | global_preferences->sync();
321 |
--------------------------------------------------------------------------------
/athom-rgbct-light.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | # Default name
3 | name: "athom-rgbcct-bulb"
4 | # Default friendly name
5 | friendly_name: "Athom RGBCCT Bulb"
6 | # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
7 | room: ""
8 | # Description as appears in ESPHome & top of webserver page
9 | device_description: "athom 15w rgbcct light bulb"
10 | # Project Name
11 | project_name: "China Athom Technology.Athom RGBCCT Bulb"
12 | # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
13 | project_version: "v1.1.4"
14 | # Restore the light (GPO switch) upon reboot to state:
15 | light_restore_mode: RESTORE_DEFAULT_ON
16 | # Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
17 | dns_domain: ".local"
18 | # Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
19 | timezone: ""
20 | # Set the duration between the sntp service polling ntp.org servers for an update
21 | sntp_update_interval: 6h
22 | # Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
23 | sntp_server_1: "0.pool.ntp.org"
24 | sntp_server_2: "1.pool.ntp.org"
25 | sntp_server_3: "2.pool.ntp.org"
26 | # Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
27 | wifi_fast_connect: "false"
28 | # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
29 | log_level: "DEBUG"
30 | # Enable or disable the use of IPv6 networking on the device
31 | ipv6_enable: "false"
32 | color_interlock: "true"
33 |
34 | globals:
35 | - id: fast_boot
36 | type: int
37 | restore_value: yes
38 | initial_value: '0'
39 |
40 | - id: restore_mode
41 | type: int
42 | restore_value: yes
43 | initial_value: "1"
44 |
45 | select:
46 | - platform: template
47 | name: "Power On State"
48 | id: "power_mode"
49 | optimistic: true
50 | options:
51 | - Always Off
52 | - Always On
53 | - Restore Power Off State
54 | on_value:
55 | then:
56 | - lambda: |-
57 | id(restore_mode)=i+1;
58 |
59 | esphome:
60 | name: "${name}"
61 | friendly_name: "${friendly_name}"
62 | comment: "${device_description}"
63 | area: "${room}"
64 | name_add_mac_suffix: true
65 | min_version: 2024.6.0
66 | project:
67 | name: "${project_name}"
68 | version: "${project_version}"
69 | platformio_options:
70 | board_upload.flash_size: 2MB
71 | board_upload.maximum_size: 2097152
72 | board_build.ldscript: eagle.flash.2m.ld
73 | on_boot:
74 | then:
75 | - script.execute: fast_boot_script
76 | - select.set_index:
77 | id: power_mode
78 | index: !lambda |-
79 | return id(restore_mode)-1;
80 | - lambda: |-
81 | switch(id(restore_mode))
82 | {
83 | case 1:{
84 | auto call = id(rgbct_light).turn_off();
85 | call.perform();
86 | break;
87 | }
88 | case 2:{
89 | auto call = id(rgbct_light).turn_on();
90 | call.set_color_mode(ColorMode::WHITE);
91 | call.set_brightness(1.0);
92 | call.perform();
93 | break;
94 | }
95 | default:{
96 | break;
97 | }
98 | }
99 |
100 | esp8266:
101 | board: esp8285
102 | restore_from_flash: true
103 |
104 | preferences:
105 | flash_write_interval: 1min
106 |
107 | api:
108 |
109 | ota:
110 | - platform: esphome
111 |
112 | logger:
113 | level: ${log_level}
114 | baud_rate: 115200
115 |
116 | web_server:
117 | port: 80
118 |
119 | network:
120 | enable_ipv6: ${ipv6_enable}
121 |
122 | wifi:
123 | # This spawns an AP with the device name and mac address with no password.
124 | ap: {}
125 | # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
126 | fast_connect: "${wifi_fast_connect}"
127 | # Define dns domain / suffix to add to hostname
128 | domain: "${dns_domain}"
129 |
130 | mdns:
131 | disabled: false
132 |
133 | captive_portal:
134 |
135 | dashboard_import:
136 | package_import_url: github://athom-tech/athom-configs/athom-rgbct-light.yaml
137 |
138 | binary_sensor:
139 | - platform: status
140 | name: "Status"
141 | entity_category: diagnostic
142 |
143 | sensor:
144 | - platform: uptime
145 | name: "Uptime Sensor"
146 | id: uptime_sensor
147 | entity_category: diagnostic
148 | internal: true
149 |
150 | - platform: wifi_signal
151 | name: "WiFi Signal dB"
152 | id: wifi_signal_db
153 | update_interval: 60s
154 | entity_category: "diagnostic"
155 |
156 | - platform: copy
157 | source_id: wifi_signal_db
158 | name: "WiFi Signal Percent"
159 | filters:
160 | - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
161 | unit_of_measurement: "Signal %"
162 | entity_category: "diagnostic"
163 | device_class: ""
164 |
165 | button:
166 | - platform: restart
167 | name: "Restart"
168 | entity_category: config
169 |
170 | - platform: factory_reset
171 | name: "Factory Reset"
172 | id: Reset
173 | entity_category: config
174 |
175 | - platform: safe_mode
176 | name: "Safe Mode"
177 | internal: false
178 | entity_category: config
179 |
180 | output:
181 | - platform: esp8266_pwm
182 | id: red_output
183 | pin: GPIO4
184 | min_power: 0.000499
185 | max_power: 1
186 | zero_means_zero: true
187 | - platform: esp8266_pwm
188 | id: green_output
189 | pin: GPIO12
190 | min_power: 0.000499
191 | max_power: 1
192 | zero_means_zero: true
193 | - platform: esp8266_pwm
194 | id: blue_output
195 | pin: GPIO14
196 | min_power: 0.000499
197 | max_power: 1
198 | zero_means_zero: true
199 | - platform: esp8266_pwm
200 | id: white_output
201 | pin: GPIO5
202 | min_power: 0.01
203 | max_power: 0.9
204 | zero_means_zero: true
205 | - platform: esp8266_pwm
206 | id: ct_output
207 | inverted: true
208 | pin: GPIO13
209 | min_power: 0.01
210 | max_power: 0.9
211 | zero_means_zero: true
212 |
213 | light:
214 | - platform: rgbct
215 | id: rgbct_light
216 | name: "RGBCCT_Bulb"
217 | restore_mode: ${light_restore_mode}
218 | red: red_output
219 | green: green_output
220 | blue: blue_output
221 | white_brightness: white_output
222 | color_temperature: ct_output
223 | cold_white_color_temperature: 6000K
224 | warm_white_color_temperature: 3000K
225 | color_interlock: ${color_interlock}
226 |
227 | text_sensor:
228 | - platform: wifi_info
229 | ip_address:
230 | name: "IP Address"
231 | entity_category: diagnostic
232 | ssid:
233 | name: "Connected SSID"
234 | entity_category: diagnostic
235 | mac_address:
236 | name: "Mac Address"
237 | entity_category: diagnostic
238 |
239 | # Creates a sensor showing when the device was last restarted
240 | - platform: template
241 | name: 'Last Restart'
242 | id: device_last_restart
243 | icon: mdi:clock
244 | entity_category: diagnostic
245 | # device_class: timestamp
246 |
247 | # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
248 | - platform: template
249 | name: "Uptime"
250 | entity_category: diagnostic
251 | lambda: |-
252 | int seconds = (id(uptime_sensor).state);
253 | int days = seconds / (24 * 3600);
254 | seconds = seconds % (24 * 3600);
255 | int hours = seconds / 3600;
256 | seconds = seconds % 3600;
257 | int minutes = seconds / 60;
258 | seconds = seconds % 60;
259 | if ( days > 3650 ) {
260 | return { "Starting up" };
261 | } else if ( days ) {
262 | return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
263 | } else if ( hours ) {
264 | return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
265 | } else if ( minutes ) {
266 | return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
267 | } else {
268 | return { (String(seconds) +"s").c_str() };
269 | }
270 | icon: mdi:clock-start
271 |
272 | time:
273 | - platform: sntp
274 | id: sntp_time
275 | # Define the timezone of the device
276 | timezone: "${timezone}"
277 | # Change sync interval from default 5min to 6 hours (or as set in substitutions)
278 | update_interval: ${sntp_update_interval}
279 | # Set specific sntp servers to use
280 | servers:
281 | - "${sntp_server_1}"
282 | - "${sntp_server_2}"
283 | - "${sntp_server_3}"
284 | # Publish the time the device was last restarted
285 | on_time_sync:
286 | then:
287 | # Update last restart time, but only once.
288 | - if:
289 | condition:
290 | lambda: 'return id(device_last_restart).state == "";'
291 | then:
292 | - text_sensor.template.publish:
293 | id: device_last_restart
294 | state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
295 |
296 | script:
297 | - id: fast_boot_script
298 | then:
299 | - if:
300 | condition:
301 | lambda: return ( id(fast_boot) >= 3 );
302 | then:
303 | - lambda: |-
304 | ESP_LOGD("athom-rgbct-light.yaml", "Now the counter is greater than or equal to 3, perform reset device and reboot");
305 | id(fast_boot) = 0;
306 | fast_boot->loop();
307 | global_preferences->sync();
308 | auto call = id(rgbct_light).turn_on();
309 | call.set_transition_length(500);
310 | call.set_brightness(1.0);
311 | call.set_color_mode(ColorMode::RGB);
312 | call.set_rgb(0.0, 0.0, 1.0);
313 | call.perform();
314 | - delay: 5s
315 | - button.press: Reset
316 | - lambda: |-
317 | id(fast_boot) += 1;
318 | fast_boot->loop();
319 | global_preferences->sync();
320 | ESP_LOGD("athom-rgbct-light.yaml", "Now the counter is %d. Reset the device when the counter is greater than or equal to 3", id(fast_boot));
321 | - delay: 10s
322 | - lambda: |-
323 | ESP_LOGD("athom-rgbct-light.yaml", "Reset counter");
324 | id(fast_boot) = 0;
325 | fast_boot->loop();
326 | global_preferences->sync();
327 |
--------------------------------------------------------------------------------
/athom-without-relay-plug.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | name: "athom-without-relay-plug"
3 | friendly_name: "Smart Plug"
4 | # Allows ESP device to be automatically lined to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
5 | room: ""
6 | device_description: "athom esp8285 without relay plug"
7 | project_name: "China Athom Technology.Athom Without Relay Plug"
8 | project_version: "v2.0.8"
9 | sensor_update_interval: "10s"
10 | # Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
11 | dns_domain: ".local"
12 | # Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
13 | timezone: ""
14 | # Set the duration between the sntp service polling ntp.org servers for an update
15 | sntp_update_interval: "6h"
16 | # Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
17 | sntp_server_1: "0.pool.ntp.org"
18 | sntp_server_2: "1.pool.ntp.org"
19 | sntp_server_3: "2.pool.ntp.org"
20 | # Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
21 | wifi_fast_connect: "false"
22 | # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
23 | log_level: "INFO"
24 | # Enable or disable the use of IPv6 networking on the device
25 | ipv6_enable: "false"
26 | # Hide the ENERGY sensor that shows kWh consumed, but with no time period associated with it. Resets when device restarted and reflashed.
27 | hide_energy_sensor: "false"
28 |
29 | esphome:
30 | name: "${name}"
31 | friendly_name: "${friendly_name}"
32 | comment: "${device_description}"
33 | area: "${room}"
34 | name_add_mac_suffix: true
35 | min_version: 2024.6.0
36 | project:
37 | name: "${project_name}"
38 | version: "${project_version}"
39 | platformio_options:
40 | board_upload.flash_size: 2MB
41 | board_upload.maximum_size: 2097152
42 | board_build.ldscript: eagle.flash.2m.ld
43 |
44 | esp8266:
45 | board: esp8285
46 | restore_from_flash: true
47 |
48 | preferences:
49 | flash_write_interval: 5min
50 |
51 | api:
52 |
53 | ota:
54 | - platform: esphome
55 |
56 | logger:
57 | level: ${log_level}
58 | baud_rate: 0
59 |
60 | web_server:
61 | port: 80
62 |
63 | network:
64 | enable_ipv6: ${ipv6_enable}
65 |
66 | wifi:
67 | # This spawns an AP with the device name and mac address with no password.
68 | ap: {}
69 | # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
70 | fast_connect: "${wifi_fast_connect}"
71 | # Define dns domain / suffix to add to hostname
72 | domain: "${dns_domain}"
73 |
74 | mdns:
75 | disabled: false
76 |
77 | captive_portal:
78 |
79 | dashboard_import:
80 | package_import_url: github://athom-tech/athom-configs/athom-without-relay-plug.yaml
81 |
82 | # Dentra Components - Adds 'Platform - Energy Statistics'
83 | # https://github.com/dentra/esphome-components/tree/master/components/energy_statistics
84 | # external_components:
85 | # - source: github://dentra/esphome-components
86 |
87 | uart:
88 | rx_pin: RX
89 | baud_rate: 4800
90 | parity: EVEN
91 |
92 | globals:
93 | - id: total_energy
94 | type: float
95 | restore_value: yes
96 | initial_value: '0.0'
97 |
98 | binary_sensor:
99 | - platform: status
100 | name: "Status"
101 | entity_category: diagnostic
102 |
103 | - platform: gpio
104 | pin:
105 | number: 5
106 | mode: INPUT_PULLUP
107 | inverted: true
108 | name: "Button"
109 | disabled_by_default: true
110 | on_multi_click:
111 | - timing:
112 | - ON for at least 4s
113 | then:
114 | - button.press: Reset
115 |
116 | sensor:
117 | - platform: uptime
118 | name: "Uptime Sensor"
119 | id: uptime_sensor
120 | entity_category: diagnostic
121 | internal: true
122 |
123 | # Reports the WiFi signal strength/RSSI in dB
124 | - platform: wifi_signal
125 | name: "WiFi Signal dB"
126 | id: wifi_signal_db
127 | update_interval: 60s
128 | entity_category: diagnostic
129 |
130 | # Reports the WiFi signal strength in %
131 | - platform: copy
132 | source_id: wifi_signal_db
133 | name: "WiFi Signal Percent"
134 | filters:
135 | - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
136 | unit_of_measurement: "%"
137 | entity_category: diagnostic
138 | device_class: ""
139 |
140 | - platform: cse7766
141 | id: athom_cse7766
142 | current:
143 | name: "Current"
144 | filters:
145 | - throttle_average: ${sensor_update_interval}
146 | - lambda: if (x < 0.060) return 0.0; else return x; #For the chip will report less than 3w power when no load is connected
147 |
148 | voltage:
149 | name: "Voltage"
150 | filters:
151 | - throttle_average: ${sensor_update_interval}
152 |
153 | power:
154 | name: "Power"
155 | id: power_sensor
156 | filters:
157 | - throttle_average: ${sensor_update_interval}
158 | - lambda: if (x < 3.0) return 0.0; else return x; #For the chip will report less than 3w power when no load is connected
159 |
160 | energy:
161 | name: "Energy"
162 | id: energy
163 | unit_of_measurement: kWh
164 | internal: ${hide_energy_sensor}
165 | filters:
166 | - throttle: ${sensor_update_interval}
167 | # Multiplication factor from W to kW is 0.001
168 | - multiply: 0.001
169 | on_value:
170 | then:
171 | - lambda: |-
172 | static float previous_energy_value = 0.0;
173 | float current_energy_value = id(energy).state;
174 | id(total_energy) += current_energy_value - previous_energy_value;
175 | previous_energy_value = current_energy_value;
176 | id(total_energy_sensor).update();
177 |
178 |
179 | apparent_power:
180 | name: "Apparent Power"
181 | filters:
182 | - throttle_average: ${sensor_update_interval}
183 | reactive_power:
184 | name: "Reactive Power"
185 | filters:
186 | - throttle_average: ${sensor_update_interval}
187 | power_factor:
188 | name: "Power Factor"
189 | filters:
190 | - throttle_average: ${sensor_update_interval}
191 |
192 | - platform: template
193 | name: "Total Energy"
194 | id: total_energy_sensor
195 | unit_of_measurement: kWh
196 | device_class: "energy"
197 | state_class: "total_increasing"
198 | icon: "mdi:lightning-bolt"
199 | accuracy_decimals: 3
200 | lambda: |-
201 | return id(total_energy);
202 | update_interval: ${sensor_update_interval}
203 |
204 | - platform: total_daily_energy
205 | name: "Total Energy Since Boot"
206 | restore: true
207 | power_id: power_sensor
208 | unit_of_measurement: kWh
209 | icon: mdi:hours-24
210 | accuracy_decimals: 3
211 | filters:
212 | - multiply: 0.001
213 |
214 | # # Dentra Components - Define the id of the sensor providing 'Total Energy' used
215 | # - platform: "energy_statistics"
216 | # total: total_energy_sensor
217 |
218 | # # Dentra Components - Adds Energy Today. Persistents if restarted, unlike 'total_daily_energy'
219 | # energy_today:
220 | # name: "Energy Today"
221 | # id: total_energy_today
222 | # accuracy_decimals: 3
223 | # icon: mdi:hours-24
224 |
225 | # # Dentra Components - Adds Energy Yesterday
226 | # energy_yesterday:
227 | # name: "Total Energy Yesterday"
228 | # id: total_energy_yesterday
229 | # accuracy_decimals: 3
230 |
231 | # # Dentra Components - Adds Energy Week
232 | # energy_week:
233 | # name: "Total Energy Week"
234 | # id: total_energy_week
235 | # accuracy_decimals: 3
236 |
237 | # # Dentra Components - Adds Energy Month
238 | # energy_month:
239 | # name: "Total Energy Month"
240 | # id: total_energy_month
241 | # accuracy_decimals: 3
242 |
243 | button:
244 | - platform: restart
245 | name: "Restart"
246 | entity_category: config
247 |
248 | - platform: factory_reset
249 | name: "Factory Reset"
250 | id: Reset
251 | entity_category: config
252 |
253 | - platform: safe_mode
254 | name: "Safe Mode"
255 | internal: false
256 | entity_category: config
257 |
258 | light:
259 | - platform: status_led
260 | name: "Status LED"
261 | id: blue_led
262 | disabled_by_default: true
263 | pin:
264 | inverted: true
265 | number: GPIO13
266 |
267 | text_sensor:
268 | - platform: wifi_info
269 | ip_address:
270 | name: "IP Address"
271 | entity_category: diagnostic
272 | ssid:
273 | name: "Connected SSID"
274 | entity_category: diagnostic
275 | mac_address:
276 | name: "Mac Address"
277 | entity_category: diagnostic
278 |
279 | # Creates a sensor showing when the device was last restarted
280 | - platform: template
281 | name: 'Last Restart'
282 | id: device_last_restart
283 | icon: mdi:clock
284 | entity_category: diagnostic
285 | # device_class: timestamp
286 |
287 | # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
288 | - platform: template
289 | name: "Uptime"
290 | entity_category: diagnostic
291 | lambda: |-
292 | int seconds = (id(uptime_sensor).state);
293 | int days = seconds / (24 * 3600);
294 | seconds = seconds % (24 * 3600);
295 | int hours = seconds / 3600;
296 | seconds = seconds % 3600;
297 | int minutes = seconds / 60;
298 | seconds = seconds % 60;
299 | if ( days > 3650 ) {
300 | return { "Starting up" };
301 | } else if ( days ) {
302 | return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
303 | } else if ( hours ) {
304 | return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
305 | } else if ( minutes ) {
306 | return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
307 | } else {
308 | return { (String(seconds) +"s").c_str() };
309 | }
310 | icon: mdi:clock-start
311 |
312 | time:
313 | - platform: sntp
314 | id: sntp_time
315 | # Define the timezone of the device
316 | timezone: "${timezone}"
317 | # Change sync interval from default 5min to 6 hours (or as set in substitutions)
318 | update_interval: ${sntp_update_interval}
319 | # Set specific sntp servers to use
320 | servers:
321 | - "${sntp_server_1}"
322 | - "${sntp_server_2}"
323 | - "${sntp_server_3}"
324 | # Publish the time the device was last restarted
325 | on_time_sync:
326 | then:
327 | # Update last restart time, but only once.
328 | - if:
329 | condition:
330 | lambda: 'return id(device_last_restart).state == "";'
331 | then:
332 | - text_sensor.template.publish:
333 | id: device_last_restart
334 | state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
335 |
--------------------------------------------------------------------------------
/athom-sw03.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | # Default name
3 | name: "athom-3gang-switch"
4 | # Default friendly name
5 | friendly_name: "3Gang Switch"
6 | # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
7 | room: ""
8 | # Description as appears in ESPHome & top of webserver page
9 | device_description: "athom 3gang switch"
10 | # Project Name
11 | project_name: "China Athom Technology.3Gang Switch"
12 | # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
13 | project_version: "v1.1.4"
14 | # Restore the relay (GPO switch) upon reboot to state:
15 | light1_restore_mode: RESTORE_DEFAULT_OFF
16 | light2_restore_mode: RESTORE_DEFAULT_OFF
17 | light3_restore_mode: RESTORE_DEFAULT_OFF
18 | # Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
19 | dns_domain: ".local"
20 | # Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
21 | timezone: ""
22 | # Set the duration between the sntp service polling ntp.org servers for an update
23 | sntp_update_interval: 6h
24 | # Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
25 | sntp_server_1: "0.pool.ntp.org"
26 | sntp_server_2: "1.pool.ntp.org"
27 | sntp_server_3: "2.pool.ntp.org"
28 | # Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
29 | wifi_fast_connect: "false"
30 | # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
31 | log_level: "DEBUG"
32 | # Enable or disable the use of IPv6 networking on the device
33 | ipv6_enable: "false"
34 |
35 | esphome:
36 | name: "${name}"
37 | friendly_name: "${friendly_name}"
38 | comment: "${device_description}"
39 | area: "${room}"
40 | name_add_mac_suffix: true
41 | min_version: 2024.6.0
42 | project:
43 | name: "${project_name}"
44 | version: "${project_version}"
45 | platformio_options:
46 | board_upload.flash_size: 2MB
47 | board_upload.maximum_size: 2097152
48 | board_build.ldscript: eagle.flash.2m.ld
49 | on_boot:
50 | - priority: 600
51 | then:
52 | - select.set_index:
53 | id: power_mode
54 | index: !lambda |-
55 | return id(restore_mode)-1;
56 | - lambda: |-
57 | switch(id(restore_mode))
58 | {
59 | case 1:{
60 | id(light1).turn_off();
61 | id(light2).turn_off();
62 | id(light3).turn_off();
63 | break;
64 | }
65 | case 2:{
66 | id(light1).turn_on();
67 | id(light2).turn_on();
68 | id(light3).turn_on();
69 | break;
70 | }
71 | default:{
72 | break;
73 | }
74 | }
75 |
76 | esp8266:
77 | board: esp8285
78 | restore_from_flash: true
79 |
80 | preferences:
81 | flash_write_interval: 1min
82 |
83 | api:
84 |
85 | ota:
86 | - platform: esphome
87 |
88 | logger:
89 | level: ${log_level}
90 | baud_rate: 115200
91 |
92 | web_server:
93 | port: 80
94 |
95 | network:
96 | enable_ipv6: ${ipv6_enable}
97 |
98 | wifi:
99 | # This spawns an AP with the device name and mac address with no password.
100 | ap: {}
101 | # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
102 | fast_connect: "${wifi_fast_connect}"
103 | # Define dns domain / suffix to add to hostname
104 | domain: "${dns_domain}"
105 |
106 | mdns:
107 | disabled: false
108 |
109 | captive_portal:
110 |
111 | dashboard_import:
112 | package_import_url: github://athom-tech/athom-configs/athom-sw03.yaml
113 |
114 | globals:
115 | - id: restore_mode
116 | type: int
117 | restore_value: yes
118 | initial_value: "3"
119 |
120 | select:
121 | - platform: template
122 | name: "Power On State"
123 | id: "power_mode"
124 | optimistic: true
125 | options:
126 | - Always Off
127 | - Always On
128 | - Restore Power Off State
129 | on_value:
130 | then:
131 | - lambda: |-
132 | id(restore_mode)=i+1;
133 |
134 | binary_sensor:
135 | - platform: status
136 | name: "Status"
137 | entity_category: diagnostic
138 |
139 | # Touch Buttons
140 | - platform: gpio
141 | pin:
142 | inverted: true
143 | number: GPIO12
144 | mode:
145 | input: true
146 | pullup: true
147 | name: "Button1"
148 | id: button1
149 | disabled_by_default: true
150 | on_multi_click:
151 | - timing:
152 | - ON for at most 0.5s
153 | - OFF for at least 0.2s
154 | then:
155 | - light.toggle: light1
156 | - timing:
157 | - ON for at least 4s
158 | then:
159 | - button.press: Reset
160 |
161 | - platform: gpio
162 | pin:
163 | inverted: true
164 | number: GPIO3
165 | mode:
166 | input: true
167 | pullup: true
168 | name: "Button2"
169 | id: button2
170 | disabled_by_default: true
171 | on_click:
172 | max_length: 0.5s
173 | then:
174 | - light.toggle: light2
175 |
176 | - platform: gpio
177 | pin:
178 | inverted: true
179 | number: GPIO5
180 | mode:
181 | input: true
182 | pullup: true
183 | name: "Button3"
184 | id: button3
185 | disabled_by_default: true
186 | on_click:
187 | max_length: 0.5s
188 | then:
189 | - light.toggle: light3
190 |
191 | sensor:
192 | - platform: uptime
193 | name: "Uptime Sensor"
194 | id: uptime_sensor
195 | entity_category: diagnostic
196 | internal: true
197 |
198 | - platform: wifi_signal
199 | name: "WiFi Signal dB"
200 | id: wifi_signal_db
201 | update_interval: 60s
202 | entity_category: "diagnostic"
203 |
204 | - platform: copy
205 | source_id: wifi_signal_db
206 | name: "WiFi Signal Percent"
207 | filters:
208 | - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
209 | unit_of_measurement: "Signal %"
210 | entity_category: "diagnostic"
211 | device_class: ""
212 |
213 | button:
214 | - platform: restart
215 | name: "Restart"
216 | entity_category: config
217 |
218 | - platform: factory_reset
219 | name: "Factory Reset"
220 | id: Reset
221 | entity_category: config
222 |
223 | - platform: safe_mode
224 | name: "Safe Mode"
225 | internal: false
226 | entity_category: config
227 |
228 | output:
229 | # Relays
230 | - platform: gpio
231 | pin: GPIO13
232 | id: relay1
233 | - platform: gpio
234 | pin: GPIO4
235 | id: relay2
236 | - platform: gpio
237 | pin: GPIO15
238 | id: relay3
239 |
240 | # Button LEDs (1.0 = Blue / 0.0 = Red)
241 | - platform: esp8266_pwm
242 | pin: GPIO16
243 | inverted: true
244 | id: button_led1
245 | - platform: esp8266_pwm
246 | pin: GPIO14
247 | inverted: true
248 | id: button_led2
249 | - platform: esp8266_pwm
250 | pin: GPIO1
251 | inverted: true
252 | id: button_led3
253 |
254 | light:
255 | - platform: status_led
256 | name: "Status LED"
257 | disabled_by_default: true
258 | pin:
259 | number: GPIO0
260 | inverted: true
261 |
262 | # Relays
263 | - platform: binary
264 | name: "Light1"
265 | id: light1
266 | output: relay1
267 | restore_mode: ${light1_restore_mode}
268 | on_turn_on:
269 | - light.turn_on: led1
270 | on_turn_off:
271 | - light.turn_off: led1
272 |
273 | - platform: binary
274 | name: "Light2"
275 | id: light2
276 | output: relay2
277 | restore_mode: ${light2_restore_mode}
278 | on_turn_on:
279 | - light.turn_on: led2
280 | on_turn_off:
281 | - light.turn_off: led2
282 |
283 | - platform: binary
284 | name: "Light3"
285 | id: light3
286 | output: relay3
287 | restore_mode: ${light3_restore_mode}
288 | on_turn_on:
289 | - light.turn_on: led3
290 | on_turn_off:
291 | - light.turn_off: led3
292 |
293 | # Button LEDs
294 | - platform: monochromatic
295 | name: "LED1"
296 | disabled_by_default: true
297 | id: led1
298 | output: button_led1
299 | default_transition_length: 500ms
300 | - platform: monochromatic
301 | name: "LED2"
302 | disabled_by_default: true
303 | id: led2
304 | output: button_led2
305 | default_transition_length: 500ms
306 | - platform: monochromatic
307 | name: "LED3"
308 | disabled_by_default: true
309 | id: led3
310 | output: button_led3
311 | default_transition_length: 500ms
312 |
313 | text_sensor:
314 | - platform: wifi_info
315 | ip_address:
316 | name: "IP Address"
317 | entity_category: diagnostic
318 | ssid:
319 | name: "Connected SSID"
320 | entity_category: diagnostic
321 | mac_address:
322 | name: "Mac Address"
323 | entity_category: diagnostic
324 |
325 | # Creates a sensor showing when the device was last restarted
326 | - platform: template
327 | name: 'Last Restart'
328 | id: device_last_restart
329 | icon: mdi:clock
330 | entity_category: diagnostic
331 | # device_class: timestamp
332 |
333 | # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
334 | - platform: template
335 | name: "Uptime"
336 | entity_category: diagnostic
337 | lambda: |-
338 | int seconds = (id(uptime_sensor).state);
339 | int days = seconds / (24 * 3600);
340 | seconds = seconds % (24 * 3600);
341 | int hours = seconds / 3600;
342 | seconds = seconds % 3600;
343 | int minutes = seconds / 60;
344 | seconds = seconds % 60;
345 | if ( days > 3650 ) {
346 | return { "Starting up" };
347 | } else if ( days ) {
348 | return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
349 | } else if ( hours ) {
350 | return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
351 | } else if ( minutes ) {
352 | return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
353 | } else {
354 | return { (String(seconds) +"s").c_str() };
355 | }
356 | icon: mdi:clock-start
357 |
358 | time:
359 | - platform: sntp
360 | id: sntp_time
361 | # Define the timezone of the device
362 | timezone: "${timezone}"
363 | # Change sync interval from default 5min to 6 hours (or as set in substitutions)
364 | update_interval: ${sntp_update_interval}
365 | # Set specific sntp servers to use
366 | servers:
367 | - "${sntp_server_1}"
368 | - "${sntp_server_2}"
369 | - "${sntp_server_3}"
370 | # Publish the time the device was last restarted
371 | on_time_sync:
372 | then:
373 | # Update last restart time, but only once.
374 | - if:
375 | condition:
376 | lambda: 'return id(device_last_restart).state == "";'
377 | then:
378 | - text_sensor.template.publish:
379 | id: device_last_restart
380 | state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
381 |
--------------------------------------------------------------------------------
/athom-wall-outlet.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | name: "athom-wall-outlet"
3 | friendly_name: "Athom Wall Outlet"
4 | # Allows ESP device to be automatically lined to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
5 | room: ""
6 | device_description: "athom wall outlet"
7 | project_name: "China Athom Technology.Athom Wall Outlet"
8 | project_version: "v1.1.5"
9 | sensor_update_interval: "10s"
10 | relay_restore_mode: RESTORE_DEFAULT_OFF
11 | # Current Limit in Amps. AU Plug = 10. IL, BR, EU, UK, US Plug = 16.
12 | current_limit : "16"
13 | # Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
14 | dns_domain: ".local"
15 | # Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
16 | timezone: ""
17 | # Set the duration between the sntp service polling ntp.org servers for an update
18 | sntp_update_interval: "6h"
19 | # Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
20 | sntp_server_1: "0.pool.ntp.org"
21 | sntp_server_2: "1.pool.ntp.org"
22 | sntp_server_3: "2.pool.ntp.org"
23 | # Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
24 | wifi_fast_connect: "false"
25 | # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
26 | log_level: "INFO"
27 | # Enable or disable the use of IPv6 networking on the device
28 | ipv6_enable: "false"
29 | # Hide the ENERGY sensor that shows kWh consumed, but with no time period associated with it. Resets when device restarted and reflashed.
30 | hide_energy_sensor: "true"
31 |
32 | esphome:
33 | name: "${name}"
34 | friendly_name: "${friendly_name}"
35 | comment: "${device_description}"
36 | area: "${room}"
37 | name_add_mac_suffix: true
38 | min_version: 2024.6.0
39 | project:
40 | name: "${project_name}"
41 | version: "${project_version}"
42 | platformio_options:
43 | board_upload.flash_size: 2MB
44 | board_upload.maximum_size: 2097152
45 | board_build.ldscript: eagle.flash.2m.ld
46 | on_boot:
47 | - priority: 600
48 | then:
49 | - select.set_index:
50 | id: power_mode
51 | index: !lambda |-
52 | return id(restore_mode)-1;
53 | - lambda: |-
54 | switch(id(restore_mode))
55 | {
56 | case 1:{
57 | id(relay).turn_off();
58 | break;
59 | }
60 | case 2:{
61 | id(relay).turn_on();
62 | break;
63 | }
64 | default:{
65 | break;
66 | }
67 | }
68 |
69 | esp8266:
70 | board: esp8285
71 | restore_from_flash: true
72 |
73 | preferences:
74 | flash_write_interval: 5min
75 |
76 | api:
77 |
78 | ota:
79 | - platform: esphome
80 |
81 | logger:
82 | baud_rate: 0
83 |
84 | web_server:
85 | port: 80
86 |
87 | network:
88 | enable_ipv6: ${ipv6_enable}
89 |
90 | wifi:
91 | # This spawns an AP with the device name and mac address with no password.
92 | ap: {}
93 | # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
94 | fast_connect: "${wifi_fast_connect}"
95 | # Define dns domain / suffix to add to hostname
96 | domain: "${dns_domain}"
97 |
98 | mdns:
99 | disabled: false
100 |
101 | captive_portal:
102 |
103 | dashboard_import:
104 | package_import_url: github://athom-tech/athom-configs/athom-wall-outlet.yaml
105 |
106 | uart:
107 | rx_pin: RX
108 | baud_rate: 4800
109 | parity: EVEN
110 |
111 | globals:
112 | - id: total_energy
113 | type: float
114 | restore_value: yes
115 | initial_value: '0.0'
116 |
117 | - id: restore_mode
118 | type: int
119 | restore_value: yes
120 | initial_value: "3"
121 |
122 | select:
123 | - platform: template
124 | name: "Power On State"
125 | id: "power_mode"
126 | optimistic: true
127 | options:
128 | - Always Off
129 | - Always On
130 | - Restore Power Off State
131 | on_value:
132 | then:
133 | - lambda: |-
134 | id(restore_mode)=i+1;
135 |
136 | binary_sensor:
137 | - platform: status
138 | name: "Status"
139 | entity_category: diagnostic
140 |
141 | - platform: gpio
142 | pin:
143 | number: 5
144 | mode: INPUT_PULLUP
145 | inverted: true
146 | name: "Power Button"
147 | disabled_by_default: true
148 | on_multi_click:
149 | - timing:
150 | - ON for at most 1s
151 | - OFF for at least 0.2s
152 | then:
153 | - switch.toggle: relay
154 | - timing:
155 | - ON for at least 4s
156 | then:
157 | - button.press: Reset
158 |
159 | sensor:
160 | - platform: uptime
161 | name: "Uptime Sensor"
162 | id: uptime_sensor
163 | entity_category: diagnostic
164 | internal: true
165 |
166 | # Reports the WiFi signal strength/RSSI in dB
167 | - platform: wifi_signal
168 | name: "WiFi Signal dB"
169 | id: wifi_signal_db
170 | update_interval: 60s
171 | entity_category: diagnostic
172 |
173 | # Reports the WiFi signal strength in %
174 | - platform: copy
175 | source_id: wifi_signal_db
176 | name: "WiFi Signal Percent"
177 | filters:
178 | - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
179 | unit_of_measurement: "%"
180 | entity_category: diagnostic
181 | device_class: ""
182 |
183 | - platform: cse7766
184 | id: athom_cse7766
185 | current:
186 | name: "Current"
187 | filters:
188 | - throttle_average: ${sensor_update_interval}
189 | - lambda: if (x < 0.060) return 0.0; else return x; #For the chip will report less than 3w power when no load is connected
190 | on_value_range:
191 | - above: ${current_limit}
192 | then:
193 | - switch.turn_off: relay
194 |
195 | voltage:
196 | name: "Voltage"
197 | filters:
198 | - throttle_average: ${sensor_update_interval}
199 |
200 | power:
201 | name: "Power"
202 | id: power_sensor
203 | filters:
204 | - throttle_average: ${sensor_update_interval}
205 | - lambda: if (x < 3.0) return 0.0; else return x; #For the chip will report less than 3w power when no load is connected
206 |
207 | energy:
208 | name: "Energy"
209 | id: energy
210 | unit_of_measurement: kWh
211 | filters:
212 | - throttle: ${sensor_update_interval}
213 | # Multiplication factor from W to kW is 0.001
214 | - multiply: 0.001
215 | on_value:
216 | then:
217 | - lambda: |-
218 | static float previous_energy_value = 0.0;
219 | float current_energy_value = id(energy).state;
220 | id(total_energy) += current_energy_value - previous_energy_value;
221 | previous_energy_value = current_energy_value;
222 | id(total_energy_sensor).update();
223 | # internal: ${hide_energy_sensor}
224 |
225 | apparent_power:
226 | name: "Apparent Power"
227 | filters:
228 | - throttle_average: ${sensor_update_interval}
229 | reactive_power:
230 | name: "Reactive Power"
231 | filters:
232 | - throttle_average: ${sensor_update_interval}
233 | power_factor:
234 | name: "Power Factor"
235 | filters:
236 | - throttle_average: ${sensor_update_interval}
237 |
238 | - platform: template
239 | name: "Total Energy"
240 | id: total_energy_sensor
241 | unit_of_measurement: kWh
242 | device_class: "energy"
243 | state_class: "total_increasing"
244 | icon: "mdi:lightning-bolt"
245 | accuracy_decimals: 3
246 | lambda: |-
247 | return id(total_energy);
248 | update_interval: ${sensor_update_interval}
249 |
250 | - platform: total_daily_energy
251 | name: "Total Energy Since Boot"
252 | restore: true
253 | power_id: power_sensor
254 | unit_of_measurement: kWh
255 | icon: mdi:hours-24
256 | accuracy_decimals: 3
257 | filters:
258 | - multiply: 0.001
259 |
260 | # # Dentra Components - Define the id of the sensor providing 'Total Energy' used
261 | # - platform: "energy_statistics"
262 | # total: total_energy_sensor
263 |
264 | # # Dentra Components - Adds Energy Today. Persistents if restarted, unlike 'total_daily_energy'
265 | # energy_today:
266 | # name: "Energy Today"
267 | # id: total_energy_today
268 | # accuracy_decimals: 3
269 | # icon: mdi:hours-24
270 |
271 | # # Dentra Components - Adds Energy Yesterday
272 | # energy_yesterday:
273 | # name: "Total Energy Yesterday"
274 | # id: total_energy_yesterday
275 | # accuracy_decimals: 3
276 |
277 | # # Dentra Components - Adds Energy Week
278 | # energy_week:
279 | # name: "Total Energy Week"
280 | # id: total_energy_week
281 | # accuracy_decimals: 3
282 |
283 | # # Dentra Components - Adds Energy Month
284 | # energy_month:
285 | # name: "Total Energy Month"
286 | # id: total_energy_month
287 | # accuracy_decimals: 3
288 |
289 | button:
290 | - platform: restart
291 | name: "Restart"
292 | entity_category: config
293 |
294 | - platform: factory_reset
295 | name: "Factory Reset"
296 | id: Reset
297 | entity_category: config
298 |
299 | - platform: safe_mode
300 | name: "Safe Mode"
301 | internal: false
302 | entity_category: config
303 |
304 | switch:
305 | - platform: gpio
306 | name: "Switch"
307 | pin: GPIO12
308 | id: relay
309 | restore_mode: ${relay_restore_mode}
310 | on_turn_on:
311 | - light.turn_on: red_led
312 | on_turn_off:
313 | - light.turn_off: red_led
314 |
315 | light:
316 | - platform: status_led
317 | name: "Status LED"
318 | id: red_led
319 | disabled_by_default: true
320 | pin:
321 | inverted: true
322 | number: GPIO13
323 |
324 | text_sensor:
325 | - platform: wifi_info
326 | ip_address:
327 | name: "IP Address"
328 | entity_category: diagnostic
329 | ssid:
330 | name: "Connected SSID"
331 | entity_category: diagnostic
332 | mac_address:
333 | name: "Mac Address"
334 | entity_category: diagnostic
335 |
336 | # Creates a sensor showing when the device was last restarted
337 | - platform: template
338 | name: 'Last Restart'
339 | id: device_last_restart
340 | icon: mdi:clock
341 | entity_category: diagnostic
342 | # device_class: timestamp
343 |
344 | # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
345 | - platform: template
346 | name: "Uptime"
347 | entity_category: diagnostic
348 | lambda: |-
349 | int seconds = (id(uptime_sensor).state);
350 | int days = seconds / (24 * 3600);
351 | seconds = seconds % (24 * 3600);
352 | int hours = seconds / 3600;
353 | seconds = seconds % 3600;
354 | int minutes = seconds / 60;
355 | seconds = seconds % 60;
356 | if ( days > 3650 ) {
357 | return { "Starting up" };
358 | } else if ( days ) {
359 | return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
360 | } else if ( hours ) {
361 | return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
362 | } else if ( minutes ) {
363 | return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
364 | } else {
365 | return { (String(seconds) +"s").c_str() };
366 | }
367 | icon: mdi:clock-start
368 |
369 | time:
370 | - platform: sntp
371 | id: sntp_time
372 | # Define the timezone of the device
373 | timezone: "${timezone}"
374 | # Change sync interval from default 5min to 6 hours (or as set in substitutions)
375 | update_interval: ${sntp_update_interval}
376 | # Set specific sntp servers to use
377 | servers:
378 | - "${sntp_server_1}"
379 | - "${sntp_server_2}"
380 | - "${sntp_server_3}"
381 | # Publish the time the device was last restarted
382 | on_time_sync:
383 | then:
384 | # Update last restart time, but only once.
385 | - if:
386 | condition:
387 | lambda: 'return id(device_last_restart).state == "";'
388 | then:
389 | - text_sensor.template.publish:
390 | id: device_last_restart
391 | state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
392 |
--------------------------------------------------------------------------------
/athom-smart-plug-v2.yaml:
--------------------------------------------------------------------------------
1 | substitutions:
2 | name: "athom-smart-plug-v2"
3 | friendly_name: "Smart Plug V2"
4 | # Allows ESP device to be automatically lined to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
5 | room: ""
6 | device_description: "athom smart plug v2"
7 | project_name: "China Athom Technology.Athom Plug V2"
8 | project_version: "v2.0.8"
9 | sensor_update_interval: "10s"
10 | relay_restore_mode: RESTORE_DEFAULT_ON
11 | # Current Limit in Amps. AU Plug = 10. IL, BR, EU, UK, US Plug = 16.
12 | current_limit : "16"
13 | # Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
14 | dns_domain: ".local"
15 | # Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
16 | timezone: ""
17 | # Set the duration between the sntp service polling ntp.org servers for an update
18 | sntp_update_interval: "6h"
19 | # Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
20 | sntp_server_1: "0.pool.ntp.org"
21 | sntp_server_2: "1.pool.ntp.org"
22 | sntp_server_3: "2.pool.ntp.org"
23 | # Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
24 | wifi_fast_connect: "false"
25 | # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
26 | log_level: "INFO"
27 | # Enable or disable the use of IPv6 networking on the device
28 | ipv6_enable: "false"
29 | # Hide the ENERGY sensor that shows kWh consumed, but with no time period associated with it. Resets when device restarted and reflashed.
30 | hide_energy_sensor: "false"
31 | # Specifies whether pins should be initialised as early as possible to known values. Recommended value is false where switches are involved, as these will toggle when updating the firmware or when restarting the device. Defaults to true.
32 | early_pin_init: "true"
33 | # Power plug icon selection. Change to reflect the type/country of powr plug in use, this will update the power plug icon shown next to the switch
34 | power_plug_type: "power-socket-us" # Options: power-socket-au | power-socket-ch | power-socket-de | power-socket-eu | power-socket-fr | power-socket-it | power-socket-jp | power-socket-uk | power-socket-us |
35 |
36 |
37 | ########################## End of Substitutions #########################
38 |
39 | esphome:
40 | name: "${name}"
41 | friendly_name: "${friendly_name}"
42 | comment: "${device_description}"
43 | area: "${room}"
44 | name_add_mac_suffix: true
45 | min_version: 2024.6.0
46 | project:
47 | name: "${project_name}"
48 | version: "${project_version}"
49 | platformio_options:
50 | board_upload.flash_size: 2MB
51 | board_upload.maximum_size: 2097152
52 | board_build.ldscript: eagle.flash.2m.ld
53 | on_boot:
54 | - priority: 600
55 | then:
56 | - select.set_index:
57 | id: power_mode
58 | index: !lambda |-
59 | return id(restore_mode)-1;
60 | - lambda: |-
61 | switch(id(restore_mode))
62 | {
63 | case 1:{
64 | id(relay).turn_off();
65 | break;
66 | }
67 | case 2:{
68 | id(relay).turn_on();
69 | break;
70 | }
71 | default:{
72 | break;
73 | }
74 | }
75 |
76 | esp8266:
77 | board: esp8285
78 | restore_from_flash: true
79 | early_pin_init: ${early_pin_init}
80 |
81 | preferences:
82 | flash_write_interval: 5min
83 |
84 | api:
85 |
86 | ota:
87 | - platform: esphome
88 |
89 | logger:
90 | level: ${log_level}
91 | baud_rate: 0
92 |
93 | web_server:
94 | port: 80
95 | # version: 3
96 |
97 | network:
98 | enable_ipv6: ${ipv6_enable}
99 |
100 | wifi:
101 | # This spawns an AP with the device name and mac address with no password.
102 | ap: {}
103 | # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
104 | fast_connect: "${wifi_fast_connect}"
105 | # Define dns domain / suffix to add to hostname
106 | domain: "${dns_domain}"
107 |
108 | mdns:
109 | disabled: false
110 |
111 | captive_portal:
112 |
113 | dashboard_import:
114 | package_import_url: github://athom-tech/athom-configs/athom-smart-plug-v2.yaml
115 |
116 | # Dentra Components - Adds 'Platform - Energy Statistics'
117 | # https://github.com/dentra/esphome-components/tree/master/components/energy_statistics
118 | # external_components:
119 | # - source: github://dentra/esphome-components
120 |
121 | uart:
122 | rx_pin: RX
123 | baud_rate: 4800
124 | parity: EVEN
125 |
126 | globals:
127 | - id: total_energy
128 | type: float
129 | restore_value: yes
130 | initial_value: '0.0'
131 | - id: restore_mode
132 | type: int
133 | restore_value: yes
134 | initial_value: "2" # 0 = Always_Off. 1 = Restore_Power_Off. 2 = Always_On.
135 |
136 | select:
137 | - platform: template
138 | name: "Power On State"
139 | id: "power_mode"
140 | optimistic: true
141 | icon: mdi:electric-switch
142 | options:
143 | - Always Off
144 | - Always On
145 | - Restore Power Off State
146 | on_value:
147 | then:
148 | - lambda: |-
149 | id(restore_mode)=i+1;
150 |
151 | binary_sensor:
152 | - platform: status
153 | name: "Status"
154 | icon: mdi:check-network-outline
155 | entity_category: diagnostic
156 |
157 | - platform: gpio
158 | pin:
159 | number: 5
160 | mode: INPUT_PULLUP
161 | inverted: true
162 | id: power_button
163 | name: "Power Button"
164 | disabled_by_default: true
165 | on_multi_click:
166 | - timing:
167 | - ON for at most 1s
168 | - OFF for at least 0.2s
169 | then:
170 | - switch.toggle: relay
171 | - timing:
172 | - ON for at least 4s
173 | then:
174 | - button.press: Reset
175 |
176 | sensor:
177 | - platform: uptime
178 | name: "Uptime Sensor"
179 | id: uptime_sensor
180 | entity_category: diagnostic
181 | internal: true
182 |
183 | # Reports the WiFi signal strength/RSSI in dB
184 | - platform: wifi_signal
185 | name: "WiFi Signal dB"
186 | id: wifi_signal_db
187 | update_interval: 60s
188 | entity_category: diagnostic
189 |
190 | # Reports the WiFi signal strength in %
191 | - platform: copy
192 | source_id: wifi_signal_db
193 | name: "WiFi Signal Percent"
194 | filters:
195 | - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
196 | unit_of_measurement: "%"
197 | entity_category: diagnostic
198 | device_class: ""
199 |
200 | # CSE7766 power monitoring chip
201 | - platform: cse7766
202 | id: athom_cse7766
203 | current:
204 | name: "Current"
205 | id: plug_current # Added ID so we can reference this in other sensors
206 | icon: mdi:current-ac
207 | filters:
208 | - throttle_average: ${sensor_update_interval}
209 | - lambda: if (x < 0.060) return 0.0; else return x; # For the chip will report less than 3w power when no load is connected
210 | on_value_range:
211 | - above: ${current_limit}
212 | then:
213 | - switch.turn_off: relay
214 |
215 | voltage:
216 | name: "Voltage"
217 | id: plug_voltage # Added ID so we can reference this in other sensors
218 | icon: mdi:sine-wave
219 | filters:
220 | - throttle_average: ${sensor_update_interval}
221 |
222 | power:
223 | name: "Power"
224 | id: power_sensor
225 | icon: mdi:power
226 | filters:
227 | - throttle_average: ${sensor_update_interval}
228 | - lambda: if (x < 3.0) return 0.0; else return x; # For the chip will report less than 3w power when no load is connected
229 |
230 | energy:
231 | name: "Energy"
232 | id: energy
233 | icon: mdi:lightning-bolt
234 | unit_of_measurement: kWh
235 | internal: ${hide_energy_sensor}
236 | filters:
237 | - throttle: ${sensor_update_interval}
238 | # Multiplication factor from W to kW is 0.001
239 | - multiply: 0.001
240 | on_value:
241 | then:
242 | - lambda: |-
243 | static float previous_energy_value = 0.0;
244 | float current_energy_value = id(energy).state;
245 | id(total_energy) += current_energy_value - previous_energy_value;
246 | previous_energy_value = current_energy_value;
247 | id(total_energy_sensor).update();
248 |
249 | apparent_power:
250 | name: "Apparent Power"
251 | icon: mdi:power
252 | filters:
253 | - throttle_average: ${sensor_update_interval}
254 |
255 | reactive_power:
256 | name: "Reactive Power"
257 | icon: mdi:flash
258 | filters:
259 | - throttle_average: ${sensor_update_interval}
260 |
261 | power_factor:
262 | name: "Power Factor"
263 | icon: mdi:percent-outline
264 | filters:
265 | - throttle_average: ${sensor_update_interval}
266 |
267 | - platform: template
268 | name: "Total Energy"
269 | id: total_energy_sensor
270 | unit_of_measurement: kWh
271 | device_class: "energy"
272 | state_class: "total_increasing"
273 | icon: mdi:lightning-bolt
274 | accuracy_decimals: 3
275 | lambda: |-
276 | return id(total_energy);
277 | update_interval: ${sensor_update_interval}
278 |
279 | - platform: total_daily_energy
280 | name: "Total Energy Since Boot"
281 | restore: true
282 | power_id: power_sensor
283 | unit_of_measurement: kWh
284 | icon: mdi:hours-24
285 | accuracy_decimals: 3
286 | filters:
287 | - multiply: 0.001
288 |
289 | # # Dentra Components - Define the id of the sensor providing 'Total Energy' used
290 | # - platform: "energy_statistics"
291 | # total: total_energy_sensor
292 |
293 | # # Dentra Components - Adds Energy Today. Persistents if restarted, unlike 'total_daily_energy'
294 | # energy_today:
295 | # name: "Energy Today"
296 | # id: total_energy_today
297 | # accuracy_decimals: 3
298 | # icon: mdi:hours-24
299 |
300 | # # Dentra Components - Adds Energy Yesterday
301 | # energy_yesterday:
302 | # name: "Total Energy Yesterday"
303 | # id: total_energy_yesterday
304 | # icon: mdi:calendar-today
305 | # accuracy_decimals: 3
306 |
307 | # # Dentra Components - Adds Energy Week
308 | # energy_week:
309 | # name: "Total Energy Week"
310 | # id: total_energy_week
311 | # icon: mdi:calendar-week
312 | # accuracy_decimals: 3
313 |
314 | # # Dentra Components - Adds Energy Month
315 | # energy_month:
316 | # name: "Total Energy Month"
317 | # id: total_energy_month
318 | # accuracy_decimals: 3
319 | # icon: mdi:calendar-month
320 |
321 | button:
322 | - platform: restart
323 | name: "Restart"
324 | entity_category: config
325 |
326 | - platform: factory_reset
327 | name: "Factory Reset"
328 | id: Reset
329 | entity_category: config
330 |
331 | - platform: safe_mode
332 | name: "Safe Mode"
333 | internal: false
334 | entity_category: config
335 |
336 | switch:
337 | - platform: gpio
338 | name: "Switch"
339 | pin: GPIO12
340 | id: relay
341 | restore_mode: ${relay_restore_mode}
342 | icon: mdi:${power_plug_type}
343 |
344 | light:
345 | - platform: status_led
346 | name: "Status LED"
347 | id: blue_led
348 | icon: mdi:lightbulb-outline
349 | disabled_by_default: true
350 | pin:
351 | inverted: true
352 | number: GPIO13
353 |
354 | text_sensor:
355 | - platform: wifi_info
356 | ip_address:
357 | name: "IP Address"
358 | icon: mdi:ip-network
359 | entity_category: diagnostic
360 | ssid:
361 | name: "Connected SSID"
362 | icon: mdi:wifi-strength-2
363 | entity_category: diagnostic
364 | mac_address:
365 | name: "Mac Address"
366 | icon: mdi:network-pos
367 | entity_category: diagnostic
368 |
369 | # Creates a sensor showing when the device was last restarted
370 | - platform: template
371 | name: 'Last Restart'
372 | id: device_last_restart
373 | icon: mdi:clock
374 | entity_category: diagnostic
375 | # device_class: timestamp
376 |
377 | # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
378 | - platform: template
379 | name: "Uptime"
380 | entity_category: diagnostic
381 | lambda: |-
382 | int seconds = (id(uptime_sensor).state);
383 | int days = seconds / (24 * 3600);
384 | seconds = seconds % (24 * 3600);
385 | int hours = seconds / 3600;
386 | seconds = seconds % 3600;
387 | int minutes = seconds / 60;
388 | seconds = seconds % 60;
389 | if ( days > 3650 ) {
390 | return { "Starting up" };
391 | } else if ( days ) {
392 | return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
393 | } else if ( hours ) {
394 | return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
395 | } else if ( minutes ) {
396 | return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
397 | } else {
398 | return { (String(seconds) +"s").c_str() };
399 | }
400 | icon: mdi:clock-start
401 |
402 | time:
403 | - platform: sntp
404 | id: sntp_time
405 | # Define the timezone of the device
406 | timezone: "${timezone}"
407 | # Change sync interval from default 5min to 6 hours (or as set in substitutions)
408 | update_interval: ${sntp_update_interval}
409 | # Set specific sntp servers to use
410 | servers:
411 | - "${sntp_server_1}"
412 | - "${sntp_server_2}"
413 | - "${sntp_server_3}"
414 | # Publish the time the device was last restarted
415 | on_time_sync:
416 | then:
417 | # Update last restart time, but only once.
418 | - if:
419 | condition:
420 | lambda: 'return id(device_last_restart).state == "";'
421 | then:
422 | - text_sensor.template.publish:
423 | id: device_last_restart
424 | state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
425 |
--------------------------------------------------------------------------------