substitutions: device_name: "habbit_desk" comment: "esp32" location: "kantoor" api_password: !secret deskcontroller_api ota_password: !secret ota_password wifi_ssid: !secret wifi_ssid wifi_password: !secret wifi_password gateway: !secret ip_gateway subnet: !secret ip_subnet # Device customization name: habbit_desk friendly_name: Habbit Desk background_color: '000000' main_icon_file: https://aguacatec.es/wp-content/uploads/2025/01/aguacatec.png secondary_image_file1: https://aguacatec.es/wp-content/uploads/2025/01/aguacatec_youtube.png secondary_image_file2: https://aguacatec.es/wp-content/uploads/2025/01/aguacatec_telegram.png # Example of Sensors sensor_temperature: sensor.temperatuur_slaapkamer_temperatuur sensor_home_temperature: sensor.ikea_of_sweden_vindstyrka_temperatuur sensor_home_humidity: sensor.temperatuur_slaapkamer_luchtvochtigheid chat_entity: input_text.habbit_desk_chat assist_entity: assist_satellite.voice_zolder_assist_satellite assist_awake_text: "Te escucho, ¿qué necesitas?" sensor_youtube: sensor.aguacatec_suscriptores sensor_telegram: input_number.miembros_telegram # Example of Lights desk_led: light.lamp_slaapkamer_2 # Example of Thermostat climate: climate.smart_radiator_thermostat_x # Example of Vacuum vacuum: vacuum.roborock_qrevo_s # Example of Switches printer: switch.regleta_l3 printer3d: switch.regleta_l4 # Other settings # Otros ajustes allowed_characters: " ¿?¡!#%'()+,-./:°0123456789ABCDEFGHIJKLMNOPQRSTUVWYZabcdefghijklmnopqrstuvwxyzáéíóú" ################################################################################################################ esphome: name: ${name} friendly_name: ${friendly_name} platformio_options: upload_speed: 921600 build_unflags: -Werror=all board_build.flash_mode: dio board_build.f_flash: 80000000L board_build.f_cpu: 240000000L psram: mode: octal esp32: board: esp32-s3-devkitc-1 flash_size: 16MB framework: type: esp-idf external_components: - source: github://buglloc/esphome-components components: [sy6970] #disable Blinking led sy6970: i2c_id: touchscreen_bus state_led_enable: false packages: connection: !include common/wifi.yaml # Enable logging logger: globals: - id: inactivity_time type: int restore_value: no initial_value: '0' switch: - platform: template name: "Auto Lock" id: auto_lock icon: "mdi:lock-clock" optimistic: true restore_mode: 'restore_default_off' - platform: template name: "Display" id: habbit_display icon: "mdi:fit-to-screen" optimistic: true restore_mode: 'always_on' on_turn_on: - light.turn_on: backlight - lambda: |- id(inactivity_time) = 0; on_turn_off: - light.turn_off: backlight - display.page.show: home number: - platform: template name: "Time Out" id: time_out icon: "mdi:timer-sand" optimistic: true min_value: 10 max_value: 600 step: 10 unit_of_measurement: "s" restore_value: true font: - file: "gfonts://Space Grotesk" id: clock_time size: 30 glyphs: ${allowed_characters} - file: "gfonts://Space Grotesk" id: secondary size: 16 glyphs: ${allowed_characters} - file: "gfonts://Roboto" id: info size: 20 glyphs: ${allowed_characters} - file: "gfonts://Roboto" id: title size: 25 glyphs: ${allowed_characters} - file: "gfonts://Space Grotesk" id: big_numbers size: 120 glyphs: ${allowed_characters} color: - id: background_color hex: ${background_color} - id: orange hex: 'e9c726' - id: white hex: 'ffffff' - id: dirty_white hex: 'c6c6c6' - id: grey hex: '222222' - id: light_grey hex: '444444' - id: lime hex: 'deff00' - id: crimson hex: 'f3528f' - id: blue hex: '52c0f3' - id: dark_blue hex: '1d85b6' - id: magenta hex: 'a91225' - id: dark_magenta hex: '440109' image: rgb: alpha_channel: - file: ${main_icon_file} id: icon_habbit resize: 180x180 # type: RGB # transparency: alpha_channel - file: ${secondary_image_file1} id: secondary_image1 resize: 160x160 # type: RGB # transparency: alpha_channel - file: ${secondary_image_file2} id: secondary_image2 resize: 120x120 # type: RGB # transparency: alpha_channel binary: - file: mdi:chat-outline id: icon_chat resize: 40x40 - file: mdi:chat-processing id: icon_assist resize: 40x40 - file: mdi:white-balance-sunny id: icon_weather resize: 40x40 - file: mdi:home-thermometer id: icon_temperature resize: 40x40 - file: mdi:water-percent id: icon_humidity resize: 40x40 - file: mdi:home-automation id: icon_devices resize: 50x50 - file: mdi:exit-to-app id: icon_exit resize: 45x45 - file: mdi:plus-thick id: icon_plus resize: 45x45 - file: mdi:led-strip-variant id: icon_led_strip resize: 100x100 - file: mdi:thermostat id: icon_thermostat resize: 100x100 - file: mdi:robot-vacuum id: icon_vacuum resize: 100x100 - file: mdi:printer id: icon_printer resize: 100x100 - file: mdi:printer-3d-nozzle id: icon_printer3d resize: 100x100 # This will fetch time from Home Assistant time: - platform: homeassistant id: esptime # Create sensors from HA you want to use and show # Crea los sensores de HA que quieres utilizar y mostrar sensor: - platform: homeassistant id: sensor_temperature entity_id: ${sensor_temperature} internal: true - platform: homeassistant id: sensor_home_temperature entity_id: ${sensor_home_temperature} internal: true - platform: homeassistant id: sensor_home_humidity entity_id: ${sensor_home_humidity} internal: true # - platform: homeassistant # id: sensor_youtube # entity_id: ${sensor_youtube} # internal: true # on_value: # then: # - display.page.show: secondary1 # - light.turn_on: backlight # - switch.turn_on: habbit_display # - lambda: |- # id(inactivity_time) = 0; # - platform: homeassistant # id: sensor_telegram # entity_id: ${sensor_telegram} # internal: true # on_value: # then: # - display.page.show: secondary2 # - light.turn_on: backlight # - switch.turn_on: habbit_display # - lambda: |- # id(inactivity_time) = 0; text_sensor: # - platform: homeassistant # id: chat_message # entity_id: ${chat_entity} # internal: true # on_value: # then: # - display.page.show: home # - light.turn_on: backlight # - switch.turn_on: habbit_display # - lambda: |- # id(inactivity_time) = 0; - platform: homeassistant id: chat_assist entity_id: ${assist_entity} internal: true on_value: then: - if: condition: lambda: 'return id(chat_assist).state == "listening";' then: - display.page.show: home - light.turn_on: backlight - switch.turn_on: habbit_display - lambda: |- id(inactivity_time) = 0; - platform: homeassistant id: device_desk_led entity_id: ${desk_led} internal: true - platform: homeassistant id: device_thermostat entity_id: ${climate} internal: true - platform: homeassistant id: device_vacuum entity_id: ${vacuum} internal: true - platform: homeassistant id: device_printer entity_id: ${printer} internal: true - platform: homeassistant id: device_printer3d entity_id: ${printer3d} internal: true spi: - id: display_qspi type: quad clk_pin: 17 data_pins: - 13 - 18 - 21 - 14 i2c: sda: 15 scl: 10 id: touchscreen_bus touchscreen: - platform: axs15231 id: main_touch display: main_display i2c_id: touchscreen_bus transform: mirror_x: true mirror_y: False swap_xy: false calibration: x_min: 0 x_max: 640 y_min: 0 y_max: 180 on_touch: - lambda: |- ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%0d, state=%d", touch.x, touch.y, touch.x_raw, touch.y_raw, touch.state ); - lambda: |- id(inactivity_time) = 0; binary_sensor: - platform: touchscreen name: Screen internal: true x_min: 0 x_max: 640 y_min: 0 y_max: 180 on_press: then: - lambda: |- id(inactivity_time) = 0; - light.turn_on: backlight - switch.turn_on: habbit_display - platform: touchscreen name: Devices button internal: true x_min: 580 x_max: 630 y_min: 0 y_max: 90 on_press: then: - if: condition: display.is_displaying_page: home then: - display.page.show: devices1 else: - display.page.show: home #[11:04:51.630][I][cal:375]: x=608, y=29, x_raw=31, y_raw=151, state=1 - platform: touchscreen name: More button internal: true x_min: 580 x_max: 630 y_min: 90 y_max: 180 on_press: then: - if: condition: display.is_displaying_page: devices1 then: - display.page.show: devices2 # else: # - if: # condition: # display.is_displaying_page: devices2 # then: # - display.page.show: devices1 # else: # - if: # condition: # display.is_displaying_page: secondary1 # then: # - display.page.show: secondary2 # else: # - if: # condition: # display.is_displaying_page: secondary2 # then: # - display.page.show: secondary1 - platform: touchscreen name: Device 1 internal: true x_min: 0 x_max: 160 y_min: 0 y_max: 180 on_press: then: # - if: # condition: # - switch.is_on: habbit_display # - display.is_displaying_page: home # then: # - display.page.show: secondary1 - if: condition: display.is_displaying_page: devices1 then: - homeassistant.action: service: light.toggle data: entity_id: ${desk_led} - if: condition: display.is_displaying_page: devices2 then: - homeassistant.action: service: switch.toggle data: entity_id: ${printer3d} - platform: touchscreen name: Device 2 internal: true x_min: 161 x_max: 290 y_min: 0 y_max: 180 on_press: then: - if: condition: display.is_displaying_page: devices1 then: - homeassistant.action: service: climate.toggle data: entity_id: ${climate} - platform: touchscreen name: Device 3 internal: true x_min: 291 x_max: 420 y_min: 0 y_max: 180 on_press: then: - if: condition: display.is_displaying_page: devices1 then: - if: condition: lambda: 'return id(device_vacuum).state == "cleaning";' then: - homeassistant.action: service: vacuum.pause data: entity_id: ${vacuum} else: - homeassistant.action: service: vacuum.start data: entity_id: ${vacuum} - platform: touchscreen name: Device 4 internal: true x_min: 421 x_max: 550 y_min: 0 y_max: 180 on_press: then: - if: condition: display.is_displaying_page: devices1 then: - homeassistant.action: service: switch.toggle data: entity_id: ${printer} output: - platform: ledc pin: GPIO1 id: backlight_pwm light: - platform: monochromatic output: backlight_pwm name: Display id: backlight restore_mode: ALWAYS_ON internal: True display: - platform: mipi_spi id: main_display spi_id: display_qspi #id: lily_display model: AXS15231 #spi_id: lily_spi dimensions: height: 640 #180 width: 184 #180 cs_pin: 12 reset_pin: 16 rotation: 90 auto_clear_enabled: false # display: # - platform: mipi_spi # id: main_display # spi_id: display_qspi # #id: lily_display # model: AXS15231 # dimensions: # height: 640 # width: 180 # cs_pin: 12 # reset_pin: 16 # transform: # mirror_x: true # mirror_y: true # swap_xy: false # rotation: 90 # auto_clear_enabled: false pages: - id: home lambda: |- it.fill(id(background_color)); it.image(-20, 0, id(icon_habbit)); if (id(chat_assist).state == "listening") { it.image(100, 20, id(icon_assist), id(blue)); it.print(150, 25, id(info), "${assist_awake_text}"); } // else { // it.image(100, 20, id(icon_chat), id(lime)); // std::string message = id(chat_message).state.c_str(); // if (message.length() > 35) { // message = message.substr(0, 35) + "..."; // } // it.print(150, 25, id(info), message.c_str()); // } it.strftime(580, 30, id(clock_time), TextAlign::CENTER, "%H:%M", id(esptime).now()); it.strftime(580, 53, id(secondary), TextAlign::CENTER, "%d/%m/%y", id(esptime).now()); it.image(170, 90, id(icon_weather), id(orange)); it.printf(220, 95, id(title), id(dirty_white), "%.0f°C", id(sensor_temperature).state); it.image(300, 90, id(icon_temperature), id(crimson)); it.printf(355, 95, id(title), id(dirty_white), "%.0f°C", id(sensor_home_temperature).state); it.image(430, 90, id(icon_humidity), id(blue)); it.printf(475, 95, id(title), id(dirty_white), "%.0f%%", id(sensor_home_humidity).state); it.filled_triangle(640, 180, 640, 60, 530, 180, grey); it.image(580, 120, id(icon_devices), id(light_grey)); - id: devices1 lambda: |- it.fill(id(background_color)); if (id(device_desk_led).state == "on") { it.image(40, 40, id(icon_led_strip), id(orange)); } else { it.image(40, 40, id(icon_led_strip), id(light_grey)); } if (id(device_thermostat).state == "heat") { it.image(170, 40, id(icon_thermostat), id(crimson)); } else { it.image(170, 40, id(icon_thermostat), id(light_grey)); } if (id(device_vacuum).state == "cleaning") { it.image(300, 40, id(icon_vacuum), id(lime)); } else { it.image(300, 40, id(icon_vacuum), id(light_grey)); } if (id(device_printer).state == "on") { it.image(430, 40, id(icon_printer), id(blue)); } else { it.image(430, 40, id(icon_printer), id(light_grey)); } it.image(585, 10, id(icon_plus), id(light_grey)); it.filled_triangle(640, 180, 640, 60, 530, 180, grey); it.image(585, 125, id(icon_exit), id(light_grey)); - id: devices2 lambda: |- it.fill(id(background_color)); if (id(device_printer3d).state == "on") { it.image(40, 40, id(icon_printer3d), id(lime)); } else { it.image(40, 40, id(icon_printer3d), id(light_grey)); } it.image(585, 10, id(icon_plus), id(light_grey)); it.filled_triangle(640, 180, 640, 60, 530, 180, grey); it.image(585, 125, id(icon_exit), id(light_grey)); # - id: secondary1 # lambda: |- # it.fill(id(magenta)); # it.image(-10, 10, id(secondary_image1)); # it.printf(170, 15, id(big_numbers), id(dirty_white), "%.3f", id(sensor_youtube).state / 1000); # it.image(585, 10, id(icon_plus), id(dark_magenta)); # it.filled_triangle(640, 180, 640, 60, 530, 180, dark_magenta); # it.image(585, 125, id(icon_exit), id(magenta)); # - id: secondary2 # lambda: |- # it.fill(id(blue)); # it.image(20, 30, id(secondary_image2)); # it.printf(170, 15, id(big_numbers), id(white), "%.3f", id(sensor_telegram).state / 1000); # it.image(585, 10, id(icon_plus), id(dark_blue)); # it.filled_triangle(640, 180, 640, 60, 530, 180, dark_blue); # it.image(585, 125, id(icon_exit), id(blue)); interval: - interval: 1s then: - lambda: |- if (id(auto_lock).state) { if (id(inactivity_time) < id(time_out).state) { id(inactivity_time) += 1; } else { id(backlight_pwm).turn_off(); id(habbit_display).turn_off(); } }