OpenHASP is pretty tightly integrated with HA.
I got this far using the configuration parameters found on openHASP:
spi:
clk_pin: GPIO19
mosi_pin: GPIO23
miso_pin: GPIO25
i2c:
sda: GPIO4
scl: GPIO0
output:
- platform: ledc
pin: GPIO26
id: moodRed
- platform: ledc
pin: GPIO32
id: moodGreen
- platform: ledc
pin: GPIO33
id: moodBlue
- platform: gpio
pin: GPIO12
id: relay_1
- platform: gpio
pin: GPIO14
id: relay_2
- platform: gpio
pin: GPIO27
id: relay_3
light:
- platform: rgb
name: "Mood Light"
red: moodRed
green: moodGreen
blue: moodBlue
display:
- id: langbon_L8
platform: st7789v
model: Custom
height: 320
width: 240
offset_height: 0
offset_width: 0
backlight_pin: GPIO5
cs_pin: GPIO22
dc_pin: GPIO21
reset_pin: GPIO18
auto_clear_enabled: false
update_interval: never
If I leave out the display
element, the device works fine and I can control the RGB moodlight.
But with the display
element, it wonāt boot. I connected the IDF monitor (using a different IDF project of mine) and hereās what I see:
Rebooting...
[I][logger:171]: Log initialized
[C][safe_mode:079]: There have been 2 suspected unsuccessful boot attempts
[D][esp32.preferences:114]: Saving 1 preferences to flash...
[D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[I][app:029]: Running through setup()...
[D][spi:035]: Setting up SPI bus...
[I][i2c.arduino:218]: Performing I2C bus recovery
[C][light:021]: Setting up light 'Mood Light'...
[D][light:036]: 'Mood Light' Setting:
[D][light:041]: Color mode: RGB
[D][light:085]: Transition length: 1.0s
[C][st7789v:011]: Setting up SPI ST7789V...
[D][spi_device:362]: mode 0, data_rate 20000kHz
[E][display:017]: Could not allocate buffer for display!
Iāll file an issue agains ESPHome but I guess Iām sticking with openHASP!
Just a thought: Does the esp32 in that device offer psram and do you have it defined in your yaml?
Edit: The link in github claims your device has 8MB psram but the yaml you post with your issue does not contain the psram component!
Thank you that did it! Adding:
psram:
mode: octal
speed: 80MHz
And now the device boots fine (but looks like it only has 4MB):
[C][light:092]: Light 'Mood Light'
[C][light:094]: Default Transition Length: 1.0s
[C][light:095]: Gamma Correct: 2.80
[C][psram:020]: PSRAM:
[C][psram:021]: Available: YES
[C][psram:024]: Size: 4095 KB
[C][FT63X6:070]: FT63X6 Touchscreen:
[C][FT63X6:071]: Address: 0x38
[C][FT63X6:074]: Update Interval: 0.050s
[C][st7789v:124]: SPI ST7789V
[C][st7789v:124]: Rotations: 0 Ā°
[C][st7789v:124]: Dimensions: 240px x 320px
[C][st7789v:125]: Model: CUSTOM
[C][st7789v:126]: Height: 320
[C][st7789v:127]: Width: 240
[C][st7789v:128]: Height Offset: 0
[C][st7789v:129]: Width Offset: 0
[C][st7789v:130]: 8-bit color mode: NO
[C][st7789v:131]: CS Pin: GPIO22
[C][st7789v:132]: DC Pin: GPIO21
[C][st7789v:133]: Reset Pin: GPIO18
[C][st7789v:134]: B/L Pin: GPIO5
[C][st7789v:135]: Update Interval: never
[C][st7789v:136]: Data rate: 20MHz
[C][lvgl:086]: LVGL:
[C][lvgl:087]: Display width/height: 240 x 320
[C][lvgl:088]: Rotation: 0
[C][lvgl:089]: Draw rounding: 2
Iām not seeing the default LVGL āHello World!ā but thatās progress already.
Use the ili9xxx
driver, not the st7789v
.
Isnāt this what we are already doing?
display:
- platform: ili9xxx
model: ST7789V
...
Apparently not, according to your log:
I now have this working including using the relays:
(really should have cleaned it before I took the photo!)
spi:
clk_pin: GPIO19
mosi_pin: GPIO23
miso_pin: GPIO25
i2c:
sda: GPIO4
scl: GPIO0
display:
- platform: ili9xxx
model: ST7789V
cs_pin: GPIO22
dc_pin: GPIO21
reset_pin: GPIO18
invert_colors: false
auto_clear_enabled: false
update_interval: never
show_test_card: true
id: disp
rotation: 180
output:
- platform: ledc
pin: GPIO5
id: backlight_pwm
- platform: ledc
id: mood_red
pin: GPIO26
- platform: ledc
id: mood_green
pin: GPIO32
- platform: ledc
id: mood_blue
pin: GPIO33
light:
- platform: monochromatic
output: backlight_pwm
name: "Display Backlight"
id: backlight
restore_mode: ALWAYS_ON
- platform: rgb
name: "Moodlight"
red: mood_red
green: mood_green
blue: mood_blue
touchscreen:
platform: ft63x6
id: touch
display: disp
calibration:
x_min: 0
y_min: 0
x_max: 230
y_max: 312
on_touch:
- lambda: |-
ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%0d",
touch.x,
touch.y,
touch.x_raw,
touch.y_raw
);
on_release:
- if:
condition: lvgl.is_paused
then:
- logger.log: "LVGL resuming"
- lvgl.resume:
- lvgl.widget.redraw:
- light.turn_on: backlight
lvgl:
displays:
- disp
default_font: montserrat_24
on_idle:
timeout: !lambda "return (id(display_timeout).state * 1000);"
then:
- logger.log: "LVGL is idle"
- light.turn_off: backlight
- lvgl.pause:
#time: !lambda "return id(homeassistant_time).now();"
style_definitions:
- id: header_footer
bg_color: 0x2F8CD8
bg_grad_color: 0x005782
bg_grad_dir: VER
bg_opa: COVER
border_opa: TRANSP
radius: 0
pad_all: 0
pad_row: 0
pad_column: 0
border_color: 0x0077b3
text_color: 0xFFFFFF
width: 100%
height: 30
text_font: montserrat_18
pages:
- id: main_page
widgets:
- obj:
align: TOP_MID
styles: header_footer
widgets:
- label:
text: "Lounge"
align: CENTER
text_align: CENTER
text_color: 0xFFFFFF
id: head_label
- buttonmatrix:
x: 5
y: 40
width: 235
height: 260
items:
pressed:
bg_color: 0x0f1e2f
bg_color: 0xa3e8ff
id: matrix_id
rows:
- buttons:
- id: light_btn
control:
checkable: true
text: 'Kitchen'
on_click:
- homeassistant.action:
action: light.toggle
data:
entity_id: light.kitchen_lights
- logger.log:
format: "Kitchen Button pressed"
- buttons:
- id: light2_btn
control:
checkable: true
text: 'Family'
on_click:
- homeassistant.action:
action: light.toggle
data:
entity_id: light.lounge_lights
- logger.log:
format: "Family Button pressed"
- buttons:
- id: aircon_btn
control:
checkable: true
text: 'Aircon'
on_click:
- homeassistant.action:
action: switch.toggle
data:
entity_id: switch.d828c9db07ff_ac_power_status
- logger.log:
format: "aircon button pressed"
- buttons:
- id: wall_btn
control:
checkable: true
text: 'Wall Light'
on_click:
- homeassistant.action:
action: switch.toggle
data:
entity_id: switch.esphome_web_5e1530_relay1
- logger.log:
format: "wall switch button pressed"
switch:
- platform: gpio
pin: GPIO12
name: relay1
id: relay1
- platform: gpio
pin: GPIO14
name: relay2
id: relay2
- platform: gpio
pin: GPIO27
name: relay3
id: relay3
binary_sensor:
- platform: homeassistant
id: kitchen_light
entity_id: light.kitchen_lights
publish_initial_state: true
on_state:
then:
lvgl.widget.update:
id: light_btn
state:
checked: !lambda return x;
- platform: homeassistant
id: family_light
entity_id: light.lounge_lights
publish_initial_state: true
on_state:
then:
lvgl.widget.update:
id: light2_btn
state:
checked: !lambda return x;
- platform: homeassistant
id: bedroom_aircon
entity_id: switch.0200000b34c2_ac_power_status
publish_initial_state: true
on_state:
then:
lvgl.widget.update:
id: aircon_btn
state:
checked: !lambda return x;
- platform: lvgl
name: button2
widget: light_btn
publish_initial_state: true
- platform: lvgl
name: button4
widget: aircon_btn
publish_initial_state: true
- platform: lvgl
name: button3
widget: light2_btn
publish_initial_state: true
- platform: lvgl
name: button4
widget: wall_btn
publish_initial_state: true
- platform: status
name: Status sensor
number:
- platform: template
name: LVGL Screen timeout
optimistic: true
id: display_timeout
unit_of_measurement: "s"
initial_value: 45
restore_value: true
min_value: 10
max_value: 180
step: 5
mode: box