diff --git a/Code/Home Assistant/README.md b/Code/Home Assistant/README.md new file mode 100644 index 0000000..e97b289 --- /dev/null +++ b/Code/Home Assistant/README.md @@ -0,0 +1,37 @@ +# Using the PicoCalc with Home Assistant + +This example demonstrates how to use your PicoCalc with Home Assistant via the [ESPHome Project (https://esphome.io/)](https://esphome.io/) + +![Home Assistant Example](../../Pictures/homeassistant_example.jpg) + +## Prerequisites + +* A working Home Assistant installation with ESPHome installed +* PicoCalc with a Pi Pico 2040 W or Pi Pico 2 2350 + +## Setup +The easiest way to get started is to use the ESPHome dashboard and make a new device, +get your Pi Pico W flashed and registered/connected with ESPHome. + +You can then copy the configuration bit you want from picocalc.yaml into your +new devices configuration and you can now reflash wirelessly. + +## Current Status + +What Works: +* WiFi +* SPI with the Display +* LVGL (UI) with widgets and updates +* OTA Updates +* Using a text_sensor to live-update my garage light status (example) + +## TODO (in no particular order): + +- [ ] Enable I2C +- [ ] Enable the keyboard +- [ ] Enable Backlight Adjustment +- [ ] Enable Backlight Keyboard +- [ ] Enable the SD card +- [ ] Enable the GPIO pins +- [ ] Enable Audio +- [ ] Enable... whatever else. \ No newline at end of file diff --git a/Code/Home Assistant/picocalc.yaml b/Code/Home Assistant/picocalc.yaml new file mode 100644 index 0000000..b4eb402 --- /dev/null +++ b/Code/Home Assistant/picocalc.yaml @@ -0,0 +1,108 @@ +esphome: + name: picocalc + friendly_name: PicoCalc + +### Board Configuration ### +## Note: If you're using a different board, you may need to change this section +rp2040: + board: rpipico2w + framework: + platform_version: https://github.com/maxgerhardt/platform-raspberrypi.git#develop + version: dev + +####### Pin Configuration ###### +# Pinout for the Raspberry Pi Pico2 W +spi: + clk_pin: GPIO10 + mosi_pin: GPIO11 + miso_pin: GPIO12 + id: spi_bus + +# Built-in LCD Display +display: + - id: builtin_display + platform: ili9xxx + model: ILI9341 + spi_id: spi_bus + cs_pin: GPIO13 + dc_pin: GPIO14 + reset_pin: GPIO15 + color_order: BGR + invert_colors: true + update_interval: 100ms + dimensions: + width: 320 + height: 320 + transform: + swap_xy: false + mirror_x: true + mirror_y: false + +lvgl: + widgets: + - label: + id: light_status_label + align: CENTER + text: "Garage Lights: Unknown" + - label: + align: TOP_LEFT + text: 'Hello World!' + - textarea: + id: i2c_textbox + text: "I2C Scan Results..." + width: 290 + height: 75 + x: 10 + y: -10 + align: BOTTOM_LEFT + +text_sensor: + - platform: homeassistant + name: "Garage Light" + entity_id: light.garage_garage_lights + id: indoor_garage_light_switch + on_value: + then: + - if: + condition: + lambda: |- + return x == "on"; + then: + - lvgl.label.update: + id: light_status_label + text: "Garage Lights: On" + else: + - lvgl.label.update: + id: light_status_label + text: "Garage Lights: Off" + +# Enable logging +logger: + level: DEBUG + +###################### REPLACE BELOWWITH YOUR OWN CONFIG ###################### +# +# Below is just an example reference of the remaining ESPHome device configuration. +# The easiest way to get started is to use the ESPHome dashboard and make a new +# device. You can then copy the configuration from above into there. +# +############################################################################### + +# Enable Home Assistant API +api: + encryption: + key: "" + +ota: + - platform: esphome + password: "" + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + + # Enable fallback hotspot in case wifi connection fails + ap: + ssid: "Picocalc Fallback Hotspot" + password: "" + \ No newline at end of file diff --git a/Pictures/homeassistant_example.jpg b/Pictures/homeassistant_example.jpg new file mode 100644 index 0000000..b0932fb Binary files /dev/null and b/Pictures/homeassistant_example.jpg differ