-
Notifications
You must be signed in to change notification settings - Fork 2
/
homebridge-ratgdo.yaml
134 lines (111 loc) · 4.48 KB
/
homebridge-ratgdo.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# This is a customized configuration YAML file for [homebridge-ratgdo](https://github.com/hjdhjd/homebridge-ratgdo) that deviates slightly from the
# default YAML provided by Ratgdo ESPHome. It is specific to those with Ratgdo hardware revisions of 2.5 or greater. For those running other hardware
# versions, you can use this as a basis for your own, but it is beyond the support I will be providing.
#
# The changes in this configuration file include:
#
# - The ability to customize the name (and friendly name) of the Ratgdo device. Though cosmetic, it can be helpful when you have multiple Ratgdo devices.
# - Uses SNTP to set the time on the Ratgdo device. Not strictly necessary, but good hygeine.
# - Allows you to configure the timezone either yourself or automatically. The timezone will be autoconfigured using the World Time API geoIP by default.
# - Set the interval to check for updates from the Ratgdo repository to every 6 hours instead of the Ratgdo default of every second.
#
# You can customize the settings to your taste in the substitutions section. On macOS, you can install this configuration file using the following
# command:
#
# ```sh
# brew install esphome
# esphome run homebridge-ratgdo.yaml --no-logs --device 1.2.3.4
# ```
#
# To install the ESPHome tools on macOS (assuming you use [Homebrew](https://brew.sh):
#
# ```sh
# brew install esphome
# ```
#
# For other platforms, you can search online for how to install the ESPHome tools.
---
substitutions:
# Unique name for this Ratgdo ESPHome device. Must be no more than 31 characters or 24 characters if you append the MAC address to the name below.
name: "homebridge-ratgdo"
# Append the MAC address suffix to the ESPHome device name. I leave this disabled because I use unique names for each Ratgdo device. You might prefer
# differently. If you do, it reduces the length available for the name field to 24 characters.
name_add_mac_suffix: "false"
# Friendly name that is used in the Ratgdo webUI.
friendly_name: "Homebridge Ratgdo"
# Defaults to UTC - Homebridge Ratgdo will automatically determine the timezone based on geographic IP address information.
# Otherwise, set it manually to your timezone to override automatic timezone detection. You can select a TZ identifier for your timezone from the list at
# the [Wikipedia list of timezone database names](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
timezone: "UTC"
id_prefix: ratgdov25i
uart_tx_pin: D1
uart_rx_pin: D2
input_obst_pin: D7
status_door_pin: D0
status_obstruction_pin: D8
dry_contact_open_pin: D5
dry_contact_close_pin: D6
dry_contact_light_pin: D3
web_server:
esphome:
name: ${name}
friendly_name: ${friendly_name}
name_add_mac_suffix: ${name_add_mac_suffix}
project:
name: ratgdo.esphome
version: "2.5i"
on_boot:
priority: -100
then:
- if:
condition:
lambda: 'return id(sntp_time).get_timezone() == "UTC";'
then:
- http_request.get:
url: "http://worldtimeapi.org/api/ip"
on_response:
then:
- lambda: |-
if(response->status_code != HTTP_CODE_OK) {
ESP_LOGE("timezone.autodetermine", "World Time API HTTP Request failed with code: %d.", response->status_code);
return;
}
parse_json(body, [](JsonObject root) -> bool {
std::string timezone = root["timezone"];
id(sntp_time).set_timezone(timezone.c_str());
ESP_LOGI("timezone.autodetermine", "Timezone set to: %s.", timezone.c_str());
return true;
});
esp8266:
board: d1_mini
restore_from_flash: true
dashboard_import:
package_import_url: github://ratgdo/esphome-ratgdo/v25iboard.yaml@main
packages:
remote_package:
url: https://github.com/ratgdo/esphome-ratgdo
files: [base.yaml]
refresh: 6h
# Enable time synchronization using SNTP.
time:
- platform: sntp
id: sntp_time
servers:
- time.apple.com
- time.cloudflare.com
timezone: ${timezone}
# Enable the HTTP Client to autoset timezone information using the World Time API.
http_request:
id: http_request_data
timeout: 15s
verify_ssl: false
api:
id: api_server
ota:
improv_serial:
wifi:
ap:
logger:
external_components:
- source: github://pr#6797
components: [ web_server_base ]