Skip to content

Commit fd621da

Browse files
committed
chore: add basic config example, restructure example docs
1 parent cf70046 commit fd621da

File tree

4 files changed

+171
-18
lines changed

4 files changed

+171
-18
lines changed

README.md

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@ appear.
1616

1717
## Usage
1818

19-
Add reference to this repository to the `external_components` definitions:
19+
Add reference to this repository to the `external_components` definitions. Make sure that `ref` is a valid tag
20+
from the [Releases](https://github.com/sairon/esphome-nspanel-lovelace-ui/tags) page or an existing
21+
[branch](https://github.com/sairon/esphome-nspanel-lovelace-ui/branches).
22+
You can use `dev` for the latest bleeding-edge version but be aware that things may break from time to time.
2023

2124
```yaml
2225
external_components:
2326
- source:
2427
type: git
2528
url: https://github.com/sairon/esphome-nspanel-lovelace-ui
26-
ref: dev
29+
ref: release/v0.2.x
2730
components: [nspanel_lovelace]
2831
```
2932
@@ -78,22 +81,7 @@ for controlling the display:
7881

7982
### Example configuration
8083

81-
An example configuration was added on [example-nspanel-config.yml](example-nspanel-config.yml).
82-
On this configuration, we expose multiple services to Home Assistant:
83-
84-
- upload_tft: Used to upload the firmware to the panel, you just need to add the [URL of the firmware](https://docs.nspanel.pky.eu/prepare_nspanel/#flash-firmware-to-nextion-screen) (only the URL)
85-
- play_rtttl: play Nokia ringtones on the buzzer of the panel, example `Mario:d=4,o=5,b=100:32p,16e6,16e6,16p,16e6,16p,16c6,16e6,16p,16g6,8p,16p,16g,8p,32p,16c6,8p,16g,8p,16e,8p,16a,16p,16b,16p,16a#,16a,16p,16g,16e6,16g6,16a6,16p,16f6,16g6,16p,16e6,16p,16c6,16d6,16b,p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16g#,16a,16c6,16p,16a,16c6,16d6,8p,8d#6,16p,16d6,8p,8c6`
86-
- wake: to wake the screen when is off
87-
- show_screensaver: it shows the screensaver
88-
- navigate_to_page: navigate to the page from the parameter. (The name of the page is created using the type of the card and the key value, like `cardMedia_bedroom`)
89-
- disable_screensaver: make sure it won't show screensaver after the timeout (useful for showing something all the time on the screen, like a media card while it's playing)
90-
- enable_screensaver: enable the screensaver after it was disabled
91-
- dim_0_to_100: dim screen brightness with values from 0 to 100
92-
- show_entity: show the card of an entity on the screen. It requires the id of the entity, ex `light.bedroom` and title, ex `Bedroom Light`
93-
- notify_on_screensaver: show a notification on the screensaver with 2 lines, it can receive both lines. The notification will disappear when you tap on the screensaver
94-
- notify_fullscreen: show a full-screen notification with title description and 2 buttons, and it plays a sound on the buzzer. The buttons are not actionable yet
95-
96-
On the example configuration under the switch on_turn_off/on_turn_on there are a feature implemented to show an entity on the screen when the button is press and show the screensaver when the switch is off
84+
See the [examples](examples) folder for configuration examples.
9785

9886
## License
9987

examples/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# ESPHome configuration examples
2+
3+
## Basic config
4+
5+
Minimal configuration with configuration of all peripherals is in [basic-config.yml](basic-config.yml). Buttons are
6+
coupled with respective relays and two Home Assistant serviecs are exposed - `upload_tft` for an explicit upgrade
7+
of the display firmware (can be used for the initial reflash) and `play_rtttl` for playing [RTTTL melodies](https://esphome.io/components/rtttl.html).
8+
9+
After the NSPanel Lovelace UI firmware is flashed for the first time, the display should show an actionable
10+
notification for upgrade to newer version when NSPanel Lovelace UI Backend is updated from HACS if
11+
the `updateMode` options is set to `auto-notify`, or should be upgraded automatically if it's set to `auto`.
12+
13+
## Advanced configuration
14+
15+
More complex example was contributed by [@spike886](https://github.com/spike886), you can find it in
16+
[advanced-config.yml](advanced-config.yml).
17+
18+
In this configuration, we expose multiple services to Home Assistant:
19+
20+
- `upload_tft`: used to upload the firmware to the panel, requires [URL of the firmware](https://docs.nspanel.pky.eu/prepare_nspanel/#flash-firmware-to-nextion-screen) (only the URL)
21+
- `play_rtttl`: play Nokia ringtones on the buzzer of the panel, e.g. `Mario:d=4,o=5,b=100:32p,16e6,16e6,16p,16e6,16p,16c6,16e6,16p,16g6,8p,16p,16g,8p,32p,16c6,8p,16g,8p,16e,8p,16a,16p,16b,16p,16a#,16a,16p,16g,16e6,16g6,16a6,16p,16f6,16g6,16p,16e6,16p,16c6,16d6,16b,p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16g#,16a,16c6,16p,16a,16c6,16d6,8p,8d#6,16p,16d6,8p,8c6`
22+
- `wake`: wake the screen when it is off
23+
- `show_screensaver`: show the screensaver
24+
- `navigate_to_page`: navigate to the page from the parameter. (The name of the page is created using the type of the card and the key value, like `cardMedia_bedroom`)
25+
- `disable_screensaver`: make sure it won't show screensaver after the timeout (useful for showing something all the time on the screen, like a media card while it's playing)
26+
- `enable_screensaver`: enable the screensaver after it was disabled
27+
- `dim_0_to_100`: dim screen brightness with values from 0 to 100
28+
- `show_entity`: show the card of an entity on the screen. It requires the id of the entity, ex `light.bedroom` and title, ex `Bedroom Light`
29+
- `notify_on_screensaver`: show a notification on the screensaver with 2 lines, it can receive both lines. The notification will disappear when you tap on the screensaver
30+
- `notify_fullscreen`: show a full-screen notification with title description and 2 buttons, and it plays a sound on the buzzer. The buttons are not actionable yet
31+
32+
This configuration also contains configuration of the `switch` entity that shows how to show the entity
33+
on the display when the light is turned on, and show the screensaver when the light is turned off.
File renamed without changes.

examples/basic-config.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
substitutions:
2+
name: nspanel
3+
device_name: NSPanel
4+
5+
external_components:
6+
- source:
7+
type: git
8+
url: https://github.com/sairon/esphome-nspanel-lovelace-ui
9+
# Using dev is discouraged, see https://github.com/sairon/esphome-nspanel-lovelace-ui/blob/dev/README.md#usage
10+
ref: dev
11+
components: [nspanel_lovelace]
12+
13+
esphome:
14+
name: ${name}
15+
16+
esp32:
17+
board: esp32dev
18+
framework:
19+
type: arduino
20+
21+
wifi:
22+
ssid: !secret wifi_ssid
23+
password: !secret wifi_password
24+
25+
nspanel_lovelace:
26+
id: nspanel
27+
28+
ota:
29+
30+
logger:
31+
32+
binary_sensor:
33+
- platform: gpio
34+
name: $device_name Left Button
35+
internal: true
36+
pin:
37+
number: 14
38+
inverted: true
39+
on_click:
40+
- switch.toggle: relay_1
41+
42+
- platform: gpio
43+
name: $device_name Right Button
44+
internal: true
45+
pin:
46+
number: 27
47+
inverted: true
48+
on_click:
49+
- switch.toggle: relay_2
50+
51+
sensor:
52+
- platform: wifi_signal
53+
name: $device_name WiFi Signal
54+
update_interval: 60s
55+
internal: true
56+
57+
- platform: ntc
58+
id: temperature
59+
sensor: resistance_sensor
60+
calibration:
61+
b_constant: 3950
62+
reference_temperature: 25°C
63+
reference_resistance: 10kOhm
64+
name: $device_name Temperature
65+
66+
- platform: resistance
67+
id: resistance_sensor
68+
sensor: ntc_source
69+
configuration: DOWNSTREAM
70+
resistor: 11.2kOhm
71+
internal: true
72+
73+
- platform: adc
74+
id: ntc_source
75+
pin: 38
76+
update_interval: 10s
77+
attenuation: 11db
78+
internal: true
79+
80+
switch:
81+
- platform: gpio
82+
name: $device_name Relay 1
83+
id: relay_1
84+
pin:
85+
number: 22
86+
- platform: gpio
87+
name: $device_name Relay 2
88+
id: relay_2
89+
pin:
90+
number: 19
91+
92+
- platform: gpio
93+
id: screen_power
94+
entity_category: config
95+
pin:
96+
number: 4
97+
inverted: true
98+
restore_mode: ALWAYS_ON
99+
100+
output:
101+
- platform: ledc
102+
id: buzzer_out
103+
pin:
104+
number: 21
105+
106+
rtttl:
107+
id: buzzer
108+
output: buzzer_out
109+
110+
mqtt:
111+
broker: 192.168.1.1
112+
113+
uart:
114+
- id: tf_uart
115+
tx_pin: 16
116+
rx_pin: 17
117+
baud_rate: 115200
118+
119+
api:
120+
services:
121+
- service: upload_tft
122+
variables:
123+
url: string
124+
then:
125+
- lambda: |-
126+
id(nspanel).upload_tft(url);
127+
- service: play_rtttl
128+
variables:
129+
song_str: string
130+
then:
131+
- rtttl.play:
132+
rtttl: !lambda 'return song_str;'

0 commit comments

Comments
 (0)