Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GrowSmart - ESPHome
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan Grewe
GrowSmart - ESPHome
Commits
cf9ae04c
Commit
cf9ae04c
authored
Jul 14, 2024
by
Jan Grewe
Browse files
Options
Downloads
Patches
Plain Diff
tweak graphs
parent
3bb175d4
Branches
Branches containing commit
No related tags found
1 merge request
!1
add growbox-screen
Pipeline
#1179
passed
Jul 14, 2024
Stage: validate
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
img/screen_growsmart.png
+0
-0
0 additions, 0 deletions
img/screen_growsmart.png
packages/display_cyd2usb.yaml
+44
-20
44 additions, 20 deletions
packages/display_cyd2usb.yaml
packages/mqtt.yaml
+9
-0
9 additions, 0 deletions
packages/mqtt.yaml
packages/screen.yaml
+154
-77
154 additions, 77 deletions
packages/screen.yaml
with
207 additions
and
97 deletions
img/screen_growsmart.png
0 → 100644
+
0
−
0
View file @
cf9ae04c
8.04 KiB
This diff is collapsed.
Click to expand it.
packages/display_cyd2usb.yaml
+
44
−
20
View file @
cf9ae04c
...
...
@@ -27,14 +27,7 @@ display:
dimensions
:
height
:
320
width
:
240
lambda
:
|-
it.fill(id(Color::BLACK));
it.line(0, 0, 50, 50);
it.filled_circle(60, 160, 30, id(green));
it.filled_circle(180, 160, 30, id(red));
it.print(60, 160, id(mdi_large), TextAlign::CENTER, "");
it.print(180, 160, id(mdi_large), TextAlign::CENTER, "");
it.print(216, 0, id(mdi_medium), id(wifi_iconstring).c_str());
lambda
:
id(update_display).execute();
# Set up the xpt2046 touch platform
touchscreen
:
...
...
@@ -90,29 +83,60 @@ light:
red
:
output_red
green
:
output_green
blue
:
output_blue
gamma_correct
:
1.0
restore_mode
:
ALWAYS_ON
effects
:
-
pulse
:
name
:
"
Default"
transition_length
:
3s
update_interval
:
3s
min_brightness
:
33
%
min_brightness
:
50
%
max_brightness
:
100%
-
strobe
:
name
:
"
Alert"
colors
:
-
state
:
true
brightness
:
100%
red
:
100%
green
:
0%
blue
:
0%
duration
:
250ms
-
state
:
false
duration
:
250ms
on_turn_on
:
-
light.turn_on
:
id
:
led
effect
:
"
Default"
brightness
:
100%
red
:
0%
green
:
100%
blue
:
0%
interval
:
-
interval
:
5
s
-
interval
:
10
s
then
:
-
if
:
condition
:
-
lambda
:
"
return
!id(recent_touch);"
then
:
-
light.turn_on
:
id
:
backlight
brightness
:
25%
else
:
-
lambda
:
"
id(recent_touch)
=
false;"
-
lambda
:
|-
// dim the display to 50% after 10s, and to 25% after 20s
if (id(recent_touch))
{
id(recent_touch) = false;
id(screen_timeout_short) = true;
}
else if (id(screen_timeout_short))
{
id(screen_timeout_short) = false;
id(screen_timeout_long) = true;
auto call = id(backlight).turn_on();
call.set_brightness(0.5);
call.perform();
}
else if (id(screen_timeout_long))
{
id(screen_timeout_long) = false;
auto call = id(backlight).turn_on();
call.set_brightness(0.25);
call.perform();
}
button
:
-
platform
:
factory_reset
name
:
Factory Reset
This diff is collapsed.
Click to expand it.
packages/mqtt.yaml
+
9
−
0
View file @
cf9ae04c
...
...
@@ -5,4 +5,13 @@ mqtt:
client_id
:
$devicename
discovery
:
false
topic_prefix
:
growsmart/$devicename
log_topic
:
topic
:
growsmart/$devicename/log
level
:
INFO
birth_message
:
topic
:
growsmart/$devicename/status
payload
:
online
will_message
:
topic
:
growsmart/$devicename/status
payload
:
offline
reboot_timeout
:
0s
This diff is collapsed.
Click to expand it.
packages/screen.yaml
+
154
−
77
View file @
cf9ae04c
substitutions
:
graph_duration
:
15min
graph_grid_x
:
1min
# Set up some global variables for some values that we want to persist
globals
:
-
id
:
wifi_iconstring
type
:
std::string
restore_value
:
no
initial_value
:
'
""'
-
id
:
recent_touch
type
:
bool
restore_value
:
no
initial_value
:
"
true"
initial_value
:
'
true'
-
id
:
screen_timeout_short
type
:
bool
-
id
:
screen_timeout_long
type
:
bool
-
id
:
temperature
type
:
float
initial_value
:
'
0.0'
-
id
:
humidity
type
:
float
initial_value
:
'
0.0'
-
id
:
ec
type
:
float
initial_value
:
'
0.0'
-
id
:
ph
type
:
float
initial_value
:
'
0.0'
# ============================================================
# ESPHome Display related setup
#
# Create a font to use, add and remove glyphs as needed
# The Material Design Icon font is going to be used to display wifi
# state as well as displaying the lightbulb icons
font
:
-
file
:
'
packages/fonts/materialdesignicons-webfont.ttf'
id
:
mdi_large
size
:
48
glyphs
:
[
"
"
,
# lightbulb-on
"
"
,
# lightbulb-off
]
-
file
:
"
packages/fonts/materialdesignicons-webfont.ttf"
id
:
mdi_medium
size
:
24
glyphs
:
[
"
"
,
# no-wifi
"
"
,
# low-wifi
"
"
,
# wifi-1
"
"
,
# wifi-2
"
"
,
# wifi-3
"
"
,
# wifi-4
]
-
file
:
type
:
gfonts
family
:
Roboto
weight
:
700
id
:
font_default
size
:
16
glyphs
:
'
!"%()+=,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ
abcdefghijklmnopqrstuvwxyzåäö'
# Create a Home Assistant blue color
color
:
-
id
:
green
hex
:
00FF00
-
id
:
red
hex
:
FF0000
image
:
-
file
:
"
img/screen_growsmart.png"
id
:
growsmart
type
:
RGB24
# Setup two binary sensors for the two areas for touch
binary_sensor
:
-
platform
:
touchscreen
name
:
Light Green
name
:
"
LED
Default"
x_min
:
0
x_max
:
120
y_min
:
0
...
...
@@ -55,12 +48,10 @@ binary_sensor:
then
:
-
light.turn_on
:
id
:
led
red
:
0.0
green
:
1.0
blue
:
0.0
effect
:
Default
-
platform
:
touchscreen
name
:
Light Red
name
:
"
LED
Alert"
x_min
:
120
x_max
:
240
y_min
:
0
...
...
@@ -69,43 +60,129 @@ binary_sensor:
then
:
-
light.turn_on
:
id
:
led
red
:
1.0
green
:
0.0
blue
:
0.0
effect
:
Alert
# Setup a script that can update the UI values independent of the display lambda
# so that we're not trying to pull the WiFi signal strength every single frame
script
:
-
id
:
update_
ui_values
-
id
:
update_
display
then
:
-
lambda
:
|-
if (isnan(id(wifi_signal_pct).state))
id(wifi_iconstring) = ""; // No-wifi
else if (id(wifi_signal_pct).state < 10)
id(wifi_iconstring) = ""; // low-wifi
else if (id(wifi_signal_pct).state < 30)
id(wifi_iconstring) = ""; // wifi-1
else if (id(wifi_signal_pct).state < 50)
id(wifi_iconstring) = ""; // wifi-2
else if (id(wifi_signal_pct).state < 75)
id(wifi_iconstring) = ""; // wifi-3
else
id(wifi_iconstring) = ""; // wifi-4
if (id(temperature) == 0.0 || id(humidity) == 0.0 || id(ph) == 0.0 || id(ec) == 0.0)
{
esp_display->image(0, 0, id(growsmart));
return;
}
esp_display->fill(id(Color::BLACK));
esp_display->printf(0, 0, id(font_default), "Temperature: %.2f °C", id(temperature));
esp_display->graph(0, 18, id(graph_temperature));
esp_display->printf(0, 80, id(font_default), "Humidity: %.2f%%", id(humidity));
esp_display->graph(0, 98, id(graph_humidity));
esp_display->printf(0, 160, id(font_default), "pH: %.2f", id(ph));
esp_display->graph(0, 178, id(graph_ph));
esp_display->printf(0, 240, id(font_default), "EC: %.2f mS", id(ec));
esp_display->graph(0, 258, id(graph_ec));
# Update the UI state every 10 seconds
interval
:
-
interval
:
1s
then
:
-
script.execute
:
update_ui_values
color
:
-
id
:
color_red
red
:
100%
green
:
0%
blue
:
0%
-
id
:
color_green
red
:
0%
green
:
100%
blue
:
0%
-
id
:
color_blue
red
:
0%
green
:
0%
blue
:
100%
graph
:
-
id
:
graph_temperature
duration
:
${graph_duration}
x_grid
:
${graph_grid_x}
y_grid
:
1.0
width
:
240
height
:
60
min_value
:
18
max_value
:
32
min_range
:
2
max_range
:
2
traces
:
-
sensor
:
mqtt_temperature
continuous
:
true
#line_thickness: 2
color
:
color_green
-
id
:
graph_humidity
duration
:
${graph_duration}
x_grid
:
${graph_grid_x}
y_grid
:
1.0
width
:
240
height
:
60
min_value
:
40
max_value
:
90
min_range
:
2
max_range
:
2
traces
:
-
sensor
:
mqtt_humidity
continuous
:
true
#line_thickness: 2
color
:
color_green
-
id
:
graph_ph
duration
:
${graph_duration}
x_grid
:
${graph_grid_x}
y_grid
:
1.0
width
:
240
height
:
60
min_value
:
4
max_value
:
8
min_range
:
2
max_range
:
2
traces
:
-
sensor
:
mqtt_ph
continuous
:
true
#line_thickness: 2
color
:
color_green
-
id
:
graph_ec
duration
:
${graph_duration}
x_grid
:
${graph_grid_x}
y_grid
:
1.0
width
:
240
height
:
60
min_value
:
0
max_value
:
3
min_range
:
2
max_range
:
2
traces
:
-
sensor
:
mqtt_ec
continuous
:
true
#line_thickness: 2
color
:
color_green
# Wifi sensor that drives the UI signal strength icon
sensor
:
-
platform
:
wifi_signal
# Reports the WiFi signal strength in %
name
:
"
WiFi
Signal
Percent"
filters
:
-
lambda
:
return min(max(2 * (x + 100.0), 0.0), 100.0);
unit_of_measurement
:
"
Signal
%"
id
:
wifi_signal_pct
update_interval
:
60s
entity_category
:
"
diagnostic"
-
platform
:
mqtt_subscribe
id
:
mqtt_temperature
name
:
"
Temperature"
topic
:
growsmart/growbox/sensor/air__temperature/state
on_value
:
then
:
-
lambda
:
'
id(temperature)
=
x;'
-
platform
:
mqtt_subscribe
id
:
mqtt_humidity
name
:
"
Humidity"
topic
:
growsmart/growbox/sensor/air__humidity/state
on_value
:
then
:
-
lambda
:
'
id(humidity)
=
x;'
-
platform
:
mqtt_subscribe
id
:
mqtt_ec
name
:
"
EC"
topic
:
growsmart/growbox/sensor/ec/state
on_value
:
then
:
-
lambda
:
'
id(ec)
=
x;'
-
platform
:
mqtt_subscribe
id
:
mqtt_ph
name
:
"
pH"
topic
:
growsmart/growbox/sensor/ph/state
on_value
:
then
:
-
lambda
:
'
id(ph)
=
x;'
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment