Compare commits

..
149 Commits
Author SHA1 Message Date
randy aa3e59bb0a mcu-eworkbench: AT6668 (Cap LoRa-1262) on the casic platform in place of the NEO-6M
CI / YAML lint (push) Successful in 7s
CI / ESPHome config validation (push) Failing after 55s
2026-11-30 13:36:24 +01:00
randy 71c31035e5 xiao-stm32c5: CANopen node package (canopen + canopen_entities, MCUboot, OTA over CAN), node 0x20 and the TinyUF2 eraser 2026-11-29 12:24:04 +01:00
randy 0c93059c78 mcu-tracker: drop the modem pin to 200bf69035, fixed in esphome#23238 2026-11-29 12:24:04 +01:00
randy 6be43cb95e stackchan: NFC reader polled from the head touch interval, its RF field caused phantom touches 2026-11-29 12:24:04 +01:00
randy 44b0601bf2 mcu-can-node-2: on-board blue LED on GPIO2 as a locate LED 2026-11-29 12:24:04 +01:00
randy fdb9fd4796 mcu-tbeam: T-Beam v1.1 as a geolocation test receiver (NEO-6M on ubx, OLED, AXP192 battery, NAV-SVINFO test aid)
CI / YAML lint (push) Successful in 5s
CI / ESPHome config validation (push) Successful in 59s
2026-11-28 16:40:34 +01:00
randy dd88807a1b mcu-eworkbench: gnss hub renamed to geolocation in esphome/esphome#23293 and #23301 2026-11-28 14:15:12 +01:00
randy 0ea4aaf685 stackchan: 5 V BUS sequenced at boot, BMI270 shake, ST25R3916 NFC, HA say/pet/shake actions
CI / YAML lint (push) Successful in 7s
CI / ESPHome config validation (push) Successful in 1m16s
The BUS was switched on at once in setup(); from the battery the inrush pulled
a converter under its UVP threshold and the AXP2101 powered off. Now the UVP
power-off is cleared and the BUS ramps up in pulses (as in m5stack/esphome-yaml
discussion #129). NFC UID is shown under a surprised face, head taps around a
tag change are ignored.
2026-11-27 11:42:02 +01:00
randy 64c25f6165 mcu-nrf-ant, mcu-nrf-dk: Garmin Varia vehicles, distance, closing speed, fast vehicle
CI / YAML lint (push) Successful in 5s
CI / ESPHome config validation (push) Successful in 52s
2026-11-27 00:06:02 +01:00
randy 7d27f8a005 mcu-eworkbench: GNSS bench with a u-blox M10 (ubx) and a NEO-6M (nmea) from esphome#23301, IPv6 only, generic flash chip 2026-11-26 18:19:54 +01:00
randy 15242c38ee tracker: modem from before esphome#22817, which leaves the SIM7600's SIM powered down
CI / YAML lint (push) Successful in 6s
CI / ESPHome config validation (push) Successful in 56s
2026-11-24 13:34:58 +01:00
randy ae7035c597 mcu-m5core2: mlx90640 from esphome-components, without the web UI 2026-11-24 12:08:58 +01:00
randy c306d87acf mcu-nrf-ant: NFC tag with a Home Assistant tag URL 2026-11-24 11:52:38 +01:00
randy c6b1cfd00d mcu-air-office-r: IPv6 only 2026-11-24 11:30:39 +01:00
randy 78644969ba ipv6_only: lwip fork rebased on IDF 6.1.1, pr#19750 merged 2026-11-24 11:30:39 +01:00
randy 27cbbbe217 mcu-trainer: rename trainer devices, add mcu-trainer-ant
CI / YAML lint (push) Successful in 6s
CI / ESPHome config validation (push) Successful in 53s
mcu-lvgl-trainer -> mcu-trainer, mcu-dimmer -> mcu-trainer-fan (Trainer Fan).
mcu-trainer-ant: ANT+ receiver on an Ebyte E104-BT5040U dongle (Open DFU),
without USB since the USB stack holds HFCLK and RadiANT can't start the HFXO.
mcu-trainer receives its values over UART (GPIO17/18) with packet_transport.
2026-11-23 23:37:02 +01:00
randy 2acb5c8506 mcu-its-g5: IPv4 only, MQTT never connected on the car hotspot
CI / YAML lint (push) Successful in 5s
CI / ESPHome config validation (push) Successful in 56s
The hotspot (O2 SK) has no IPv6, but with IPv6 enabled MQTT resolves the
broker's AAAA record first even with only a link-local address, and
never falls back to IPv4.
2026-11-23 15:59:35 +01:00
randy 547dea26e3 mcu-its-g5: decoded header as JSON on mcu-its-g5/decoded, 1 Hz per station
CI / YAML lint (push) Successful in 6s
CI / ESPHome config validation (push) Successful in 58s
Message type, station type and id, position, speed and heading from the
GeoNetworking header, so consumers don't need an ASN.1 decoder. Outside
its/<node>/#, so the EMQX bridge keeps it off OpenTrafficMap.
2026-11-19 00:24:44 +01:00
randy 3676c0bbcc mcu-its-g5: MQTT only, to the own broker with an EMQX bridge to OpenTrafficMap
CI / YAML lint (push) Successful in 7s
CI / ESPHome config validation (push) Successful in 58s
HA can't reach the API on the car hotspot, so the device talks MQTT to the own
broker like the tracker; EMQX forwards its/<node_id>/# to cits1.opentrafficmap.org.
API and homeassistant time removed, the OTA key set directly.

MQTT discovery unique ids with the MAC (its-g5 and tracker): the default
ESP<type><object_id> made the common entities of both devices clash in HA.
Uptime in "d": HA MQTT discovery rejects "days" with device class duration.
2026-11-17 21:59:19 +01:00
randy 177bdcb3de hosted/xiao-c6-spi: esp-hosted co-processor firmware for the mcu-its-g5 XIAO ESP32-C6
CI / YAML lint (push) Successful in 6s
CI / ESPHome config validation (push) Successful in 1m15s
2026-11-16 22:07:33 +01:00
randy 523957d30d mcu-its-g5: ITS-G5 receiver on a XIAO ESP32-C5 with Wi-Fi on a XIAO ESP32-C6 2026-11-16 21:56:33 +01:00
randy a0e216fcf1 ipv6_only: back on pr#19750, the IPv4-off build is fixed there 2026-11-16 19:51:53 +01:00
randy 775cf085fe stackchan: m5ioe1 from our components, voice_assistant from dev 2026-11-16 19:51:25 +01:00
randy c913af2814 lvgl: Pip-Boy UI with STAT, DATA, MAP and SYS tabs 2026-11-16 19:51:25 +01:00
randy faa4fe43f3 cnc-pendant: handwheel autolock, Tiny5 Mono font 2026-11-16 19:51:25 +01:00
randy f8142505b7 cec-bedroom: hdmi_cec from dev, IPv6-only, no physical_address option 2026-11-16 19:51:25 +01:00
randy 16fde5016e car-can: plain esp32 variant instead of the m5stamp-pico board 2026-11-16 19:51:01 +01:00
randy 885fc5a016 tracker: restore the OLED status screen dropped in b660638 2026-11-16 19:49:14 +01:00
randy 3cafd749d3 stm32: F4 Discovery and miniSTM32F103ZE-EK, button debounce, ST-LINK serials
CI / YAML lint (push) Successful in 7s
CI / ESPHome config validation (push) Successful in 53s
2026-11-07 11:20:18 +01:00
randy 93f622f430 mcu-m5core2: M5GFX SH1107 init on boot for the Unit OLED
CI / YAML lint (push) Successful in 18s
CI / ESPHome config validation (push) Successful in 1m5s
2026-11-05 13:32:04 +01:00
randy 9c20f605d2 nrf: packet_interface link with reliability and session, add Tacx Neo 2
The DK <-> ANT UART link now runs packet_transport over packet_interface:
HDLC retransmits lost frames and the session layer reports in HA whether
mcu-nrf-ant is reachable (ANT Link). Tacx Neo 2 (FE-C, ANT ID 13888)
publishes power, cadence and in use.
2026-11-05 13:31:29 +01:00
randy 0383ea9871 m5core2: MLX90640 thermal camera, backlight voltage
MLX90640 on Port C through the randybb fork without a web server, a
camera entity and sensors in HA and a thermal page on the LCD (32x24
upscaled bilinear with the iron palette). DC3 is set to 3.3 V on boot:
the AXP192 forgets it when the Faces battery runs flat and the LCD stays
dark.
2026-11-05 11:46:47 +01:00
randy a57b678401 car-can: Auris CAN sniffer on a Stamp Pico, body, engine, climate and trip computer signals
CI / YAML lint (push) Failing after 13s
CI / ESPHome config validation (push) Successful in 58s
2026-11-04 00:01:02 +01:00
randy 0f72e3e9bc m5core2: on_node to Home Assistant as a disabled example
randy_home's Meshtastic integration already gives HA every node.
2026-11-03 16:37:50 +01:00
randy ad2a00f674 m5core2: LoRa868 on Meshtastic LongFast, ESP32 advanced options
CI / YAML lint (push) Failing after 13s
CI / ESPHome config validation (push) Successful in 58s
Modded LoRa868 module (NSS G19, DIO0 G35) with the meshtastic component:
received messages on the LoRa page, typed lines sent to LongFast. Flash
chip, chip revision and SRAM1 as IRAM set as the boot log suggests.
2026-11-03 15:40:21 +01:00
randy bf88390257 nspanel_terminal: update to v0.8.0 with lvgl_iram, fix build warnings 2026-11-03 11:25:46 +01:00
randy a7215bdef9 m5core2: Unit LCD invert and sleep switches 2026-11-03 09:59:03 +01:00
randy 7cef9c674d m5core2: Unit LCD on its own LVGL instance
CI / YAML lint (push) Failing after 15s
CI / ESPHome config validation (push) Successful in 59s
lvgl_unit (rotation 90 in LVGL) shows the clock, the last keyboard line
and a battery bar; page actions name lvgl_main now that there are two
instances.
2026-11-03 01:38:02 +01:00
randy 2d3754bf79 m5core2: Core2 on the Faces Bottom II with the QWERTY face
IPv6-only, LVGL demo with the ESPHome boot/status page, a keyboard page
and AXP192 diagnostics; the three touch buttons below the LCD switch pages.

- Faces QWERTY and CardKB through m5stack_keyboard into a text area
- AXP192: LCD power/reset and the M-Bus 5V boost on boot, charging set
  to 4.1 V / 360 mA for the 600 mAh Faces battery and its ADCs read
  directly (the m5stack axp192 component uses the AXP2101 layout)
- Faces LED strips (G2) as light and status LED; G2 is also the speaker
  DOUT, so no speaker or voice assistant for now
- BM8563 RTC, synced from Home Assistant
- Port C as a second I2C bus: Unit OLED (SH1107, offset_x 32), Unit LCD
  through m5stack_st7789v2, CardKB
2026-11-03 01:32:34 +01:00
randy d60c604967 aixun-h310d: fix path 2026-11-03 00:35:47 +01:00
randy 4e7fca4883 aixun-h310d: switch to ext component repo 2026-11-03 00:15:01 +01:00
randy 5f4a227f27 aixun-h310d: memory wipe of my hot air station 2026-11-03 00:12:21 +01:00
randy ad15557c50 nspanel_terminal: update to v0.7.1, drop the deprecated panel_id
CI / YAML lint (push) Failing after 19s
CI / ESPHome config validation (push) Successful in 4s
2026-11-01 01:56:28 +01:00
randy a5dff6fb15 nspanel_terminal: name the MDI glyphs in the icon fonts
CI / YAML lint (push) Failing after 15s
CI / ESPHome config validation (push) Successful in 1m5s
2026-10-31 23:36:46 +01:00
randy 203fc5e26d nspanel_terminal: heating icons on the home page
A row of state icons above today's weather, filled by packages (the first
one on the right):
- fireplace_icon.yaml: the fireplace burning or out.
- radiator_icon.yaml: per thermostat; disabled while it does not call for
  heat, off while it does but the off-peak tariff has the boiler hard off and
  the fireplace is out, on while it heats.
Both hide outside the heating season (boiler switch off, fireplace out).
2026-10-31 23:33:27 +01:00
randy 697af24f47 nspanel_terminal 0.7.0
Streams LVGL flush areas instead of mirroring the frame; protocol and TFTs
unchanged, so no TFT upload is needed.
2026-10-31 19:21:16 +01:00
randy 17bbf207e4 Move zephyr fork configs to the nrf: and stm32: platform keys
The fork's framework-zephyr rewrite drops the zephyr: key: variant and
board stay on the platform key, the other options move under framework:.
CI skips the Zephyr RTOS platform keys instead of zephyr:.
2026-10-31 16:15:00 +01:00
randy 7b9430c0e5 nspanel_terminal 0.6.0
CI / ESPHome config validation (push) Successful in 6s
CI / YAML lint (push) Failing after 14s
Faster PackBits encoding and DATA framing on the ESP32; protocol and TFTs
unchanged, so no TFT upload is needed.
2026-10-31 13:14:00 +01:00
randy 3759a7b61c nspanel_terminal 0.5.0, even home page margins; pin the IPv6-only wifi PR
nspanel-terminal 0.5.0 (protocol 7, native 93 TFT) is untagged, so it is
pinned to its release commit. The home page uses the 16 px page margin on
every side, measured on the glyph ink; the clock shrinks to 100 px so it
clears the forecast column.

The current head of esphome/esphome#19750 does not build with the IPv4 stack
off (IPV6_ROAM_SETTLE_MS is defined under USE_WIFI_LEASE_CACHE but used under
USE_NETWORK_IPV6), so the PR is pinned to be1f55d until that is fixed.
2026-10-31 10:32:23 +01:00
randy e3687d321d nspanel_terminal: upstream v0.4.0, larger arrow touch areas, '-' in the clock font
CI / YAML lint (push) Failing after 15s
CI / ESPHome config validation (push) Successful in 4s
The fixes of ptaru/nspanel-terminal#1 are released in v0.4.0, so the fork is
no longer needed. The page arrows get an 88x64 touch area; grid pages and the
thermostat move their content below it. The clock font gets '-' for the
placeholder shown while connecting.
2026-10-31 00:25:46 +01:00
randy cafa2da954 nspanel: drop the nspanel_lovelace leftovers
CI / YAML lint (push) Successful in 7s
CI / ESPHome config validation (push) Successful in 1m7s
No panel uses common/nspanel.yaml, nspanel_popup.yaml,
nspanel_sleep_dim.yaml or the lui.tft secret any more.
2026-10-30 18:26:15 +01:00
randy 9b5229323f nspanel: all panels on nspanel-terminal with the LVGL UI
The shared UI (home, light detail, status/boot page, notifications, OTA
progress, display hardware) moves from mcu-nspanel-dev.yaml into
common/nspanel_terminal/panel.yaml. office-r, patio, fireplace, office-j
and bedroom move from nspanel_lovelace to it with the pages, tiles and
buttons of their former cards.

thermostat.yaml carries its page and takes an id prefix, so a panel can
have more than one (fireplace). The thermostat returns to the HA target
5 s after sending, in case HA rejects the change. Idle timeout 15 s.
2026-10-30 18:20:45 +01:00
randy 5976d81d1c nspanel-dev: report the NTC temperature to HA again 2026-10-30 17:38:33 +01:00
randy 071637f589 secrets.yaml.default: tft_url_terminal for nspanel-dev 2026-10-30 17:25:52 +01:00
randy 53f0dec88e nspanel-dev: nspanel-terminal from the GitHub fork instead of a local checkout
randybb/nspanel-terminal@upload-and-redraw-fixes carries the fixes of
ptaru/nspanel-terminal#1; switch to upstream once that is merged.
2026-10-30 17:24:29 +01:00
randy 53c427e99c nspanel-dev: LVGL UI on nspanel-terminal instead of nspanel_lovelace
The display runs the ptaru/nspanel-terminal TFT and ESPHome draws the UI
with LVGL (component from a local checkout for now, see PR
ptaru/nspanel-terminal#1).

Pages: home (clock, weather, forecast, temperatures), lights, outside,
irrigation, thermostat, gate, status/boot screen; light detail with
brightness, colour temperature or hue on long press. Grid tiles come
from packages in common/nspanel_terminal/ that add themselves to a page.
Unavailable entities are greyed out, OTA progress shows on the status
page, sleep dim and the notify/show_info actions match the other panels.
2026-10-30 17:20:44 +01:00
randy 0e7dc6591f stackchan: voice_assistant fix from the fork branch instead of a local path
CI / YAML lint (push) Successful in 7s
CI / ESPHome config validation (push) Successful in 1m14s
2026-10-27 22:10:03 +01:00
randy ab45a776fa stackchan, tracker: github:// shorthand without the components path, dev rejects trailing text now 2026-10-27 22:02:47 +01:00
randy a07bce90f9 stm32-*" initial stm32 (zephyr) devices 2026-10-27 21:17:53 +01:00
randy cf49f238ca stackchan: fix mic issues 2026-10-27 21:16:41 +01:00
randy 6389bbdcef lvgl trainer: add display idle 2026-10-27 21:16:06 +01:00
randy 5e7e4f065e pow washer: move to ipv6 only network 2026-10-27 21:14:46 +01:00
randy b660638999 tracker: plain dev modem, GNSS from the +CGNSSINFO URC
CI / YAML lint (push) Failing after 4s
CI / ESPHome config validation (push) Failing after 4s
pr#14683 brought rssi, ber, network_type and urc to dev, but no GNSS, so the
fork of pr#9802 is gone. GNSS is switched with modem.send_at and the position
is parsed from the URC until the modem gets official GNSS support. The device
tracker also gets the accuracy (DOP * gnss_uere_m), the vertical accuracy and
the battery level.
2026-10-24 23:45:56 +02:00
randy 5025159798 tracker: own MQTT user, so the broker ACL limits it to its own topics
CI / ESPHome config validation (push) Failing after 6s
CI / YAML lint (push) Failing after 52s
2026-10-24 12:48:05 +02:00
randy 342ef79771 tracker: modem sensors, GNSS device tracker, battery, data diet
- modem from dev, sensors from pr#9802 via randybb/esphome@modem-gnss-fix
  (fix for the AT+CGPS=1 resend loop), signal/network/operator, GNSS switch
- position as an MQTT device_tracker (discovery sent on connect), one JSON
  on a ~50 m move or hourly
- GNSS and its antenna off while parked, a short look every 30 min
- AXP192 battery: coulomb counter SoC calibrated on a full charge, voltage
  estimate until then, 10 % steps to HA, USB power, Battery Low, power off
  below 3.3 V without USB
- O2 Telemetria data diet: no MQTT logs, 10 min keepalive, values only on
  change or hourly, text sensors on change, PMU details internal
- SNTP every 6 h, time and position on the OLED
2026-10-24 10:36:26 +02:00
randy a110e0c536 tracker: drop the AT+CFUN=1 workaround, pr#6721 sets the APN after the SIM is ready now 2026-10-23 23:40:19 +02:00
randy 1b003fd167 tracker: modem over PPP with MQTT, OLED status, cleanup
- modem from pr#6721 only, enabled from on_boot after the power-up sequence
- AT+CFUN=1 in init_at: the component sets the APN while the radio is off
- signal and network mode parsed from +CSQ/+CPSI URCs
- MQTT instead of API (no WiFi for now), status/uptime/version/restart/IP entities
- SSD1306 OLED with network, signal, PPP/MQTT state, IP and uptime
- AXP192 from m5stack, pinout and I2C header, drop old commented configs
2026-10-23 18:10:11 +02:00
randy 72afe7c622 all esp32*: back to pr#19750
CI / ESPHome config validation (push) Failing after 5s
CI / YAML lint (push) Failing after 1m2s
2026-10-23 15:08:01 +02:00
randy ff092cbe20 nrf-*: add j-link sn & instructions for flashing
CI / ESPHome config validation (push) Failing after 6s
CI / YAML lint (push) Failing after 22s
2026-10-22 12:12:03 +02:00
randy 1bd695fac0 clock-1: gpio9 is not available, use gpio10 instead 2026-10-22 12:11:04 +02:00
randy b3d4a01f67 ipv6_only: mdns is on 1.14.0 so we can drop it, fix ipv6 only due latest changes 2026-10-22 12:10:18 +02:00
randy 52cc85d62b heater, mains-power: add sub device relation - child 2026-10-22 12:08:50 +02:00
randy 7e0e26c329 ipv6_only: network and co. from the PR merged with dev
CI / YAML lint (push) Failing after 27s
CI / ESPHome config validation (push) Successful in 56s
The head of esphome/esphome#19750 lags behind dev, its const overrides
the one of dev and esp32 fails to load ("Platform missing"). The fork
branch has the PR merged with dev and leaves const alone.
2026-10-20 22:54:35 +02:00
randy 2b9b825d79 rfid-openprintag: lower ext component refresh 2026-10-20 20:04:04 +02:00
randy 09afa56cdb cnc pendant: channel_colors instead of rgb_order for the status LED
CI / YAML lint (push) Failing after 4s
CI / ESPHome config validation (push) Successful in 1m0s
2026-10-15 17:26:03 +02:00
randy b4e03f3dec bedroom lamps: switch back to mmakaay's component
CI / YAML lint (push) Failing after 4s
CI / ESPHome config validation (push) Successful in 1m2s
2026-10-14 19:42:17 +02:00
randy 3374ed6ad8 staircase-light: add second PIR sensor
CI / ESPHome config validation (push) Failing after 5s
CI / YAML lint (push) Failing after 19s
2026-10-10 17:50:24 +02:00
randy e5f9c5813e stackchan: 40MHz flash, the IDF 5.5.5 bootloader misreads this flash at 80MHz 2026-10-10 17:41:05 +02:00
randy 2b66f1a60d echo-1: WAV media format, decoding MP3/FLAC without PSRAM runs the heap out 2026-10-10 17:41:05 +02:00
randy 05060756e3 OpenPrintTag reader: filament color light falls back to the Creality tag
CI / ESPHome config validation (push) Failing after 6s
CI / YAML lint (push) Failing after 17s
2026-10-10 12:35:49 +02:00
randy 7cc90187d1 ipv6_only_eth: mdns 1.14.0 from the registry instead of the fork 2026-10-10 12:35:49 +02:00
randy 26a09b37bc all esp8266: LEAmDNS fork announcing IPv6 addresses (esp8266/Arduino#9068) 2026-10-10 12:33:12 +02:00
randy 4c45ebdc4a all esp32: disable wifi power saving
CI / YAML lint (push) Successful in 8s
CI / ESPHome config validation (push) Successful in 1m2s
2026-10-08 22:52:25 +02:00
randy 2ad74b9d05 all esp8266: switch to native toolchain 2026-10-08 22:51:21 +02:00
randy b1b57818df fireplace, heater: switch to native ds248x component + cleanup 2026-10-08 22:50:00 +02:00
randy 1a83052d90 Spool reader: Creality CFS tags too
CI / YAML lint (push) Successful in 9s
CI / ESPHome config validation (push) Successful in 57s
creality_cfs reads the Creality tags of the spools, sends their record
to Home Assistant (esphome.creality_cfs) and writes them through the
creality_cfs_write action; the success tune gets a valid default
duration.
2026-10-05 21:22:36 +02:00
randy 8eae480253 OpenPrintTag reader: pn5180 and openprinttag components, red flash on writes
CI / YAML lint (push) Failing after 17s
CI / ESPHome config validation (push) Successful in 55s
The reader config follows the split of pn5180 into the reader and the
openprinttag component; the notify LED flashes red while the
integration writes to a tag.
2026-10-03 18:18:42 +02:00
randy 5fdacb82df OpenPrintTag reader: aux write action for the integration
CI / YAML lint (push) Failing after 17s
CI / ESPHome config validation (push) Successful in 51s
openprinttag_write_aux lets the OpenPrintTag integration's
openprinttag.update write the consumed weight and other aux values
to the tag on the reader.
2026-10-03 13:55:21 +02:00
randy 9eb5cd9155 OpenPrintTag reader: send the tag record to Home Assistant
esphome.openprinttag event with the uid and the raw record (empty when
the tag is removed) for the OpenPrintTag integration
(randybb/ha-openprinttag).
2026-10-03 13:20:40 +02:00
randy b8f8649833 OpenPrintTag reader: M5Stamp S3 with a PN5180
Filament spool tags to Home Assistant through the pn5180 component of
randybb/esphome-components, the color also as a light. Onboard LED for
tag feedback and status until the external LED is fitted, buzzer on
GPIO4.
2026-10-03 12:48:56 +02:00
randy 5fdea643a7 rfid-reader: use a valid RTTTL default duration (d=32)
ESPHome only accepts d=1/2/4/8/16/32 now; d=24 was rejected and the
success/write tones never played.
2026-10-03 10:51:23 +02:00
randy 4bbf26fc87 Update comment about upstream mdns component
CI / YAML lint (push) Failing after 17s
CI / ESPHome config validation (push) Successful in 1m0s
2026-10-02 17:46:59 +02:00
randy 427e9ac136 IPv6-only for the Ethernet gateway
Split the WiFi part off common/ipv6_only.yaml into common/ipv6_only_eth.yaml
and use it on mcu-gateway. The #19750 component list needs ethernet,
otherwise the stock component still runs DHCPv4. mdns from the fork also
carries the IPv6 fix for ETH-only builds (espressif/esp-protocols#1161).
2026-10-01 23:49:02 +02:00
randy 005c9903bf Disable api reboot timeout for kitchen lights due flaky wifi (thanks ubiquiti!)
CI / YAML lint (push) Failing after 17s
CI / ESPHome config validation (push) Successful in 51s
2026-10-01 12:37:09 +02:00
randy db57574497 Fix crashing, display cs and fonts for cnc pendant
CI / YAML lint (push) Failing after 18s
CI / ESPHome config validation (push) Successful in 49s
2026-10-01 01:38:21 +02:00
randy fd7a4c98b5 Add initial mcu-cnc-pendant configuration 2026-10-01 00:50:41 +02:00
randy 2e8b678072 nrf-ant, nrf-dk: two-way UART on the DK default pins, wires crossed
Both boards use UART1 RX P1.01 / TX P1.02 so Home Assistant data can reach
the ANT+ node's transmitters; on the default pins the ANT+ node no longer
needs the RX pin workaround.
2026-09-30 23:15:10 +02:00
randy 3f9a8c3117 nrf-ant: Garmin HRM-Dual, HRM-Tri, Rally RS200, Speed Sensor 2, SRAM Force AXS
CI / YAML lint (push) Successful in 8s
CI / ESPHome config validation (push) Successful in 50s
Also sets the unused UART1 RX to P1.02: without it the fork keeps the DK's
default RX pin, P1.01, and the UART hears its own transmissions.
2026-09-30 22:13:33 +02:00
randy 38ede7fab6 nrf-ant: Garmin HRM-Pro, Concept2 PM5, Garmin Tempe, Garmin Varia RTL515, status LEDs
LED 1 lights while a configured ANT+ device is received, LED 2 while an
unconfigured one is in range; everything is forwarded to mcu-nrf-dk.
2026-09-30 21:55:04 +02:00
randy ad9aeea346 nrf-dk: Thread MTD, frees 52 KB of the MCUboot slot (98 % -> 87 %) 2026-09-30 21:34:17 +02:00
randy 3a397cfb4b ANT+ via ESPHome: mcu-nrf-ant (RadiANT) sends heart rate to mcu-nrf-dk over packet_transport
Replaces the E73 running the archived nrf-ant-bridge firmware and drops
mcu-ant-host, which read that bridge's line protocol.
2026-09-30 21:17:20 +02:00
randy 6fd5ee1fa7 Add ant-host: host ESPHome reading an ANT+ bridge over serial 2026-09-30 20:07:57 +02:00
randy eb25302e9b nrf-dk: Thread, buttons, LEDs and ANT+ heart rate from the E73 bridge 2026-09-30 20:07:57 +02:00
randy 34929a38c7 CI: skip zephyr: configs, they need the esphomeplatformzephyr fork 2026-09-30 20:07:57 +02:00
randy 0536e91fd1 CI: work on Gitea's runner image too
CI / YAML lint (push) Successful in 5s
CI / ESPHome config validation (push) Successful in 10s
Install yamllint with pip instead of ibiqlik/action-yamllint, which expects
it preinstalled like on GitHub's runner, and pip install with
--ignore-installed so pip doesn't try to remove Debian's packages.
2026-09-30 14:50:33 +02:00
randy 7374ddf4d6 Drop the speaker override, esphome#19862 is merged
CI / YAML lint (push) Failing after 32s
CI / ESPHome config validation (push) Failing after 37s
2026-09-30 12:35:53 +02:00
randy a005b940b2 rfid-reader: take the NDEF records by reference
get_records() now returns a StaticVector of unique_ptr, which can't be copied.
2026-09-30 12:15:49 +02:00
randy 46cf3b1fe8 OTA: require encryption with the api key, plaintext + password only for migration
allow_plaintext_upload lets the uploader give a device that doesn't encrypt
yet its one migration install. Remove it together with the password once
every device has been updated (the uploader says so).
2026-09-30 12:05:39 +02:00
randy bb76912023 Set framework.advanced.flash_chip on ESP32 devices to save IRAM
Values come from ESPHome's own hint in the log of each online device
("Set flash_chip: ... to save IRAM"). Devices that were off got the value of
an identical board (ESP32-PICO-D4 ATOM/Stamp Pico: gd, JC3248W535: generic,
POW Elite: gd), marked as not read from the device.
2026-09-30 11:57:30 +02:00
randy 831d88689d CI: Node 24 actions, pip on PEP 668 runner images, drop committed build cache
- actions/checkout@v7 and tj-actions/changed-files@v47 (Node 20 is deprecated)
- PIP_BREAK_SYSTEM_PACKAGES for Gitea's runner image (externally-managed Python)
- untrack common/.esphome (a gitlink with no submodule mapping) and ignore
  .esphome/ in every directory
2026-09-30 11:21:55 +02:00
randy 170fd69274 Fix yamllint errors: trailing spaces, blank lines and newline at end of file
Allow aligned values after a colon (the bedroom lamp presets).
2026-09-30 11:08:22 +02:00
randy 89763817f6 bedroom lamps: use the xiaomi_bslamp2 fork with the ESPHome 2026.10 light fix 2026-09-30 10:53:16 +02:00
randy 03ca4e98b5 status_led: show component errors only on a dedicated status LED (show_errors)
The ATOM LED gets them; displays and lights that are also normal lights don't,
so a failed component can't take them over.
2026-09-30 10:12:06 +02:00
randy fb66547dd1 status_led: don't show component errors, only network, API and OTA 2026-09-30 09:00:58 +02:00
randy 725c400de6 atoms3: full-screen status, IPv6-only, animation as image platform, fix colours
The status (common/status_led.yaml) drives a virtual RGB light that fills
the display; the display needs little-endian RGB565 (colours were swapped).
2026-09-30 08:58:16 +02:00
randy 7517c301ac Status LED on every ATOM device (except the vehicle beacons)
common/status_led_atom.yaml puts common/status_led.yaml on the ATOM Lite's
own RGB LED (G27, 64 RMT symbols to leave room for IR/RF). echo-1 uses its
existing LED light.
2026-09-30 08:58:16 +02:00
randy 422b334582 air-office-r: LEDs back on (the stick had lost its GND), status on the NEO stick 2026-09-30 08:29:19 +02:00
randy 2f5e438424 Move remaining NSPanel's to IPv6 Only network 2026-09-30 08:08:12 +02:00
randy 6a3002d9b7 Add status_led package: network, API, error and OTA status on a visible RGB light
CI / ESPHome config validation (push) Failing after 7s
CI / YAML lint (push) Failing after 37s
Red blink without network, orange without an API client, purple on a
component error, blue blink during OTA, green when things are back to
normal, then the light returns to its previous state.

echo uses it on the gateway LED ring; drop its status_led on GPIO23,
which never worked because the ledc output owns that pin.
2026-09-29 23:33:50 +02:00
randy 6845679bc0 echo: only the gateway LED ring is visible, the ATOM LED is inside 2026-09-29 23:24:39 +02:00
randy a3950d9f17 echo: it's a Xiaomi Mijia Gateway with an ATOM Echo brain transplant 2026-09-29 23:23:44 +02:00
randy 0d6aa6e3d7 nspanel-patio: jump straight to the Von card
Temporarily make it the default page and render it once, instead of
rendering home, next and next.
2026-09-29 23:23:14 +02:00
randy 271a5a5a54 nspanel: popups for OTA progress and device info, Info card on every panel
common/nspanel_popup.yaml shows a popupNotify page during OTA (written straight
to the display uart, since OTA blocks the loop that sends the component's
queued commands) and a device info popup (version, build time, IPs) from the
Info button on the new last card or the show_info API action. The OTA gets
id ota_esphome to extend it. Also documents the NSPanel pinout.
2026-09-29 23:23:14 +02:00
randy c5ab280725 air-office-r: document hardware, disable the LEDs until the stick is fixed
The TZT 8-bit WS2812 stick lights up random colours after the first LED.
2026-09-29 23:22:17 +02:00
randy 1a2aec5d01 Document hardware, pinout and I2C devices in a header comment of every device
Merge the old pinout comment blocks into the header and mark what each pin is used for.
2026-09-29 23:22:17 +02:00
randy 882428e491 Move echo's to ipv6 only network 2026-09-29 21:53:38 +02:00
randy 20f6db5a70 ipv6_only: take audio from esphome#19750 2026-09-29 19:42:15 +02:00
randy b8738b39e0 fix: update patio status entity ID to match old naming convention
CI / ESPHome config validation (push) Failing after 9s
CI / YAML lint (push) Failing after 38s
2026-09-29 08:38:48 +02:00
randy 7ee975875a nspanel-patio: right button toggles the relay unless mcu-patio is online
CI / ESPHome config validation (push) Failing after 7s
CI / YAML lint (push) Failing after 38s
2026-09-29 00:03:03 +02:00
randy dd508aec99 m5paper: replace the weather forecast with a calendar (birthdays, waste collection), wake up once a day, IPv6-only 2026-09-28 23:40:13 +02:00
randy e13be73596 m5paper: clear-night icon for sunny hours without UV, center hourly temperature without precipitation 2026-09-28 23:13:31 +02:00
randy b523963944 TFT: switch to LVGL, add XPT2046 touch 2026-09-28 23:13:00 +02:00
randy 6ca813fb64 Pin speaker override (esphome#19862) for stackchan/echo, migrate echo codec option, refresh components hourly 2026-09-28 22:41:08 +02:00
randy d80abdbb90 Add IPv6 WiFi credentials to secrets.yaml.default to fix CI 2026-09-28 22:03:38 +02:00
randy 29b375df68 nspanel: move shared config to common/nspanel.yaml, add TFT version sensor
CI / ESPHome config validation (push) Failing after 7s
CI / YAML lint (push) Failing after 37s
2026-09-28 20:51:05 +02:00
randy 5db5987405 ipv6_only: pin patched lwip so .local names resolve over IPv6 (esp-lwip#94) 2026-09-28 20:12:22 +02:00
randy dec5e5de0a ipv6_only: pin audio override so HTTP reader connects over IPv6 2026-09-28 16:01:28 +02:00
randy 88e1214058 ipv6_only: pin patched espressif/mdns to stop advertising A 0.0.0.0
CI / ESPHome config validation (push) Successful in 10s
CI / YAML lint (push) Failing after 33s
2026-09-28 12:49:33 +02:00
randy 61032ad248 ipv6_only: switch to network enable_ipv4: false (renamed in esphome#19750) 2026-09-28 12:42:17 +02:00
randy 148c51c4df mcu-lvgl-4848s040: add Guition ESP32-S3-4848S040 initial config
CI / ESPHome config validation (push) Failing after 6s
CI / YAML lint (push) Failing after 37s
- mipi_rgb GUITION-4848S040 model, ST7701S init over SPI (48/47)
- GT911 touch mirrored like the image, backlight on GPIO38
- clock and status pages (status until Home Assistant connects),
  same navigation bar as the other LVGL displays
- IPv6-only network
2026-09-27 23:13:33 +02:00
randy cc2ab4c467 Move more devices to the IPv6-only network
Add common/ipv6_only.yaml to mcu-clock-1, mcu-desk-lamp, mcu-dimmer,
mcu-fireplace, mcu-gate, mcu-heater, mcu-kitchen, mcu-mains-power,
mcu-nspanel-office-r, mcu-office-r, mcu-patio, mcu-pow-dishwasher,
mcu-rf, mcu-shed, mcu-well.
2026-09-27 22:51:47 +02:00
randy 504aa06d10 mcu-lvgl, mcu-lvgl-trainer: status page, colored status lines
mcu-lvgl (CYD 4.3"):
- normalized: rpi_dpi_rgb -> mipi_rgb (ESP32-8048S050 pins/timing, pclk
  12.5 MHz), GT911 touch added, platformio_options and default CPU
  frequency dropped, demo meters and duplicate uptime sensors removed
- pages: clock, status (logo, WiFi, IPv6 first, HA, version, uptime);
  status page shown until Home Assistant connects
- same navigation bar and theme as mcu-lvgl-trainer

mcu-lvgl-trainer:
- status lines colored like on the other displays (connected green,
  waiting orange, details gray), stacked in a flex column
- stopwatch format warning fixed
2026-09-27 22:51:47 +02:00
randy 4b6544adfa mcu-tft: status screen until Home Assistant connects
Same boot screen as on the other displays: "Made for ESPHome" logo,
name, WiFi with signal, IPv6 addresses first (link-local skipped),
Home Assistant state, ESPHome version and uptime.
2026-09-27 21:26:07 +02:00
randy 6a51099789 common: ipv6_only package for the IPv6-only IoT network
- common/wifi.yaml: the network gets id wifi_iot, so devices can
  override it with '!extend wifi_iot'
- common/ipv6_only.yaml: add-on package next to any common package;
  switches to the IPv6-only SSID, wifi ipv6_only (SLAAC, no DHCPv4,
  esphome/esphome#19750 as external component until merged) and
  min_ipv6_addr_count: 1
- mcu-lvgl-trainer, mcu-nspanel-dev, mcu-rfid-reader, mcu-stackchan,
  mcu-tft moved to the IPv6-only network
2026-09-27 21:26:02 +02:00
randy 369578a63a mcu-nspanel-office-j: dim the display at night like the bedroom panel
CI / ESPHome config validation (push) Failing after 8s
CI / YAML lint (push) Failing after 38s
Inactive display dim follows the sun (5 % by day, off after dusk at
-6 degrees) and stays at 5 % while light.office_j_lights is on.
Re-applied on time sync, at dawn/dusk and when the lights change.
2026-09-27 20:36:59 +02:00
randy bdf49db1c2 mcu-lvgl-trainer: six pages for the pain cave, fix touch rotation
- touch: drop calibration/transform, the driver defaults to the native
  320x480 panel and LVGL rotates touch points itself (taps were rotated
  by 90 degrees)
- pages: clock (default), basement lights with brightness and color
  temperature for the exercise room (sliders hidden while it is off),
  training start/stop, fan off/50-100 %, stopwatch, status screen with
  "Made for ESPHome" logo and IPv6 first
- light attributes read as text, 'None' while off is skipped
- unused fonts, colors and leftovers removed; ext_uart kept for a
  future ANT+ bridge
2026-09-27 20:31:37 +02:00
randy 349f699572 mcu-stackchan: "Made for ESPHome" logo, IPv6 on status screen
- status screen logo replaced by the official "Made for ESPHome" badge,
  the plain ESPHome logo is not meant for third-party devices
- status screen shows one global IPv6 and one IPv4 address (link-local
  skipped) instead of the IPv4 sensor value
2026-09-27 19:49:57 +02:00
randy 329830e553 mcu-m5paper: rework on M5Stack components, battery mode with forecast
Rewrite of the old config on the core ESPHome components (it8951, gt911,
bm8563, sht3xd):
- USB: always on, forecast screen redrawn every 15 min, forecast
  refreshed every hour and when Home Assistant connects
- battery: BM8563 timer wakes the board every 15 min (off 1:00-5:00),
  it draws the stored forecast and cuts power; WiFi only when the
  forecast is older than 6 h
- mode detected by trying to power off; battery voltage drop on USB
  triggers the battery cycle
- hourly forecast via weather.get_forecasts, 48 h kept in the FM24C02
  EEPROM (include/m5paper_weather.h)
- OTA image confirmed before power-off, battery wake-ups are shorter
  than boot_is_good_after
- status screen with "Made for ESPHome" logo, IPv6 addresses first
2026-09-27 19:49:57 +02:00
randy d813717d2c common: enable ha_time in common packages, devices extend it
Move the homeassistant time platform (id ha_time) into all common
packages. Devices with custom triggers now use '!extend ha_time';
plain duplicate time blocks are removed. mcu-lvgl's unused time_comp
is unified to ha_time.
2026-09-27 16:43:35 +02:00
141 changed files with 192010 additions and 3733 deletions

No files matched your search

+18 -9
View File
@@ -10,35 +10,42 @@ jobs:
name: YAML lint name: YAML lint
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v7
- name: Get changed YAML files - name: Get changed YAML files
id: changed id: changed
uses: tj-actions/changed-files@v46 uses: tj-actions/changed-files@v47
with: with:
files: "**/*.yaml" files: "**/*.yaml"
- uses: ibiqlik/action-yamllint@v3 # yamllint straight from pip: Gitea's runner image doesn't ship it like GitHub's does
- name: Lint changed YAML files
if: steps.changed.outputs.any_changed == 'true' if: steps.changed.outputs.any_changed == 'true'
with: env:
config_file: .yamllint.yml PIP_BREAK_SYSTEM_PACKAGES: "1"
file_or_dir: ${{ steps.changed.outputs.all_changed_files }} run: |
pip install --ignore-installed yamllint
yamllint -c .yamllint.yml -f parsable ${{ steps.changed.outputs.all_changed_files }}
validate: validate:
name: ESPHome config validation name: ESPHome config validation
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v7
- name: Get changed device configs - name: Get changed device configs
id: changed id: changed
uses: tj-actions/changed-files@v46 uses: tj-actions/changed-files@v47
with: with:
files: "mcu-*.yaml" files: "mcu-*.yaml"
- name: Install ESPHome (dev) - name: Install ESPHome (dev)
if: steps.changed.outputs.any_changed == 'true' if: steps.changed.outputs.any_changed == 'true'
run: pip install git+https://github.com/esphome/esphome.git@dev # Gitea's runner image marks the system Python as externally managed (PEP 668)
# and has Debian packages pip can't uninstall (pyparsing), so don't touch them
env:
PIP_BREAK_SYSTEM_PACKAGES: "1"
run: pip install --ignore-installed git+https://github.com/esphome/esphome.git@dev
- name: Prepare secrets - name: Prepare secrets
if: steps.changed.outputs.any_changed == 'true' if: steps.changed.outputs.any_changed == 'true'
@@ -48,6 +55,8 @@ jobs:
if: steps.changed.outputs.any_changed == 'true' if: steps.changed.outputs.any_changed == 'true'
run: | run: |
for f in ${{ steps.changed.outputs.all_changed_files }}; do for f in ${{ steps.changed.outputs.all_changed_files }}; do
# Zephyr RTOS platforms need the esphomeplatformzephyr fork, upstream doesn't know them yet
if grep -qE '^(nrf|stm32|nxp|renesas|silabs):' "$f"; then echo "Skipping $f (zephyr fork)"; continue; fi
echo "Validating $f..." echo "Validating $f..."
esphome config "$f" esphome config "$f"
done done
+1 -1
View File
@@ -2,7 +2,7 @@
# This is an example and may include too much for your use-case. # This is an example and may include too much for your use-case.
# You can modify this file to suit your needs. # You can modify this file to suit your needs.
/.claude/ /.claude/
/.esphome/ .esphome/
/secrets.yaml /secrets.yaml
/archive/ /archive/
/trash/ /trash/
+4
View File
@@ -25,3 +25,7 @@ rules:
comments: comments:
require-starting-space: false require-starting-space: false
# Aligned values (e.g. the bedroom lamp presets) are intentional
colons:
max-spaces-after: -1
+28781
View File
File diff suppressed because it is too large. Load diff
+86576
View File
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1194" height="240" fill="none" viewBox="0 0 1194 240"><g clip-path="url(#clip0_2_63)"><path fill="#18BCF2" d="M240 219C240 227.24 233.24 234 225 234H15C6.76 234 0 227.24 0 219V129C0 120.76 4.78 109.22 10.6 103.4L109.4 4.61999C115.24 -1.22001 124.78 -1.22001 130.62 4.61999L229.4 103.4C235.24 109.24 240 120.76 240 129V219Z"/><path fill="#F2F4F9" d="M160 78.66H80C76.68 78.66 74 81.34 74 84.66V234H86V90.66H154V102.66H104C100.68 102.66 98 105.34 98 108.66V132.66C98 135.98 100.68 138.66 104 138.66H154V150.66H104C100.68 150.66 98 153.34 98 156.66V180.66C98 183.98 100.68 186.66 104 186.66H154V198.66H104C100.68 198.66 98 201.34 98 204.66C98 207.98 100.68 210.66 104 210.66H160C163.32 210.66 166 207.98 166 204.66V180.66C166 177.34 163.32 174.66 160 174.66H110V162.66H160C163.32 162.66 166 159.98 166 156.66V132.66C166 129.34 163.32 126.66 160 126.66H110V114.66H160C163.32 114.66 166 111.98 166 108.66V84.66C166 81.34 163.32 78.66 160 78.66Z"/><path fill="#F2F4F9" d="M423 167.61V190.11H336V49.95H423V72.63H359.82V108.91H416.26V130.01H359.82V167.61H423Z"/><path fill="#F2F4F9" d="M491.08 47.41C503.9 47.41 514.54 50.53 523.04 56.79C531.54 63.03 536.76 71.39 538.7 81.83L516.3 87.93C515.04 81.93 512.12 77.31 507.54 74.05C502.94 70.81 497.28 69.17 490.52 69.17C483.26 69.17 477.52 70.91 473.28 74.37C469.02 77.83 466.9 82.45 466.9 88.19C466.9 97.25 472.52 103.13 483.78 105.81L506.66 111.53C518.48 114.59 527.32 119.45 533.2 126.11C539.08 132.77 542.02 140.97 542.02 150.71C542.02 163.21 537.48 173.31 528.42 181.03C519.36 188.75 507.24 192.61 492.04 192.61C478.36 192.61 466.78 189.39 457.36 182.95C448.04 176.27 442.54 167.45 440.86 156.51L463.26 150.69C464.08 156.87 467.16 161.73 472.5 165.23C477.84 168.73 484.64 170.47 492.9 170.47C501.16 170.47 507.08 168.79 511.6 165.45C516.14 162.11 518.4 157.57 518.4 151.81C518.4 142.81 512.78 136.87 501.52 133.99L478.64 128.45C466.88 125.77 458.06 120.99 452.16 114.15C446.26 107.31 443.3 98.95 443.3 89.07C443.3 76.69 447.7 66.65 456.48 58.93C465.26 51.21 476.8 47.35 491.12 47.35L491.08 47.41Z"/><path fill="#F2F4F9" d="M666.1 95.61C666.1 109.37 661.92 120.49 653.58 128.99C645.24 137.49 634 141.75 619.88 141.75H588.38V190.13H564.56V49.95H620.06C634.3 49.95 645.54 54.07 653.76 62.27C661.98 70.49 666.08 81.59 666.08 95.59L666.1 95.61ZM641.16 95.05C641.16 87.99 638.96 82.25 634.56 77.85C630.16 73.45 623.92 71.25 615.86 71.25H588.4V120.85H615.5C623.74 120.85 630.1 118.51 634.54 113.81C638.98 109.13 641.2 102.87 641.2 95.05H641.16Z"/><path fill="#F2F4F9" d="M687.38 49.95H711.2V108.55L772.98 108.73V49.95H796.98V190.11H772.98V129.83L711.2 129.65V190.11H687.38V49.95Z"/><path fill="#F2F4F9" d="M868.6 92.79C883.1 92.79 894.92 97.45 904.04 106.75C913.16 116.07 917.72 128.03 917.72 142.65C917.72 157.27 913.16 169.15 904.04 178.47C894.92 187.79 883.1 192.43 868.6 192.43C854.1 192.43 842.1 187.77 832.98 178.47C823.86 169.15 819.3 157.23 819.3 142.65C819.3 128.07 823.86 115.97 832.98 106.69C842.1 97.41 853.98 92.77 868.6 92.77V92.79ZM868.6 172.01C876.34 172.01 882.64 169.27 887.5 163.81C892.34 158.35 894.76 151.23 894.76 142.49C894.76 133.75 892.34 126.67 887.5 121.25C882.66 115.85 876.36 113.15 868.6 113.15C860.84 113.15 854.26 115.85 849.38 121.25C844.5 126.65 842.06 133.73 842.06 142.49C842.06 151.25 844.5 158.35 849.38 163.81C854.26 169.27 860.66 172.01 868.6 172.01Z"/><path fill="#F2F4F9" d="M1081.6 129.83V190.11H1059.56V133.29C1059.56 126.73 1057.88 121.61 1054.5 117.91C1051.12 114.23 1046.54 112.37 1040.72 112.37C1034.54 112.37 1029.6 114.39 1025.9 118.41C1022.22 122.45 1020.36 128.09 1020.36 135.33V190.09H998.04V133.27C998.04 126.71 996.4 121.59 993.12 117.89C989.84 114.21 985.3 112.35 979.48 112.35C973.3 112.35 968.32 114.37 964.58 118.39C960.84 122.41 958.96 128.07 958.96 135.31V190.07H936.28V95.39H957.38L958.14 104.49C963.64 96.43 972.6 92.39 985.04 92.39C992.28 92.39 998.58 93.89 1003.88 96.89C1009.2 99.89 1013.22 104.27 1015.98 110.01C1018.3 104.51 1022.12 100.19 1027.46 97.07C1032.8 93.95 1039.16 92.39 1046.54 92.39C1057.28 92.39 1065.82 95.71 1072.14 102.33C1078.46 108.95 1081.6 118.11 1081.6 129.79V129.83Z"/><path fill="#F2F4F9" d="M1193.54 151.11H1120.98C1121.74 158.23 1124.42 163.67 1129.04 167.43C1133.66 171.19 1139.54 173.05 1146.66 173.05C1158.22 173.05 1166.32 168.23 1170.94 158.61L1189.88 166.11C1186.32 174.43 1180.7 180.93 1173.06 185.61C1165.4 190.29 1156.6 192.65 1146.66 192.65C1132.66 192.65 1121.3 188.07 1112.58 178.91C1103.86 169.75 1099.5 157.73 1099.5 142.87C1099.5 128.01 1103.9 115.91 1112.68 106.59C1121.46 97.27 1132.94 92.63 1147.14 92.63C1161.34 92.63 1172.3 97.23 1180.8 106.41C1189.3 115.59 1193.56 127.69 1193.56 142.69V151.13L1193.54 151.11ZM1121.36 135.17H1170.48C1170.04 127.49 1167.72 121.63 1163.5 117.59C1159.28 113.55 1153.6 111.55 1146.48 111.55C1139.36 111.55 1133.66 113.59 1129.24 117.69C1124.8 121.79 1122.18 127.61 1121.36 135.17Z"/></g><defs><clipPath id="clip0_2_63"><rect width="1193.56" height="240" fill="#fff"/></cliLine truncated

Before

Width:  |  Height:  |  Size: 4.9 KiB

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" id="Layer_2" data-name="Layer 2" viewBox="0 0 681.98 201.98"><defs><style>.cls-1{fill:none;stroke:#1d2126;stroke-miterlimit:10;stroke-width:1.01px}.cls-2{fill:#1d2126}.cls-2,.cls-3,.cls-4{stroke-width:0}.cls-3{fill:#f2f4f9}.cls-4{fill:#18bcf2}</style></defs><g id="Layer_1-2" data-name="Layer 1"><g><g><rect width="680.97" height="200.97" x=".51" y=".51" class="cls-3" rx="40.48" ry="40.48"/><rect width="680.97" height="200.97" x=".51" y=".51" class="cls-1" rx="40.48" ry="40.48"/></g><g><path d="M236.13,43.11v26.53h-5.29v-14.5l-5.68,14.5h-5.08l-5.61-14.4v14.4h-5.12v-26.53h5.12l8.16,20.27,8.21-20.27h5.29Z" class="cls-4"/><path d="M259.54,63.84h-9.04l-2.02,5.8h-5.59l9.51-26.53h5.33l9.47,26.53h-5.7l-1.97-5.8ZM258,59.34l-2.95-8.7-2.99,8.7h5.94Z" class="cls-4"/><path d="M296.93,56.42c.02,1.89-.3,3.66-.98,5.31s-1.61,3.06-2.8,4.22-2.61,2.07-4.26,2.73-3.4.98-5.26.96h-9.65v-26.53h9.65c2.43-.04,4.66.52,6.71,1.68s3.67,2.76,4.86,4.82,1.78,4.33,1.74,6.81ZM291.25,56.42c0-2.46-.71-4.46-2.12-5.99s-3.27-2.29-5.58-2.29h-4.22v16.52h4.22c2.34,0,4.21-.75,5.61-2.26s2.09-3.5,2.09-5.99Z" class="cls-4"/><path d="M321.38,64.59v5.04h-16.7v-26.53h16.7v5.1h-11.34v5.66h10.07v4.75h-10.07v5.98h11.34Z" class="cls-4"/><path d="M348.35,48.17v6.1h9.58l-.04,4.82h-9.54v10.55h-5.36v-26.53h16.73l-.04,5.06h-11.34Z" class="cls-4"/><path d="M378.62,42.64c1.9,0,3.66.34,5.27,1.03s2.99,1.63,4.11,2.84,2,2.66,2.63,4.35.94,3.52.94,5.49c.02,1.95-.28,3.77-.91,5.48s-1.52,3.17-2.65,4.39-2.52,2.17-4.15,2.86-3.39,1.03-5.27,1c-2.5.04-4.74-.54-6.72-1.72s-3.52-2.82-4.6-4.92-1.6-4.45-1.56-7.05c-.02-1.95.28-3.77.91-5.48s1.51-3.18,2.65-4.39,2.51-2.17,4.13-2.87,3.37-1.03,5.23-1ZM378.65,64.82c2.24,0,4.01-.76,5.32-2.28s1.96-3.58,1.96-6.2-.65-4.71-1.95-6.22-3.08-2.27-5.33-2.27-4.03.76-5.33,2.27-1.95,3.59-1.95,6.22.65,4.71,1.95,6.21,3.08,2.26,5.33,2.26Z" class="cls-4"/><path d="M419.5,69.64h-6.01l-4.08-9.58h-4.89v9.58h-5.36v-26.53h10.21c3.28.01,5.76.74,7.44,2.19s2.51,3.55,2.51,6.3c0,1.79-.39,3.34-1.17,4.65s-1.89,2.28-3.33,2.91l4.68,10.48ZM413.63,51.6c0-1.15-.36-2.05-1.07-2.72s-1.78-.99-3.18-.99h-4.85v7.49h4.85c1.41,0,2.47-.34,3.18-1.01s1.07-1.6,1.07-2.77Z" class="cls-4"/></g><g><path d="M251.92,146.83v11.25h-43.5v-70.08h43.5v11.34h-31.59v18.14h28.22v10.55h-28.22v18.8h31.59Z" class="cls-2"/><path d="M285,86.74c6.41,0,11.73,1.56,15.98,4.69,4.25,3.12,6.86,7.3,7.83,12.52l-11.2,3.05c-.62-3-2.09-5.31-4.38-6.94-2.3-1.62-5.13-2.44-8.51-2.44-3.62,0-6.5.87-8.62,2.6s-3.19,4.04-3.19,6.91c0,4.53,2.81,7.47,8.44,8.81l11.44,2.86c5.91,1.53,10.33,3.96,13.27,7.29s4.41,7.43,4.41,12.3c0,6.25-2.27,11.3-6.8,15.16-4.53,3.86-10.59,5.79-18.19,5.79-6.84,0-12.62-1.61-17.34-4.83-4.66-3.34-7.41-7.75-8.25-13.22l11.2-2.91c.41,3.09,1.95,5.52,4.62,7.27,2.67,1.75,6.07,2.62,10.2,2.62s7.09-.84,9.35-2.51c2.27-1.67,3.4-3.94,3.4-6.82,0-4.5-2.81-7.47-8.44-8.91l-11.44-2.77c-5.88-1.34-10.29-3.73-13.24-7.15s-4.43-7.6-4.43-12.54c0-6.19,2.2-11.21,6.59-15.07,4.39-3.86,10.16-5.79,17.32-5.79Z" class="cls-2"/><path d="M371.55,110.83c0,6.88-2.09,12.44-6.26,16.69-4.17,4.25-9.79,6.38-16.85,6.38h-15.75v24.19h-11.91v-70.08h27.75c7.12,0,12.74,2.06,16.85,6.16,4.11,4.11,6.16,9.66,6.16,16.66ZM359.08,110.55c0-3.53-1.1-6.4-3.3-8.6s-5.32-3.3-9.35-3.3h-13.73v24.8h13.55c4.12,0,7.3-1.17,9.52-3.52s3.33-5.47,3.33-9.38Z" class="cls-2"/><path d="M381.23,88h11.91v29.3l30.89.09v-29.39h12v70.08h-12v-30.14l-30.89-.09v30.23h-11.91v-70.08Z" class="cls-2"/><path d="M470.88,109.43c7.25,0,13.16,2.33,17.72,6.98,4.56,4.66,6.84,10.64,6.84,17.95s-2.28,13.25-6.84,17.91c-4.56,4.66-10.47,6.98-17.72,6.98s-13.25-2.33-17.81-6.98c-4.56-4.66-6.84-10.62-6.84-17.91s2.28-13.34,6.84-17.98,10.5-6.96,17.81-6.96ZM470.88,149.04c3.88,0,7.02-1.37,9.45-4.1,2.42-2.73,3.63-6.29,3.63-10.66s-1.21-7.91-3.63-10.62c-2.42-2.7-5.57-4.05-9.45-4.05s-7.17,1.35-9.61,4.05c-2.44,2.7-3.66,6.24-3.66,10.62s1.22,7.93,3.66,10.66c2.44,2.73,5.64,4.1,9.61,4.1Z" class="cls-2"/><path d="M576.42,127.94v30.14h-11.02v-28.41c0-3.28-.84-5.84-2.53-7.69-1.69-1.84-3.98-2.77-6.89-2.77-3.09,0-5.56,1.01-7.41,3.02s-2.77,4.84-2.77,8.46v27.38h-11.16v-28.41c0-3.28-.82-5.84-2.46-7.69-1.64-1.84-3.91-2.77-6.82-2.77-3.09,0-5.58,1.01-7.45,3.02s-2.81,4.84-2.81,8.46v27.38h-11.34v-47.34h10.55l.38,4.55c2.75-4.03,7.23-6.05,13.45-6.05,3.62,0,6.77.75,9.42,2.25s4.67,3.69,6.05,6.56c1.16-2.75,3.07-4.91,5.74-6.47,2.67-1.56,5.85-2.34,9.54-2.34,5.38,0,9.64,1.66,12.8,4.97,3.16,3.31,4.73,7.89,4.73,13.73Z" class="cls-2"/><path d="M631.43,138.58h-36.28c.38,3.56,1.72,6.28,4.03,8.16s5.25,2.81,8.81,2.81c5.78,0,9.83-2.41,12.14-7.22l9.47,3.75c-1.78,4.16-4.59,7.41-8.41,9.75s-8.23,3.52-13.2,3.52c-7,0-12.68-2.29-17.04-6.87-4.36-4.58-6.54-10.59-6.54-18.02s2.2-13.48,6.59-18.14c4.39-4.66,10.13-6.98,17.23-6.98s12.58,2.3,16.83,6.89,6.38,10.64,6.38,18.14v4.22ZM595.34,130.61h24.56c-.22-3.84-1.38-6.77-3.49-8.79s-4.95-3.02-8.51-3.02-6.41,1.02-8.62,3.07c-2.22,2.05-3.53,4.96-3.94,8.74Z" class="cls-2"/></g><g><path d="M170.55,153.49c0,4.12-3.38,7.5-7.5,7.5H58.05c-4.12,0-7.5-3.38-7.5-7.5v-45c0-4.12,2.39-9.89,5.3-12Line truncated

After

Width:  |  Height:  |  Size: 5.3 KiB

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" id="Layer_2" data-name="Layer 2" viewBox="0 0 681.98 201.98"><defs><style>.cls-1{fill:#1d2126}.cls-1,.cls-2,.cls-3{stroke-width:0}.cls-2{fill:#f2f4f9}.cls-3{fill:#18bcf2}.cls-4{fill:none;stroke:#f2f4f9;stroke-miterlimit:10;stroke-width:1.01px}</style></defs><g id="Layer_1-2" data-name="Layer 1"><g><g><rect width="680.97" height="200.97" x=".51" y=".51" class="cls-1" rx="40.48" ry="40.48"/><rect width="680.97" height="200.97" x=".51" y=".51" class="cls-4" rx="40.48" ry="40.48"/></g><g><path d="M236.13,43.11v26.53h-5.29v-14.5l-5.68,14.5h-5.08l-5.61-14.4v14.4h-5.12v-26.53h5.12l8.16,20.27,8.21-20.27h5.29Z" class="cls-3"/><path d="M259.54,63.84h-9.04l-2.02,5.8h-5.59l9.51-26.53h5.33l9.47,26.53h-5.7l-1.97-5.8ZM258,59.34l-2.95-8.7-2.99,8.7h5.94Z" class="cls-3"/><path d="M296.93,56.42c.02,1.89-.3,3.66-.98,5.31s-1.61,3.06-2.8,4.22-2.61,2.07-4.26,2.73-3.4.98-5.26.96h-9.65v-26.53h9.65c2.43-.04,4.66.52,6.71,1.68s3.67,2.76,4.86,4.82,1.78,4.33,1.74,6.81ZM291.25,56.42c0-2.46-.71-4.46-2.12-5.99s-3.27-2.29-5.58-2.29h-4.22v16.52h4.22c2.34,0,4.21-.75,5.61-2.26s2.09-3.5,2.09-5.99Z" class="cls-3"/><path d="M321.38,64.59v5.04h-16.7v-26.53h16.7v5.1h-11.34v5.66h10.07v4.75h-10.07v5.98h11.34Z" class="cls-3"/><path d="M348.35,48.17v6.1h9.58l-.04,4.82h-9.54v10.55h-5.36v-26.53h16.73l-.04,5.06h-11.34Z" class="cls-3"/><path d="M378.62,42.64c1.9,0,3.66.34,5.27,1.03s2.99,1.63,4.11,2.84,2,2.66,2.63,4.35.94,3.52.94,5.49c.02,1.95-.28,3.77-.91,5.48s-1.52,3.17-2.65,4.39-2.52,2.17-4.15,2.86-3.39,1.03-5.27,1c-2.5.04-4.74-.54-6.72-1.72s-3.52-2.82-4.6-4.92-1.6-4.45-1.56-7.05c-.02-1.95.28-3.77.91-5.48s1.51-3.18,2.65-4.39,2.51-2.17,4.13-2.87,3.37-1.03,5.23-1ZM378.65,64.82c2.24,0,4.01-.76,5.32-2.28s1.96-3.58,1.96-6.2-.65-4.71-1.95-6.22-3.08-2.27-5.33-2.27-4.03.76-5.33,2.27-1.95,3.59-1.95,6.22.65,4.71,1.95,6.21,3.08,2.26,5.33,2.26Z" class="cls-3"/><path d="M419.5,69.64h-6.01l-4.08-9.58h-4.89v9.58h-5.36v-26.53h10.21c3.28.01,5.76.74,7.44,2.19s2.51,3.55,2.51,6.3c0,1.79-.39,3.34-1.17,4.65s-1.89,2.28-3.33,2.91l4.68,10.48ZM413.63,51.6c0-1.15-.36-2.05-1.07-2.72s-1.78-.99-3.18-.99h-4.85v7.49h4.85c1.41,0,2.47-.34,3.18-1.01s1.07-1.6,1.07-2.77Z" class="cls-3"/></g><g><path d="M251.92,146.83v11.25h-43.5v-70.08h43.5v11.34h-31.59v18.14h28.22v10.55h-28.22v18.8h31.59Z" class="cls-2"/><path d="M285,86.74c6.41,0,11.73,1.56,15.98,4.69,4.25,3.12,6.86,7.3,7.83,12.52l-11.2,3.05c-.62-3-2.09-5.31-4.38-6.94-2.3-1.62-5.13-2.44-8.51-2.44-3.62,0-6.5.87-8.62,2.6s-3.19,4.04-3.19,6.91c0,4.53,2.81,7.47,8.44,8.81l11.44,2.86c5.91,1.53,10.33,3.96,13.27,7.29s4.41,7.43,4.41,12.3c0,6.25-2.27,11.3-6.8,15.16-4.53,3.86-10.59,5.79-18.19,5.79-6.84,0-12.62-1.61-17.34-4.83-4.66-3.34-7.41-7.75-8.25-13.22l11.2-2.91c.41,3.09,1.95,5.52,4.62,7.27,2.67,1.75,6.07,2.62,10.2,2.62s7.09-.84,9.35-2.51c2.27-1.67,3.4-3.94,3.4-6.82,0-4.5-2.81-7.47-8.44-8.91l-11.44-2.77c-5.88-1.34-10.29-3.73-13.24-7.15s-4.43-7.6-4.43-12.54c0-6.19,2.2-11.21,6.59-15.07,4.39-3.86,10.16-5.79,17.32-5.79Z" class="cls-2"/><path d="M371.55,110.83c0,6.88-2.09,12.44-6.26,16.69-4.17,4.25-9.79,6.38-16.85,6.38h-15.75v24.19h-11.91v-70.08h27.75c7.12,0,12.74,2.06,16.85,6.16,4.11,4.11,6.16,9.66,6.16,16.66ZM359.08,110.55c0-3.53-1.1-6.4-3.3-8.6s-5.32-3.3-9.35-3.3h-13.73v24.8h13.55c4.12,0,7.3-1.17,9.52-3.52s3.33-5.47,3.33-9.38Z" class="cls-2"/><path d="M381.23,88h11.91v29.3l30.89.09v-29.39h12v70.08h-12v-30.14l-30.89-.09v30.23h-11.91v-70.08Z" class="cls-2"/><path d="M470.88,109.43c7.25,0,13.16,2.33,17.72,6.98,4.56,4.66,6.84,10.64,6.84,17.95s-2.28,13.25-6.84,17.91c-4.56,4.66-10.47,6.98-17.72,6.98s-13.25-2.33-17.81-6.98c-4.56-4.66-6.84-10.62-6.84-17.91s2.28-13.34,6.84-17.98,10.5-6.96,17.81-6.96ZM470.88,149.04c3.88,0,7.02-1.37,9.45-4.1,2.42-2.73,3.63-6.29,3.63-10.66s-1.21-7.91-3.63-10.62c-2.42-2.7-5.57-4.05-9.45-4.05s-7.17,1.35-9.61,4.05c-2.44,2.7-3.66,6.24-3.66,10.62s1.22,7.93,3.66,10.66c2.44,2.73,5.64,4.1,9.61,4.1Z" class="cls-2"/><path d="M576.42,127.94v30.14h-11.02v-28.41c0-3.28-.84-5.84-2.53-7.69-1.69-1.84-3.98-2.77-6.89-2.77-3.09,0-5.56,1.01-7.41,3.02s-2.77,4.84-2.77,8.46v27.38h-11.16v-28.41c0-3.28-.82-5.84-2.46-7.69-1.64-1.84-3.91-2.77-6.82-2.77-3.09,0-5.58,1.01-7.45,3.02s-2.81,4.84-2.81,8.46v27.38h-11.34v-47.34h10.55l.38,4.55c2.75-4.03,7.23-6.05,13.45-6.05,3.62,0,6.77.75,9.42,2.25s4.67,3.69,6.05,6.56c1.16-2.75,3.07-4.91,5.74-6.47,2.67-1.56,5.85-2.34,9.54-2.34,5.38,0,9.64,1.66,12.8,4.97,3.16,3.31,4.73,7.89,4.73,13.73Z" class="cls-2"/><path d="M631.43,138.58h-36.28c.38,3.56,1.72,6.28,4.03,8.16s5.25,2.81,8.81,2.81c5.78,0,9.83-2.41,12.14-7.22l9.47,3.75c-1.78,4.16-4.59,7.41-8.41,9.75s-8.23,3.52-13.2,3.52c-7,0-12.68-2.29-17.04-6.87-4.36-4.58-6.54-10.59-6.54-18.02s2.2-13.48,6.59-18.14c4.39-4.66,10.13-6.98,17.23-6.98s12.58,2.3,16.83,6.89,6.38,10.64,6.38,18.14v4.22ZM595.34,130.61h24.56c-.22-3.84-1.38-6.77-3.49-8.79s-4.95-3.02-8.51-3.02-6.41,1.02-8.62,3.07c-2.22,2.05-3.53,4.96-3.94,8.74Z" class="cls-2"/></g><g><path d="M170.55,153.49c0,4.12-3.38,7.5-7.5,7.5H58.05c-4.12,0-7.5-3.38-7.5-7.5v-45c0-4.12,2.39-9.89,5.3-12Line truncated

After

Width:  |  Height:  |  Size: 5.3 KiB

+40
View File
@@ -0,0 +1,40 @@
# Render a Pip-Boy green map (inverted OSM tiles) centred on home.
# Map data (c) OpenStreetMap contributors, ODbL.
# usage: make_map.py LAT LON ZOOM W H OUT
import io, math, sys, urllib.request
from PIL import Image, ImageDraw, ImageOps
GRID_STEP = 48
lat, lon, z, w, h, out = float(sys.argv[1]), float(sys.argv[2]), int(sys.argv[3]), int(sys.argv[4]), int(sys.argv[5]), sys.argv[6]
def world_px(lat, lon):
n = 256 * 2**z
x = (lon + 180) / 360 * n
y = (1 - math.asinh(math.tan(math.radians(lat))) / math.pi) / 2 * n
return x, y
cx, cy = world_px(lat, lon)
x0, y0 = int(cx - w / 2), int(cy - h / 2)
canvas = Image.new("RGB", (w, h))
for ty in range(y0 // 256, (y0 + h) // 256 + 1):
for tx in range(x0 // 256, (x0 + w) // 256 + 1):
url = f"https://tile.openstreetmap.org/{z}/{tx}/{ty}.png"
req = urllib.request.Request(url, headers={"User-Agent": "esphome-map-render/1.0"})
tile = Image.open(io.BytesIO(urllib.request.urlopen(req).read())).convert("RGB")
canvas.paste(tile, (tx * 256 - x0, ty * 256 - y0))
g = ImageOps.autocontrast(ImageOps.invert(canvas.convert("L")), cutoff=1)
g = g.point(lambda v: int(255 * (v / 255) ** 1.8)) # darker background, roads/edges stay bright
# black -> Pip-Boy background, white -> a muted green so the markers stand out
img = ImageOps.colorize(g, black=(10, 15, 11), white=(80, 170, 105))
# grid and frame like the Pip-Boy local map
draw = ImageDraw.Draw(img)
GRID = (36, 67, 46)
for x in range(GRID_STEP, w, GRID_STEP):
draw.line([(x, 0), (x, h - 1)], fill=GRID)
for y in range(GRID_STEP, h, GRID_STEP):
draw.line([(0, y), (w - 1, y)], fill=GRID)
draw.rectangle([0, 0, w - 1, h - 1], outline=GRID)
img.save(out)
print(f"saved {out}, centre world px {cx:.1f},{cy:.1f}")
Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Submodule common/.esphome/external_components/b7dc7eea deleted from 16571e8a90.
+2 -2
View File
@@ -24,8 +24,8 @@ text_sensor:
# - <<: !include text_sensor/uptime.yaml # - <<: !include text_sensor/uptime.yaml
- <<: !include text_sensor/wifi_info.yaml - <<: !include text_sensor/wifi_info.yaml
# time: time:
#. - <<: !include time/homeassistant.yaml - <<: !include time/homeassistant.yaml
network: network:
enable_ipv6: true enable_ipv6: true
+3
View File
@@ -24,5 +24,8 @@ text_sensor:
- <<: !include text_sensor/version.yaml - <<: !include text_sensor/version.yaml
- <<: !include text_sensor/wifi_info.yaml - <<: !include text_sensor/wifi_info.yaml
time:
- <<: !include time/homeassistant.yaml
network: network:
enable_ipv6: true enable_ipv6: true
+3
View File
@@ -23,5 +23,8 @@ text_sensor:
- <<: !include text_sensor/version.yaml - <<: !include text_sensor/version.yaml
- <<: !include text_sensor/wifi_info.yaml - <<: !include text_sensor/wifi_info.yaml
time:
- <<: !include time/homeassistant.yaml
network: network:
enable_ipv6: true enable_ipv6: true
+3
View File
@@ -21,5 +21,8 @@ text_sensor:
- <<: !include text_sensor/version.yaml - <<: !include text_sensor/version.yaml
- <<: !include text_sensor/ethernet_info.yaml - <<: !include text_sensor/ethernet_info.yaml
time:
- <<: !include time/homeassistant.yaml
network: network:
enable_ipv6: true enable_ipv6: true
+3
View File
@@ -27,3 +27,6 @@ text_sensor:
- <<: !include text_sensor/git_ref.yaml - <<: !include text_sensor/git_ref.yaml
- <<: !include text_sensor/version.yaml - <<: !include text_sensor/version.yaml
- <<: !include text_sensor/wifi_info.yaml - <<: !include text_sensor/wifi_info.yaml
time:
- <<: !include time/homeassistant.yaml
+10
View File
@@ -0,0 +1,10 @@
---
# ESP8266 core with LEAmDNS announcing the IPv6 addresses (AAAA, ff02::fb) from
# randybb/Arduino@mdns-ipv6-aaaa (esp8266/Arduino#9068); add next to common_esp8266.yaml.
# The device must not set 'toolchain: arduino' (no custom framework source there).
# Drop once it's upstream and in an ESPHome release.
esp8266:
toolchain: platformio
framework:
version: 3.1.2
source: https://github.com/randybb/Arduino.git#mdns-ipv6-aaaa
+14
View File
@@ -0,0 +1,14 @@
---
# IPv6-only IoT network (SLAAC, no DHCPv4); add next to a common package:
# packages:
# common: !include common/common.yaml
# ipv6_only: !include common/ipv6_only.yaml
# Ethernet devices use common/ipv6_only_eth.yaml (this without the WiFi part)
packages:
base: !include ipv6_only_eth.yaml
wifi:
networks:
- id: !extend wifi_iot
ssid: !secret wifi_ssid_ipv6
password: !secret wifi_password_ipv6
+19
View File
@@ -0,0 +1,19 @@
---
# IPv6-only IoT network (SLAAC, no DHCPv4) for ethernet devices; add next to a common package:
# packages:
# common_eth: !include common/common_eth.yaml
# ipv6_only: !include common/ipv6_only_eth.yaml
# WiFi devices use common/ipv6_only.yaml (this + the IPv6 SSID)
esp32:
framework:
components:
# IDF v6.1.1 lwip + .local resolution over IPv6 (espressif/esp-lwip#94), drop once in IDF
- name: lwip
source: https://github.com/randybb/esp-lwip.git
ref: idf-v6.1.1-lwip-component
path: lwip
network:
enable_ipv6: true
enable_ipv4: false
min_ipv6_addr_count: 1
+179
View File
@@ -0,0 +1,179 @@
#pragma once
// Header-level decoding of captured ITS-G5 frames: 802.11 + LLC/SNAP, GeoNetworking (EN 302 636-4-1)
// and BTP (EN 302 636-5-1). Gives the message type (from the BTP port) and the sender's position
// vector, which GeoNetworking carries in every packet. The message bodies (CAM, DENM, SPATEM, ...)
// are ASN.1 UPER and are not decoded here.
#include <cstddef>
#include <cstdint>
#include <vector>
namespace its_g5_decode {
struct Info {
uint16_t port{0}; // BTP destination port, 0 = none
uint8_t station_type{0}; // ETSI station type from the GN address
uint64_t addr{0}; // GN address (M bit, station type, MID), identifies the station
bool secured{false}; // carried in an ETSI TS 103 097 signed packet (signature not verified)
double lat{0}, lon{0}; // degrees
float speed_kmh{0};
float heading{0}; // degrees
};
inline const char *port_name(uint16_t port) {
switch (port) {
case 2001: return "CAM";
case 2002: return "DENM";
case 2003: return "MAPEM";
case 2004: return "SPATEM";
case 2005: return "SAEM";
case 2006: return "IVIM";
case 2007: return "SREM";
case 2008: return "SSEM";
case 2009: return "CPM";
case 2010: return "EVCSN";
case 2011: return "TRM";
case 2013: return "RTCMEM";
case 2018: return "VAM";
default: return "other";
}
}
inline const char *station_name(uint8_t type) {
static const char *const NAMES[] = {"unknown", "pedestrian", "cyclist", "moped",
"motorcycle", "passengerCar", "bus", "lightTruck",
"heavyTruck", "trailer", "specialVehicle", "tram"};
if (type < sizeof(NAMES) / sizeof(NAMES[0]))
return NAMES[type];
return type == 15 ? "roadSideUnit" : "other";
}
inline uint16_t be16(const uint8_t *p) { return (p[0] << 8) | p[1]; }
inline int32_t be32(const uint8_t *p) {
return static_cast<int32_t>((uint32_t(p[0]) << 24) | (uint32_t(p[1]) << 16) | (uint32_t(p[2]) << 8) | p[3]);
}
// Returns false for anything that is not a GeoNetworking packet it understands.
inline bool parse(const std::vector<uint8_t> &frame, Info &out) {
const uint8_t *f = frame.data();
const size_t n = frame.size();
if (n < 24 || ((f[0] >> 2) & 3) != 2) // data frames only
return false;
size_t i = 24;
const bool qos = f[0] & 0x80;
if (qos)
i += 2;
if ((f[1] & 3) == 3) // ToDS + FromDS: fourth address
i += 6;
if (qos && (f[1] & 0x80)) // +HTC
i += 4;
static const uint8_t SNAP_GN[] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00, 0x89, 0x47};
if (i + 8 + 4 > n)
return false;
for (size_t k = 0; k < 8; k++) {
if (f[i + k] != SNAP_GN[k])
return false;
}
i += 8;
// GN basic header: version | next header, reserved, lifetime, remaining hop limit
const uint8_t basic_nh = f[i] & 0x0F;
i += 4;
if (basic_nh == 2) {
// ponytail: walks only the usual 1609.2 shape (signedData with an unsecuredData payload, no
// external hash); anything else is skipped. A real OER decoder is needed for the rest.
if (i + 7 > n || f[i] != 0x03 || f[i + 1] != 0x81 || !(f[i + 3] & 0x40) || f[i + 4] != 0x03 ||
f[i + 5] != 0x80)
return false;
i += 6;
if (f[i] & 0x80) {
i += 1 + (f[i] & 0x7F);
} else {
i += 1;
}
out.secured = true;
} else if (basic_nh != 1) {
return false;
}
// GN common header (8 bytes): next header | reserved, header type | subtype, ...
if (i + 8 > n)
return false;
const uint8_t common_nh = f[i] >> 4;
const uint8_t ht = f[i + 1] >> 4, hst = f[i + 1] & 0x0F;
i += 8;
size_t pv, ext; // offset of the source position vector, length of the extended header
switch (ht) {
case 1: pv = i; ext = 24; break; // beacon
case 2: pv = i + 4; ext = 48; break; // GUC
case 3: case 4: pv = i + 4; ext = 44; break; // GAC, GBC
case 5: pv = hst == 0 ? i : i + 4; ext = 28; break; // SHB, TSB
default: return false; // location service, unknown
}
if (pv + 24 > n)
return false;
// Long position vector: GN address (8), timestamp (4), lat, lon (1/10 µdeg), PAI | speed, heading
out.station_type = (f[pv] >> 2) & 0x1F;
for (size_t k = 0; k < 8; k++)
out.addr = (out.addr << 8) | f[pv + k];
out.lat = be32(f + pv + 12) / 1e7;
out.lon = be32(f + pv + 16) / 1e7;
int16_t speed = be16(f + pv + 20) & 0x7FFF;
if (speed & 0x4000)
speed -= 0x8000; // 15-bit signed, 0.01 m/s
out.speed_kmh = speed * 0.036f;
out.heading = be16(f + pv + 22) / 10.0f;
if ((common_nh == 1 || common_nh == 2) && i + ext + 2 <= n) // BTP-A / BTP-B
out.port = be16(f + i + ext);
return true;
}
struct Stats {
uint32_t cam{0}, denm{0}, spatem{0}, mapem{0}, other{0};
Info last;
};
inline Stats stats;
// Parse, count and log one frame; returns false if it was not decoded.
inline bool handle(const std::vector<uint8_t> &frame) {
Info info;
if (!parse(frame, info))
return false;
switch (info.port) {
case 2001: stats.cam++; break;
case 2002: stats.denm++; break;
case 2004: stats.spatem++; break;
case 2003: stats.mapem++; break;
default: stats.other++; break;
}
stats.last = info;
return true;
}
// Rate limit per station: true if addr was not let through in the last period_ms.
// ponytail: 32 slots, the oldest is evicted; with more stations in range some publish more often.
inline bool due(uint64_t addr, uint32_t now, uint32_t period_ms) {
static struct {
uint64_t addr;
uint32_t ms;
} slots[32]{};
auto *slot = &slots[0];
for (auto &s : slots) {
if (s.addr == addr) {
slot = &s;
break;
}
if (now - s.ms > now - slot->ms)
slot = &s;
}
if (slot->addr == addr && now - slot->ms < period_ms)
return false;
*slot = {addr, now};
return true;
}
} // namespace its_g5_decode
+33
View File
@@ -0,0 +1,33 @@
// Self-check for decode.h: one signed SHB CAM frame from a passenger car.
// Build: g++ -std=c++20 decode_test.cpp -o /tmp/t && /tmp/t
#include "decode.h"
#include <cassert>
#include <cmath>
#include <cstdio>
using namespace its_g5_decode;
int main() {
std::vector<uint8_t> f = {0x88, 0x00, 0, 0, 0xff,0xff,0xff,0xff,0xff,0xff, 1,2,3,4,5,6, 0xff,0xff,0xff,0xff,0xff,0xff, 0,0, // QoS data hdr
0x00, 0x00, // QoS ctrl
0xAA,0xAA,0x03,0,0,0,0x89,0x47, // SNAP GN
0x12, 0x00, 0x1a, 0x01, // basic, NH=2 secured
0x03, 0x81, 0x00, 0x40, 0x03, 0x80, 0x30, // 1609.2 signedData/unsecuredData len
0x20, 0x50, 0x02, 0x80, 0x00, 0x30, 0x01, 0x00}; // common: NH=BTP-B, HT=5 HST=0
uint8_t pv[24] = {5 << 2, 0, 1,2,3,4,5,6, 0,0,0,0,
0x1C,0xB3,0x8A,0x40, // lat 481528384 -> 48.1528384
0x0A,0x34,0x5A,0x60, // lon 171203168 -> 17.1203168
0x05,0x6E, // 1390 * 0.01 m/s = 50.04 km/h
0x04,0xD2}; // 123.4 deg
f.insert(f.end(), pv, pv + 24);
uint8_t media[4] = {0}; f.insert(f.end(), media, media + 4);
uint8_t btp[4] = {0x07, 0xD1, 0, 0}; f.insert(f.end(), btp, btp + 4); // port 2001
Info i;
assert(parse(f, i));
assert(i.secured && i.port == 2001 && i.station_type == 5);
assert(std::fabs(i.lat - 48.1528384) < 1e-7 && std::fabs(i.lon - 17.1203168) < 1e-7);
assert(std::fabs(i.speed_kmh - 50.04f) < 0.01f && std::fabs(i.heading - 123.4f) < 0.01f);
assert(i.addr == 0x1400010203040506ULL);
assert(handle(f) && stats.cam == 1);
assert(due(i.addr, 1000, 1000) && !due(i.addr, 1999, 1000) && due(2, 1999, 1000) && due(i.addr, 2000, 1000));
f[30] = 0x48; assert(!parse(f, i)); // not GeoNetworking
std::puts("ok");
}
+14
View File
@@ -0,0 +1,14 @@
# Package: tile on a grid page that calls a Home Assistant action on an entity (e.g. button.press).
# Its checked/disabled states are up to the owner (e.g. gate.yaml). Tiles fill the page in package order.
# vars: page, id, name, icon (MDI glyph, must be in icon_s), action, entity
lvgl:
pages:
- id: !extend ${page}
widgets:
- button:
<<: !include {file: tile.yaml, vars: {id: "${id}", name: "${name}", icon: "${icon}"}}
on_click:
- homeassistant.action:
action: ${action}
data:
entity_id: ${entity}
@@ -0,0 +1,44 @@
# Package: fireplace icon in the home page icon row (white while it burns, grey while not, dark grey unavailable).
# Hidden outside the heating season: fire out and the boiler switch off.
# defaults: entity (fire binary_sensor), boiler (switch that lets the boiler fire)
defaults:
entity: binary_sensor.heating_fireplace_fire
boiler: switch.heating_enabled
lvgl:
pages:
- id: !extend page_home
widgets:
- obj:
id: !extend home_icons
widgets:
- label:
id: fireplace_icon
text: "\U000F0E2F"
text_font: icon_s
text_color: 0x48484A
script:
- id: fireplace_icon_update
then:
- lambda: |-
const std::string &fire = id(fireplace_fire).state;
const bool on = fire == "on";
lv_label_set_text(id(fireplace_icon), on ? "\U000F0E2E" : "\U000F0E2F");
lv_obj_set_style_text_color(id(fireplace_icon), lv_color_hex(on ? 0xFFFFFF : ha_unavailable(fire) ? 0x48484A : 0x8E8E93), 0);
lv_obj_set_hidden(id(fireplace_icon), fire == "off" && id(fireplace_boiler).state == "off");
text_sensor:
# text, not binary: a binary sensor drops "unavailable"
- platform: homeassistant
id: fireplace_fire
entity_id: ${entity}
internal: true
on_value:
- script.execute: fireplace_icon_update
- platform: homeassistant
id: fireplace_boiler
entity_id: ${boiler}
internal: true
on_value:
- script.execute: fireplace_icon_update
+49
View File
@@ -0,0 +1,49 @@
# One forecast row: day, icon, day/night temperature on two lines, all centred vertically.
# Not clickable, so a tap falls through to the home page.
obj:
clickable: false
width: SIZE_CONTENT
height: SIZE_CONTENT
bg_opa: TRANSP
border_width: 0
pad_all: 0
layout:
type: FLEX
flex_flow: ROW
flex_align_cross: CENTER
pad_column: 8
widgets:
- label:
id: forecast_day_${i}
text: ""
text_font: font_s
text_color: 0xB4B4BA
width: 26
text_align: RIGHT
- label:
id: forecast_icon_${i}
text: ""
text_font: icon_s
text_color: 0xFFFFFF
- obj:
clickable: false
width: SIZE_CONTENT
height: SIZE_CONTENT
bg_opa: TRANSP
border_width: 0
pad_all: 0
layout:
type: FLEX
flex_flow: COLUMN
pad_row: 0
widgets:
- label:
id: forecast_high_${i}
text: ""
text_font: font_s
text_color: 0xFFFFFF
- label:
id: forecast_low_${i}
text: ""
text_font: font_s
text_color: 0x8E8E93
+55
View File
@@ -0,0 +1,55 @@
# Package: gate state tile (two slots) on a grid page, and the state of the gate_open/gate_close action tiles
# vars: page, state (select with Open/Closed/Opening/Closing)
lvgl:
pages:
- id: !extend ${page}
widgets:
# highlighted while not closed
- obj:
id: gate_state_tile
clickable: false
width: 272
height: 112
styles: tile_style
checked:
bg_color: 0xF5B342
text_color: 0x000000
disabled:
bg_color: 0x161618
text_color: 0x48484A
widgets:
- label:
id: gate_state_icon
text: ""
text_font: icon_l
align: LEFT_MID
- label:
id: gate_state_label
text: ""
align: LEFT_MID
x: 64
text_sensor:
- platform: homeassistant
id: gate_state
entity_id: ${state}
internal: true
on_value:
- lambda: |-
static const char *const STATES[][3] = {{"Open", "Otvorená", "\U000F116A"},
{"Closed", "Zatvorená", "\U000F0299"},
{"Opening", "Otvára sa", "\U000F1169"},
{"Closing", "Zatvára sa", "\U000F17F7"}};
const char *text = x.c_str(), *icon = "\U000F17F8";
for (auto &s : STATES)
if (x == s[0]) text = s[1], icon = s[2];
lv_label_set_text(id(gate_state_label), text);
lv_label_set_text(id(gate_state_icon), icon);
// highlighted unless closed
lv_obj_set_state(id(gate_state_tile), LV_STATE_CHECKED, x != "Closed");
// the button of the running movement
lv_obj_set_state(id(gate_open), LV_STATE_CHECKED, x == "Opening");
lv_obj_set_state(id(gate_close), LV_STATE_CHECKED, x == "Closing");
// gate controller offline: grey out the whole gate page
for (lv_obj_t *o : {(lv_obj_t *) id(gate_open), (lv_obj_t *) id(gate_close), id(gate_state_tile)})
lv_obj_set_state(o, LV_STATE_DISABLED, ha_unavailable(x));
+21
View File
@@ -0,0 +1,21 @@
# Grid page (list item of lvgl pages): title and arrows; the 2x3 tiles come from the *_tile.yaml packages
# vars: id, title, prev, next (page ids for the arrows), skip (hidden page: out of the page cycle, no next arrow)
id: ${id}
skip: ${skip}
styles: page_style
# header 64 px high (arrow touch area), 2x112 tiles + gap below, 8 px left at the bottom
pad_bottom: 8
layout:
type: FLEX
flex_flow: ROW_WRAP
widgets:
- label:
text: "${title}"
text_font: font_s
text_color: 0xB4B4BA
width: 100%
height: 48
pad_top: 14
text_align: CENTER
- <<: !include {file: page_arrow.yaml, vars: {icon: "\U000F0141", align: TOP_LEFT, x: -16, to: "${prev}", hidden: false}}
- <<: !include {file: page_arrow.yaml, vars: {icon: "\U000F0142", align: TOP_RIGHT, x: 16, to: "${next}", hidden: "${skip}"}}
+5
View File
@@ -0,0 +1,5 @@
#pragma once
#include <string>
// Home Assistant entity state that means "no usable value": the tile is shown greyed out and disabled
inline bool ha_unavailable(const std::string &s) { return s.empty() || s == "unavailable" || s == "unknown"; }
+17
View File
@@ -0,0 +1,17 @@
#pragma once
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
// HA brightness 0..255 -> slider percent; NaN (light off) -> 0
inline int brightness_pct(float b) { return std::isnan(b) ? 0 : int(std::lround(b * 100 / 255)); }
// Hue from the hs_color attribute, "(30.0, 80.0)" or "[30.0, 80.0]"; -1 if missing
inline int parse_hue(const std::string &s) {
size_t p = s.find_first_of("([");
if (p == std::string::npos) return -1;
char *end;
float h = std::strtof(s.c_str() + p + 1, &end);
return end == s.c_str() + p + 1 ? -1 : int(std::lround(h));
}
+63
View File
@@ -0,0 +1,63 @@
# Package: Home Assistant light as a tile on a grid page, with its state. Tap toggles, long press opens page_light.
# Tiles fill the page in package order.
# vars: page, id, name, entity, icon (MDI glyph, must be in icon_s),
# dim (brightness), kmin (lowest colour temperature in K, 0 = none), hs (hue)
lvgl:
pages:
- id: !extend ${page}
widgets:
- button:
<<: !include {file: tile.yaml, vars: {id: "${id}", name: "${name}", icon: "${icon}"}}
# not checkable: the checked state comes only from Home Assistant
on_short_click:
- homeassistant.action:
action: light.toggle
data:
entity_id: ${entity}
on_long_press:
- script.execute:
id: open_light
entity: ${entity}
name: "${name}"
dim: ${dim}
kmin: ${kmin}
hs: ${hs}
is_on: !lambda return id(${id}_state).state == "on";
bri: !lambda return id(${id}_bri).state;
ct: !lambda return id(${id}_ct).state;
hue: !lambda return id(${id}_hs).state;
sensor:
- platform: homeassistant
id: ${id}_bri
entity_id: ${entity}
attribute: brightness
internal: true
on_value:
- lambda: 'if (id(cur_light) == "${entity}") lv_slider_set_value(id(detail_bri), brightness_pct(x), LV_ANIM_OFF);'
- platform: homeassistant
id: ${id}_ct
entity_id: ${entity}
attribute: color_temp_kelvin
internal: true
on_value:
- lambda: 'if (id(cur_light) == "${entity}") lv_slider_set_value(id(detail_ct), x, LV_ANIM_OFF);'
text_sensor:
# text, not binary: a binary sensor drops "unavailable"
- platform: homeassistant
id: ${id}_state
entity_id: ${entity}
internal: true
on_value:
- lambda: |-
lv_obj_set_state(id(${id}), LV_STATE_CHECKED, x == "on");
lv_obj_set_state(id(${id}), LV_STATE_DISABLED, ha_unavailable(x));
if (id(cur_light) == "${entity}") lv_obj_set_state(id(detail_power), LV_STATE_CHECKED, x == "on");
- platform: homeassistant
id: ${id}_hs
entity_id: ${entity}
attribute: hs_color
internal: true
on_value:
- lambda: 'if (id(cur_light) == "${entity}") lv_slider_set_value(id(detail_hue), parse_hue(x), LV_ANIM_OFF);'
+19
View File
@@ -0,0 +1,19 @@
# Package: tile on a grid page that opens another page, a big icon only (e.g. the robot for automations)
# vars: page, to (page id), icon (MDI glyph, must be in icon_l)
lvgl:
pages:
- id: !extend ${page}
widgets:
- button:
width: 130
height: 112
styles: tile_style
pressed:
bg_color: 0x48484A
on_click:
- lvgl.page.show: ${to}
widgets:
- label:
text: "${icon}"
text_font: icon_l
align: CENTER
+21
View File
@@ -0,0 +1,21 @@
# Page switch arrow in a top corner; floats over the page's flex layout
# vars: icon, align, x, to (page id), hidden
obj:
floating: true
hidden: ${hidden}
align: ${align}
x: ${x}
y: -16
width: 88
height: 64
bg_opa: TRANSP
border_width: 0
pad_all: 0
on_click:
- lvgl.page.show: ${to}
widgets:
- label:
text: "${icon}"
text_font: icon_s
text_color: 0xB4B4BA
align: CENTER
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,70 @@
# Package: radiator icon in the home page icon row:
# disabled (grey) while the thermostat does not call for heat, off (grey) while it does but the off-peak tariff
# is off (the boiler is then hard off) and the fireplace is out, on (white) while it heats.
# Hidden outside the heating season: boiler switch off and the fireplace out.
# vars: id (prefix of its ids, unique per icon), entity (climate);
# defaults: boiler (switch that lets the boiler fire), fire (fireplace binary_sensor), off_peak (tariff binary_sensor)
defaults:
boiler: switch.heating_enabled
fire: binary_sensor.heating_fireplace_fire
off_peak: binary_sensor.heater_off_peak
lvgl:
pages:
- id: !extend page_home
widgets:
- obj:
id: !extend home_icons
widgets:
- label:
id: ${id}_icon
text: "\U000F0AD8"
text_font: icon_s
text_color: 0x48484A
script:
- id: ${id}_update
then:
- lambda: |-
const std::string &boiler = id(${id}_boiler).state, &fire = id(${id}_fire).state;
const bool demand = id(${id}_action).state == "heating";
// the burning fireplace heats the water without the boiler
const bool heating = demand && (id(${id}_off_peak).state != "off" || fire == "on");
lv_label_set_text(id(${id}_icon), !demand ? "\U000F0AD7" : heating ? "\U000F0438" : "\U000F0AD8");
const bool unavailable = ha_unavailable(id(${id}_mode).state);
lv_obj_set_style_text_color(id(${id}_icon), lv_color_hex(heating ? 0xFFFFFF : unavailable ? 0x48484A : 0x8E8E93), 0);
lv_obj_set_hidden(id(${id}_icon), boiler == "off" && fire == "off");
text_sensor:
- platform: homeassistant
id: ${id}_boiler
entity_id: ${boiler}
internal: true
on_value:
- script.execute: ${id}_update
- platform: homeassistant
id: ${id}_fire
entity_id: ${fire}
internal: true
on_value:
- script.execute: ${id}_update
- platform: homeassistant
id: ${id}_off_peak
entity_id: ${off_peak}
internal: true
on_value:
- script.execute: ${id}_update
# the climate state only tells whether the thermostat is reachable
- platform: homeassistant
id: ${id}_mode
entity_id: ${entity}
internal: true
on_value:
- script.execute: ${id}_update
- platform: homeassistant
id: ${id}_action
entity_id: ${entity}
attribute: hvac_action
internal: true
on_value:
- script.execute: ${id}_update
+44
View File
@@ -0,0 +1,44 @@
---
# NSPanel sleep dim: the idle (dimmed) brightness drops to 0 at night
# (sun below -6°), unless the room light is on. Sets the idle_brightness global of panel.yaml (${dim_brightness} or 0).
# packages:
# sleep_dim: !include
# file: common/nspanel_terminal/sleep_dim.yaml
# vars:
# sleep_override_entity: light.bedroom_lights
script:
- id: apply_sleep_dim
then:
- lambda: |-
bool day = id(sun_id).is_above_horizon(-6);
id(idle_brightness) = id(sleep_override).state == "on" || day ? ${dim_brightness} : 0;
if (id(dimmed))
id(panel).request_brightness(id(idle_brightness));
time:
- id: !extend ha_time
on_time_sync:
- script.execute: apply_sleep_dim
text_sensor:
# sleepOverride; text, not binary: a binary sensor drops "unavailable"
- platform: homeassistant
id: sleep_override
entity_id: ${sleep_override_entity}
internal: true
on_value:
- script.execute: apply_sleep_dim
sun:
id: sun_id
time_id: ha_time
latitude: 48.15°
longitude: 17.11°
on_sunrise:
- elevation: -6°
then:
- script.execute: apply_sleep_dim
on_sunset:
- elevation: -6°
then:
- script.execute: apply_sleep_dim
+12
View File
@@ -0,0 +1,12 @@
# Package: empty slot on a grid page (e.g. to start the next row)
# vars: page
lvgl:
pages:
- id: !extend ${page}
widgets:
- obj:
clickable: false
width: 130
height: 112
bg_opa: TRANSP
border_width: 0
+25
View File
@@ -0,0 +1,25 @@
# Package: on/off Home Assistant entity (switch, automation, ...) as a tile on a grid page, with its state.
# Tiles fill the page in package order.
# vars: page, id, name, entity, icon (MDI glyph, must be in icon_s), domain (tap calls <domain>.toggle)
lvgl:
pages:
- id: !extend ${page}
widgets:
- button:
<<: !include {file: tile.yaml, vars: {id: "${id}", name: "${name}", icon: "${icon}"}}
on_click:
- homeassistant.action:
action: ${domain}.toggle
data:
entity_id: ${entity}
text_sensor:
# text, not binary: a binary sensor drops "unavailable"
- platform: homeassistant
id: ${id}_state
entity_id: ${entity}
internal: true
on_value:
- lambda: |-
lv_obj_set_state(id(${id}), LV_STATE_CHECKED, x == "on");
lv_obj_set_state(id(${id}), LV_STATE_DISABLED, ha_unavailable(x));
+25
View File
@@ -0,0 +1,25 @@
#pragma once
#include <string>
#include <vector>
// HA list attribute as sent to ESPHome, "['none', 'away']" or '["none", "away"]' -> items
inline std::vector<std::string> parse_list(const std::string &s) {
std::vector<std::string> out;
for (size_t p = 0; (p = s.find_first_of("'\"", p)) != std::string::npos;) {
size_t end = s.find(s[p], p + 1);
if (end == std::string::npos) break;
out.push_back(s.substr(p + 1, end - p - 1));
p = end + 1;
}
return out;
}
// Display name for a climate preset; unknown presets are shown as they come
inline std::string preset_name(const std::string &p) {
static const char *const NAMES[][2] = {{"none", "Žiadny"}, {"home", "Doma"}, {"away", "Preč"},
{"eco", "Eco"}, {"comfort", "Komfort"}, {"sleep", "Spánok"},
{"activity", "Aktivita"}, {"boost", "Boost"}};
for (auto &n : NAMES)
if (p == n[0]) return n[1];
return p;
}
+328
View File
@@ -0,0 +1,328 @@
# Package: thermostat page (arc with target temperature, -/+, heat/off, boiler switch, presets) and its HA state.
# vars: id (prefix of its ids, unique per thermostat page), page, title, prev, next (page ids for the arrows),
# entity (climate with heat/off and presets),
# boiler (switch that lets the boiler fire, the same in every room)
defaults:
boiler: switch.heating_enabled
globals:
# preset_modes of the thermostat, in dropdown order
- id: ${id}_preset_list
type: std::vector<std::string>
lvgl:
pages:
- id: ${page}
styles: page_style
widgets:
- label:
text: "${title}"
text_font: font_s
text_color: 0xB4B4BA
width: 100%
text_align: CENTER
- <<: !include
file: page_arrow.yaml
vars: {icon: "\U000F0141", align: TOP_LEFT, x: -16, to: "${prev}", hidden: false}
- <<: !include
file: page_arrow.yaml
vars: {icon: "\U000F0142", align: TOP_RIGHT, x: 16, to: "${next}", hidden: false}
# target temperature in half degrees, 10..30 °C
- arc:
id: ${id}_arc
disabled:
arc_color: 0x161618
align: BOTTOM_LEFT
y: -20
width: 220
height: 220
min_value: 20
max_value: 60
arc_width: 16
arc_color: 0x2C2C2E
indicator:
arc_width: 16
arc_color: 0x8E8E93
knob:
bg_color: 0xFFFFFF
pad_all: 2
on_value:
- lambda: 'lv_label_set_text_fmt(id(${id}_target_label), "%.1f", x / 2.0f);'
on_release:
- script.execute: ${id}_send_target
widgets:
- obj:
clickable: false
align: CENTER
y: -8
width: SIZE_CONTENT
height: SIZE_CONTENT
bg_opa: TRANSP
border_width: 0
pad_all: 0
text_color: 0xFFFFFF
layout:
type: FLEX
flex_flow: ROW
flex_align_cross: START
pad_column: 2
widgets:
- label:
id: ${id}_target_label
text: "-"
text_font: font_big
text_color: 0xFFFFFF
- label:
text: "°C"
y: 6
text_color: 0xB4B4BA
- label:
id: ${id}_current_label
text: ""
text_font: font_s
text_color: 0xB4B4BA
align: CENTER
y: 34
- label:
id: ${id}_action_label
text: ""
text_font: font_s
text_color: 0x8E8E93
align: CENTER
y: -50
- button:
id: ${id}_minus
align: BOTTOM_LEFT
x: 46
width: 56
height: 44
styles: tile_style
disabled:
bg_color: 0x161618
text_color: 0x48484A
pad_all: 0
on_click:
- lambda: |-
lv_arc_set_value(id(${id}_arc), lv_arc_get_value(id(${id}_arc)) - 1);
lv_label_set_text_fmt(id(${id}_target_label), "%.1f", lv_arc_get_value(id(${id}_arc)) / 2.0f);
- script.execute: ${id}_send_target
widgets:
- label:
text: "\U000F0374"
text_font: icon_s
align: CENTER
- button:
id: ${id}_plus
align: BOTTOM_LEFT
x: 118
width: 56
height: 44
styles: tile_style
disabled:
bg_color: 0x161618
text_color: 0x48484A
pad_all: 0
on_click:
- lambda: |-
lv_arc_set_value(id(${id}_arc), lv_arc_get_value(id(${id}_arc)) + 1);
lv_label_set_text_fmt(id(${id}_target_label), "%.1f", lv_arc_get_value(id(${id}_arc)) / 2.0f);
- script.execute: ${id}_send_target
widgets:
- label:
text: "\U000F0415"
text_font: icon_s
align: CENTER
- button:
id: ${id}_power
align: TOP_RIGHT
x: -90
y: 56
width: 82
height: 44
styles: tile_style
disabled:
bg_color: 0x161618
text_color: 0x48484A
pad_all: 0
checked:
bg_color: 0xF5B342
text_color: 0x000000
on_click:
- homeassistant.action:
action: climate.set_hvac_mode
data:
entity_id: ${entity}
hvac_mode: !lambda 'return id(${id}_mode).state == "heat" ? "off" : "heat";'
widgets:
- label:
text: "\U000F0438"
text_font: icon_s
align: LEFT_MID
x: 6
- label:
text: "Izba"
text_font: font_s
align: RIGHT_MID
x: -8
# the boiler only fires with this switch on
- button:
id: ${id}_boiler_button
align: TOP_RIGHT
x: 0
y: 56
width: 82
height: 44
styles: tile_style
disabled:
bg_color: 0x161618
text_color: 0x48484A
pad_all: 0
checked:
bg_color: 0xF5B342
text_color: 0x000000
on_click:
- homeassistant.action:
action: switch.toggle
data:
entity_id: ${boiler}
widgets:
- label:
text: "\U000F0238"
text_font: icon_s
align: LEFT_MID
x: 6
- label:
text: "Kotol"
text_font: font_s
align: RIGHT_MID
x: -8
# options come from the preset_modes attribute (thermostat.yaml)
- dropdown:
id: ${id}_preset_dropdown
disabled:
text_color: 0x48484A
align: TOP_RIGHT
y: 112
width: 172
options: ["-"]
styles: tile_style
pad_all: 10
symbol: "\U000F0140"
indicator:
text_font: icon_s
dropdown_list:
bg_color: 0x2C2C2E
text_color: 0xFFFFFF
text_font: font_m
border_width: 0
radius: 14
selected:
checked:
bg_color: 0xF5B342
text_color: 0x000000
on_value:
- homeassistant.action:
action: climate.set_preset_mode
data:
entity_id: ${entity}
preset_mode: !lambda 'return x < id(${id}_preset_list).size() ? id(${id}_preset_list)[x] : std::string();'
sensor:
- platform: homeassistant
id: ${id}_target
entity_id: ${entity}
attribute: temperature
internal: true
on_value:
- lambda: |-
if (std::isnan(x)) return;
lv_arc_set_value(id(${id}_arc), std::lround(x * 2));
lv_label_set_text_fmt(id(${id}_target_label), "%.1f", x);
- platform: homeassistant
id: ${id}_current
entity_id: ${entity}
attribute: current_temperature
internal: true
on_value:
- lambda: 'lv_label_set_text_fmt(id(${id}_current_label), "teraz %.1f°C", x);'
text_sensor:
# text, not binary: a binary sensor drops "unavailable"
- platform: homeassistant
id: ${id}_boiler
entity_id: ${boiler}
internal: true
on_value:
- lambda: |-
lv_obj_set_state(id(${id}_boiler_button), LV_STATE_CHECKED, x == "on");
lv_obj_set_state(id(${id}_boiler_button), LV_STATE_DISABLED, ha_unavailable(x));
- platform: homeassistant
id: ${id}_mode
entity_id: ${entity}
internal: true
on_value:
- lambda: |-
lv_obj_set_state(id(${id}_power), LV_STATE_CHECKED, x == "heat");
// thermostat unavailable: grey out its controls
for (lv_obj_t *o : {(lv_obj_t *) id(${id}_power), (lv_obj_t *) id(${id}_arc), id(${id}_minus), id(${id}_plus),
id(${id}_preset_dropdown)->obj})
lv_obj_set_state(o, LV_STATE_DISABLED, ha_unavailable(x));
- script.execute: ${id}_update_action
- platform: homeassistant
id: ${id}_action
entity_id: ${entity}
attribute: hvac_action
internal: true
on_value:
- script.execute: ${id}_update_action
- platform: homeassistant
id: ${id}_presets
entity_id: ${entity}
attribute: preset_modes
internal: true
on_value:
- lambda: |-
id(${id}_preset_list) = parse_list(x);
std::string options;
for (auto &p : id(${id}_preset_list)) options += (options.empty() ? "" : "\n") + preset_name(p);
lv_dropdown_set_options(id(${id}_preset_dropdown)->obj, options.c_str());
- script.execute: ${id}_select_preset
- platform: homeassistant
id: ${id}_preset
entity_id: ${entity}
attribute: preset_mode
internal: true
on_value:
- script.execute: ${id}_select_preset
script:
# Arc and -/+ change the target locally; send once the user stops for a moment
- id: ${id}_send_target
mode: restart
then:
- delay: 800ms
- homeassistant.action:
action: climate.set_temperature
data:
entity_id: ${entity}
temperature: !lambda return lv_arc_get_value(id(${id}_arc)) / 2.0f;
# back to what HA has, in case it did not take the change (e.g. actions not allowed for this device)
- delay: 5s
- lambda: |-
float target = id(${id}_target).state;
if (std::isnan(target)) return;
lv_arc_set_value(id(${id}_arc), std::lround(target * 2));
lv_label_set_text_fmt(id(${id}_target_label), "%.1f", target);
- id: ${id}_update_action
then:
- lambda: |-
bool off = id(${id}_mode).state == "off";
bool heating = id(${id}_action).state == "heating";
lv_label_set_text(id(${id}_action_label), off ? "vypnuté" : heating ? "kúri" : "nekúri");
lv_obj_set_style_arc_color(id(${id}_arc), lv_color_hex(heating ? 0xF5B342 : 0x8E8E93), LV_PART_INDICATOR);
- id: ${id}_select_preset
then:
- lambda: |-
auto &list = id(${id}_preset_list);
auto it = std::find(list.begin(), list.end(), id(${id}_preset).state);
if (it != list.end()) lv_dropdown_set_selected(id(${id}_preset_dropdown)->obj, it - list.begin());
+25
View File
@@ -0,0 +1,25 @@
# Look of a 2x3 grid tile (button body): icon top left, name bottom left; merge it into a button with <<:
# checked = on (orange), disabled = entity unavailable (grey), pressed = touch feedback
# vars: id, name, icon (MDI glyph, must be in icon_s)
id: ${id}
width: 130
height: 112
styles: tile_style
pressed:
bg_color: 0x48484A
checked:
bg_color: 0xF5B342
text_color: 0x000000
disabled:
bg_color: 0x161618
text_color: 0x48484A
widgets:
- label:
text: "${icon}"
text_font: icon_s
align: TOP_LEFT
- label:
text: "${name}"
align: BOTTOM_LEFT
long_mode: WRAP
width: 100%
+57
View File
@@ -0,0 +1,57 @@
#pragma once
#include <cstdlib>
#include <cstring>
#include <string>
// Home Assistant weather condition -> MDI icon (glyphs listed in the font: config)
inline const char *weather_icon(const std::string &c) {
static const char *const MAP[][2] = {
{"clear-night", "\U000F0594"}, {"sunny", "\U000F0599"}, {"partlycloudy", "\U000F0595"},
{"cloudy", "\U000F0590"}, {"fog", "\U000F0591"}, {"rainy", "\U000F0597"},
{"pouring", "\U000F0596"}, {"snowy", "\U000F0598"}, {"snowy-rainy", "\U000F067F"},
{"hail", "\U000F0592"}, {"lightning", "\U000F0593"}, {"lightning-rainy", "\U000F067E"},
{"windy", "\U000F059D"}, {"windy-variant", "\U000F059E"}, {"exceptional", "\U000F05D6"}};
for (auto &m : MAP)
if (c == m[0]) return m[1];
return "";
}
// One day of the HA `forecast` attribute as sent to ESPHome (Python repr or JSON of a list of dicts).
struct ForecastDay {
std::string condition;
float high, low;
};
// Value after `key` in s, starting at pos; works for 'key': and "key":
static inline const char *forecast_value_(const std::string &s, size_t pos, const char *key, size_t end) {
size_t k = s.find(key, pos);
if (k == std::string::npos || k >= end) return nullptr;
k = s.find(':', k + std::strlen(key));
if (k == std::string::npos || k >= end) return nullptr;
while (++k < end && (s[k] == ' ' || s[k] == '\'' || s[k] == '"')) {
}
return s.c_str() + k;
}
// Fills up to n days starting at index `first`; returns how many were parsed.
inline int parse_forecast(const std::string &s, int first, ForecastDay *out, int n) {
int index = 0, got = 0;
size_t pos = 0;
while (got < n && (pos = s.find('{', pos)) != std::string::npos) {
size_t end = s.find('}', pos);
if (end == std::string::npos) break;
if (index++ >= first) {
const char *cond = forecast_value_(s, pos, "condition", end);
const char *high = forecast_value_(s, pos, "temperature", end);
const char *low = forecast_value_(s, pos, "templow", end);
if (cond && high && low) {
out[got].condition.assign(cond, std::strcspn(cond, "'\","));
out[got].high = std::strtof(high, nullptr);
out[got].low = std::strtof(low, nullptr);
++got;
}
}
pos = end;
}
return got;
}
+4
View File
@@ -2,3 +2,7 @@
ota: ota:
- platform: esphome - platform: esphome
password: !secret ota_password password: !secret ota_password
# migration to encrypted OTA (api key): once every device encrypts,
# remove allow_plaintext_upload together with the password
encryption:
allow_plaintext_upload: true
+5
View File
@@ -1,5 +1,10 @@
--- ---
ota: ota:
- platform: esphome - platform: esphome
id: ota_esphome
password: !secret ota_password password: !secret ota_password
# migration to encrypted OTA (api key): once every device encrypts,
# remove allow_plaintext_upload together with the password
encryption:
allow_plaintext_upload: true
allow_partition_access: true allow_partition_access: true
+36
View File
@@ -0,0 +1,36 @@
---
# Pip-Boy list row for mcu-lvgl's DATA tab: name left, value (id ${row}_val) right, select by touch
# vars: row (widget id), name (left text), idx (row index for select_row)
obj:
id: ${row}
width: 100%
height: 44
pad_left: 10
pad_right: 10
border_side: [BOTTOM]
border_width: 1
border_color: ${pip_line}
bg_color: ${pip_panel}
layout:
type: flex
flex_flow: row
flex_align_cross: center
pad_column: 12
on_press:
- script.execute:
id: select_row
row: ${idx}
widgets:
- obj:
id: ${row}_mark
width: 10
height: 10
bg_color: ${pip_green}
bg_opa: COVER
hidden: true
- label:
flex_grow: 1
text: "${name}"
- label:
id: ${row}_val
text: "--"
+1 -2
View File
@@ -2,9 +2,8 @@
platform: uptime platform: uptime
name: Uptime name: Uptime
id: uptime_sensor id: uptime_sensor
unit_of_measurement: "days" unit_of_measurement: d # HA unit for duration; MQTT discovery rejects "days"
accuracy_decimals: 2 accuracy_decimals: 2
update_interval: 60s update_interval: 60s
filters: filters:
- lambda: return x / 86400; - lambda: return x / 86400;
+127
View File
@@ -0,0 +1,127 @@
---
# Status on a visible RGB light, which stays a normal light otherwise:
# network down red, slow blink
# no API client (HA) orange, slow blink
# component error purple, steady (only with show_errors: "true", for a dedicated status LED)
# OTA blue, fast blink; green when done, 3 red blinks on error
# back to normal green for 1 s, then the light goes back to how it was
# packages:
# status_led: !include
# file: common/status_led.yaml
# vars:
# light_id: led_light
# Needs the ota id ota_esphome (common/ota_esp32.yaml).
defaults:
brightness: "0.3"
show_errors: "false" # a failed component would take over a display or a shared light for good
globals:
- id: status_led_active
type: bool
initial_value: "false"
- id: status_led_saved
type: light::LightColorValues
- id: status_led_last
type: uint32_t
initial_value: "0xFFFFFFFF"
script:
- id: status_led_show
parameters:
r: float
g: float
b: float
lit: bool
then:
- lambda: |-
auto *l = id(${light_id});
uint32_t key = (lit << 24) | (uint32_t(r * 255) << 16) | (uint32_t(g * 255) << 8) | uint32_t(b * 255);
if (!id(status_led_active)) {
id(status_led_saved) = l->remote_values;
id(status_led_active) = true;
} else if (key == id(status_led_last)) {
return; // unchanged: don't flood Home Assistant with the same state
}
id(status_led_last) = key;
if (lit) {
l->turn_on().set_rgb(r, g, b).set_brightness(${brightness}).set_transition_length(0).set_effect("None").perform();
} else {
l->turn_off().set_transition_length(0).perform();
}
l->loop(); // write now: OTA blocks the main loop
- id: status_led_restore
parameters:
confirm: bool
then:
- lambda: |-
if (id(status_led_active) && confirm) id(status_led_show)->execute(0.0f, 1.0f, 0.0f, true);
- if:
condition:
lambda: 'return id(status_led_active) && confirm;'
then:
- delay: 1s # green: back to normal
- lambda: |-
if (!id(status_led_active)) return;
id(status_led_active) = false;
id(status_led_last) = 0xFFFFFFFF;
id(${light_id})->make_call().from_light_color_values(id(status_led_saved)).set_transition_length(0).perform();
interval:
- interval: 500ms
then:
- lambda: |-
static uint8_t tick = 0;
tick++;
bool slow = (tick / 2) % 2 == 0; // 1 s on, 1 s off
bool error = ${show_errors} && (App.get_app_state() & STATUS_LED_ERROR);
bool problem = !network::is_connected() || !api::global_api_server->is_connected() || error;
if (problem) id(status_led_restore)->stop();
if (!network::is_connected()) {
id(status_led_show)->execute(1.0f, 0.0f, 0.0f, slow);
} else if (!api::global_api_server->is_connected()) {
id(status_led_show)->execute(1.0f, 0.4f, 0.0f, slow);
} else if (error) {
id(status_led_show)->execute(0.6f, 0.0f, 1.0f, true);
} else if (id(status_led_active) && !id(status_led_restore)->is_running()) {
id(status_led_restore)->execute(true);
}
ota:
- id: !extend ota_esphome
on_begin:
- script.execute:
id: status_led_show
r: 0.0
g: 0.0
b: 1.0
lit: true
on_progress:
- lambda: 'id(status_led_show)->execute(0.0f, 0.0f, 1.0f, (millis() / 250) % 2 == 0);'
on_end:
- script.execute:
id: status_led_show
r: 0.0
g: 1.0
b: 0.0
lit: true
on_error:
- repeat:
count: 3
then:
- script.execute:
id: status_led_show
r: 1.0
g: 0.0
b: 0.0
lit: true
- delay: 250ms
- script.execute:
id: status_led_show
r: 1.0
g: 0.0
b: 0.0
lit: false
- delay: 250ms
- script.execute:
id: status_led_restore
confirm: false
+19
View File
@@ -0,0 +1,19 @@
---
# Status LED on the M5Stack ATOM Lite's own RGB LED (G27), see common/status_led.yaml
packages:
status_led: !include
file: status_led.yaml
vars:
light_id: atom_led
show_errors: "true" # dedicated status LED
light:
- platform: esp32_rmt_led_strip
id: atom_led
internal: true
pin: 27
num_leds: 1
rmt_symbols: 64 # 1 LED is 24 bits; leave RMT memory for remote_transmitter/receiver
chipset: ws2812
channel_colors: GRB
restore_mode: ALWAYS_OFF
+2
View File
@@ -2,6 +2,8 @@ esp32:
variant: esp32 variant: esp32
toolchain: esp-idf toolchain: esp-idf
framework: framework:
advanced:
flash_chip: gd # ESP32-PICO-D4, like every other ATOM Lite
type: esp-idf type: esp-idf
external_components: external_components:
+4 -1
View File
@@ -2,8 +2,11 @@
wifi: wifi:
# reboot_timeout: 0s # reboot_timeout: 0s
networks: networks:
- ssid: !secret wifi_ssid # id lets devices override the network with '!extend wifi_iot'
- id: wifi_iot
ssid: !secret wifi_ssid
password: !secret wifi_password password: !secret wifi_password
enable_btm: true enable_btm: true
enable_rrm: true enable_rrm: true
min_auth_mode: WPA3 min_auth_mode: WPA3
power_save_mode: none
+124
View File
@@ -0,0 +1,124 @@
---
# Seeed XIAO STM32C5 as a CANopen node (mrk's canopen hub + canopen_entities), MCUboot, OTA over CAN from can2mqtt
# (upload .esphome/build/<node>/.west_build/zephyr/zephyr/zephyr.signed.bin).
# Needs: substitutions node_id; the esphomeplatformzephyr fork (esphome-zephyr).
# Pinout:
# PB12 user LED (active low) -> LED (light binary)
# PH2 BOOT0, left alone (a pull-up there sends software resets to ROM DFU)
# PB5/PB13 FDCAN2 RX/TX, PB14 CAN_STB -> on-board transceiver (board DTS)
# PB3/PB4 I2C2 SCL/SDA, LSM6DS3TR-C @0x6A -> on-board IMU (motion lsm6ds)
# First flash (TinyUF2 erased with mcu-stm32-xiao-c5-eraser.yaml), hold BOOT + press RESET for ROM DFU:
# dfu-util -a 0 -s 0x08000000 -D .esphome/build/<node>/.west_build/mcuboot/zephyr/zephyr.bin
# dfu-util -a 0 -s 0x08008000:leave -D .esphome/build/<node>/.west_build/zephyr/zephyr/zephyr.signed.bin
external_components:
- source: github://mrk-its/esphome-canopen@dc6efff43e0076a5c2820800e6ff5ce28ee4c678 # canopen_entities; newer needs consts the zephyr fork lacks
components: [canopen, canopen_entities]
stm32:
variant: STM32C5
board: xiao_stm32c5
framework:
advanced:
bootloader: mcuboot
# required by the fork for MCUboot on the XIAO; the first flash is dfu-util by hand (see above)
runner: stm32cubeprogrammer
logger:
logs:
# canbus logs every frame at DEBUG; over USB CDC that stalls the loop and the RX queue overflows
canbus: INFO
i2c:
# pins come from the board DTS (i2c2: PB3/PB4), STM32C5 takes no sda:/scl:
- id: i2c_imu
dts_node_override: i2c2
motion:
- platform: lsm6ds
id: imu
i2c_id: i2c_imu
address: 0x6A
update_interval: 5s
sensor:
- platform: lsm6ds
id: imu_temp
name: IMU Temperature
- platform: motion
motion_id: imu
id: pitch
type: pitch
name: Pitch
- platform: motion
motion_id: imu
id: roll
type: roll
name: Roll
output:
- platform: gpio
id: led_out
pin:
number: PB12
inverted: true
light:
- platform: binary
name: LED
id: led
output: led_out
# no button on PH2: it is BOOT0, and with BOOT_SEL on the pin (after tinyuf2_eraser) an internal pull-up there makes
# every software reset (OTA, reboot) start the ROM DFU bootloader instead of MCUboot
canbus:
- platform: zephyr_can
id: can_bus
can_id: 0
bit_rate: 500kbps
# an SDO block (16 frames) arrives back to back and must fit the RX queue (default 8)
rx_buffer_size: 32
canopen:
id: can_gate
canbus_id: can_bus
node_id: ${node_id}
heartbeat_interval: 5s
canopen_entities:
canopen_id: can_gate
entities:
- id: led
index: 1
tpdo: 0
# 2-byte encoding over min..max, so the three fit one TPDO
- id: pitch
index: 3
tpdo: 1
size: 2
min_value: -180
max_value: 180
- id: roll
index: 4
tpdo: 1
size: 2
min_value: -180
max_value: 180
- id: imu_temp
index: 5
tpdo: 1
size: 2
min_value: -40
max_value: 125
remote_logs:
level: INFO
ota:
- platform: canopen_entities
# the XIAO's board layout has slot0 one sector larger than slot1 (swap-move); with the fork's default
# (offset) MCUboot finds the slots incompatible and never installs the update
swap_method: move
# confirms the new MCUboot image after a good boot; without it MCUboot rolls back at the next reset
safe_mode:
+4
View File
@@ -0,0 +1,4 @@
build/
managed_components/
sdkconfig
sdkconfig.old
+6
View File
@@ -0,0 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(xiao_c6_spi)
+28
View File
@@ -0,0 +1,28 @@
= XIAO ESP32-C6 esp-hosted co-processor (SPI)
esp-hosted-mcu 3.1.0 co-processor firmware (`examples/wifi/sta/cp`) for a Seeed XIAO ESP32-C6 that gives a
XIAO ESP32-C5 its Wi-Fi over SPI (`mcu-its-g5.yaml`). The user LED (GPIO15) blinks while it runs.
Wiring, D-pin to the same D-pin on both boards, plus GND and 3V3:
[cols="1,1,1,1"]
|===
| Signal | XIAO pin | C5 GPIO | C6 GPIO
| CLK | D8 | 8 | 19
| MISO | D9 | 9 | 20
| MOSI | D10 | 10 | 18
| CS | D3 | 7 | 21
| handshake | D0 | 1 | 0
| data ready | D1 | 0 | 1
| reset | D2 | 25 | 2 (the XIAO has no EN pin)
|===
Build with the ESP-IDF that ESPHome already downloaded, and flash over USB:
----
./build.sh /dev/serial/by-id/usb-Espressif_USB_JTAG_serial_debug_unit_90:64:9B:AB:5F:DC-if00
----
Keep the esp_hosted version in `main/idf_component.yml` in step with the one ESPHome uses on the host.
ESPHome's `update: platform: esp32_hosted` only supports ESP32-P4 and ESP32-H2 hosts, so this one is flashed by hand.
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
# Build the co-processor firmware with the ESP-IDF that ESPHome already downloaded, and flash it
# when a port is given: ./build.sh [/dev/serial/by-id/usb-Espressif_...]
set -e
cd "$(dirname "$0")"
IDF=$(ls -d "$HOME"/.cache/esphome/idf/frameworks/5.5.* | sort -V | tail -1)
export IDF_PATH="$IDF" IDF_TOOLS_PATH="$HOME/.cache/esphome/idf"
export IDF_PYTHON_ENV_PATH="$HOME/.cache/esphome/idf/penvs/$(basename "$IDF")"
. "$IDF_PATH/export.sh" >/dev/null
[ -f sdkconfig ] || idf.py set-target esp32c6
idf.py build
[ -z "$1" ] || idf.py -p "$1" flash
+63
View File
@@ -0,0 +1,63 @@
dependencies:
espressif/esp_hosted:
component_hash: 22b08509494d4465f0e2f91ee16973d76fe90d5a930fa3910b7a43615db001bf
dependencies:
- name: cherry-embedded/cherryusb
registry_url: https://components.espressif.com
require: private
rules:
- if: target in [esp32p4]
- if: $CONFIG{ESP_HOSTED_HOST_USB_CHERRYUSB_MANIFEST} == 1
version: '>=1.6.0'
- name: espressif/esp_tinyusb
registry_url: https://components.espressif.com
require: private
rules:
- if: target in [esp32s2, esp32s3, esp32s31]
- if: $CONFIG{ESP_HOSTED_CP_TINYUSB_MANIFEST} == 1
version: '*'
- name: espressif/iot_usbh_rndis
registry_url: https://components.espressif.com
require: private
rules:
- if: target in [esp32p4]
- if: $CONFIG{ESP_HOSTED_HOST_USB_RNDIS_MANIFEST} == 1
version: ^0.5.2
- name: espressif/usb_host_cdc_acm
registry_url: https://components.espressif.com
require: private
rules:
- if: target in [esp32p4]
- if: $CONFIG{ESP_HOSTED_HOST_USB_CDC_ACM_MANIFEST} == 1
version: '*'
- name: idf
require: private
version: '>=5.5'
source:
registry_url: https://components.espressif.com/
type: service
targets:
- esp32
- esp32s2
- esp32s3
- esp32s31
- esp32c2
- esp32c3
- esp32c5
- esp32c6
- esp32c61
- esp32h2
- esp32h4
- esp32h21
- esp32p4
version: 3.1.0
idf:
source:
type: idf
version: 5.5.6
direct_dependencies:
- espressif/esp_hosted
- idf
manifest_hash: c37e626b03eed70cc211e75eb89460b788364cc18d9edb9dd97aec930c8ccc2c
target: esp32c6
version: 2.0.0
+4
View File
@@ -0,0 +1,4 @@
idf_component_register(SRCS "main.c"
INCLUDE_DIRS "."
REQUIRES esp_hosted
PRIV_REQUIRES nvs_flash esp_wifi)
@@ -0,0 +1,5 @@
dependencies:
espressif/esp_hosted:
version: '==3.1.0' # keep in step with the esp_hosted version ESPHome uses on the host
idf:
version: '>=5.5'
+39
View File
@@ -0,0 +1,39 @@
/*
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "esp_log.h"
#include "esp_event.h"
#include "nvs_flash.h"
#include "esp_check.h"
#include "driver/gpio.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
static const char *TAG = "wifi_mcu_example";
void app_main(void)
{
ESP_LOGI(TAG, "ESP-Hosted MCU WiFi Example Starting...");
/* Initialize NVS */
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK(ret);
/* create default event loop */
ESP_ERROR_CHECK(esp_event_loop_create_default());
/* Heartbeat on the XIAO ESP32-C6 user LED (GPIO15, active low): shows the co-processor runs. */
gpio_set_direction(GPIO_NUM_15, GPIO_MODE_OUTPUT);
for (int on = 0;; on = !on) {
gpio_set_level(GPIO_NUM_15, !on);
vTaskDelay(pdMS_TO_TICKS(500));
}
}
@@ -0,0 +1,7 @@
# ESP-Hosted shared partition table — 4 MB flash, dual OTA (1.75 MB per slot)
# Name, Type, SubType, Offset, Size
nvs, data, nvs, 0x9000, 0x4000
otadata, data, ota, 0xd000, 0x2000
phy_init, data, phy, 0xf000, 0x1000
ota_0, app, ota_0, 0x10000, 0x1C0000
ota_1, app, ota_1, 0x1D0000, 0x1C0000
1 # ESP-Hosted shared partition table — 4 MB flash, dual OTA (1.75 MB per slot)
2 # Name, Type, SubType, Offset, Size
3 nvs, data, nvs, 0x9000, 0x4000
4 otadata, data, ota, 0xd000, 0x2000
5 phy_init, data, phy, 0xf000, 0x1000
6 ota_0, app, ota_0, 0x10000, 0x1C0000
7 ota_1, app, ota_1, 0x1D0000, 0x1C0000
+25
View File
@@ -0,0 +1,25 @@
# ── Role: COPROCESSOR ────────────────────────────────────────────────
# ESP-Hosted coprocessor firmware (works with both MCU and Linux hosts
# via the unified MCU RPC v2 wire).
CONFIG_ESP_HOSTED=y
CONFIG_ESP_HOSTED_CP=y
CONFIG_ESP_HOSTED_CP_FOR_MCU=y
CONFIG_ESP_HOSTED_CP_RPC_V2=y
#Disable enterprise support by default
CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT=n
# BT Configuration
CONFIG_BT_ENABLED=n
#CONFIG_BT_CONTROLLER_ONLY=y
# OTA
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_eh_cp_ota_4m.csv"
# OS
CONFIG_FREERTOS_HZ=1000
CONFIG_ESP_WIFI_NVS_ENABLED=y
CONFIG_ESP_HOSTED_CP_FEAT_WIFI=y
@@ -0,0 +1,112 @@
# 1. CPU
#--------
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_160=y
# 2. BT Configuration
#---------------------
CONFIG_BT_ENABLED=n
CONFIG_BT_CONTROLLER_ONLY=y
CONFIG_BT_BLUEDROID_ENABLED=
CONFIG_BT_LE_SLEEP_ENABLE=y
# 3.1 BLE over SPI/SDIO
#-----------------------
CONFIG_BT_LE_HCI_INTERFACE_USE_RAM=y
# 3.2 BLE over UART
#-------------------
# Enable below config, delete sdkconfig, build/ and rebuild
# CONFIG_BT_LE_HCI_INTERFACE_USE_UART=y
# CONFIG_BT_LE_HCI_UART_TX_PIN=5
# CONFIG_BT_LE_HCI_UART_RX_PIN=12
# CONFIG_BT_LE_HCI_UART_FLOWCTRL=n
# # 4 pin solution is not working yet for c6
# #CONFIG_BT_LE_HCI_UART_RTS_PIN=9
# #CONFIG_BT_LE_HCI_UART_CTS_PIN=13
# 4. Partition Table
#--------------------
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_eh_cp_ota_4m.csv"
# 5. Mempool
#------------
CONFIG_ESP_CACHE_MALLOC=y
# # 6.1 LWIP split
# #---------------
#
# CONFIG_ESP_HOSTED_CP_FEAT_NW_SPLIT=y
# CONFIG_LWIP_TCP_LOCAL_PORT_RANGE_START=61440
# CONFIG_LWIP_TCP_LOCAL_PORT_RANGE_END=65535
# CONFIG_LWIP_UDP_LOCAL_PORT_RANGE_START=61440
# CONFIG_LWIP_UDP_LOCAL_PORT_RANGE_END=65535
#
#
# # 6.2 LWIP split examples
# #-------------------------
# 7. Transport config
#---------------------
# ESP_HOSTED_TRANSPORT_CP_SDIO_NSEND_PSAMPLE=y
# ESP_HOSTED_TRANSPORT_CP_SDIO_DEFAULT_SPEED=y
#ESP_HOSTED_TRANSPORT_CP_SDIO_STREAMING_MODE=y
# For SPI Full duplex C6 on ESP32-P4-Function-EV-Board, please uncomment below
#CONFIG_ESP_HOST_DEV_BOARD_P4_FUNC_BOARD=y
#CONFIG_ESP_HOSTED_TRANSPORT_CP_SPI=y
# 8. Wifi config
#----------------
CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=20
CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=64
CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=64
CONFIG_ESP_WIFI_AMPDU_TX_ENABLED=y
CONFIG_ESP_WIFI_TX_BA_WIN=32
CONFIG_ESP_WIFI_AMPDU_RX_ENABLED=y
CONFIG_ESP_WIFI_RX_BA_WIN=32
CONFIG_ESP_WIFI_RX_IRAM_OPT=y
CONFIG_ESP_WIFI_IRAM_OPT=y
# # 9. LWIP config
# #----------------
# CONFIG_LWIP_TCP_SND_BUF_DEFAULT=65535
# CONFIG_LWIP_TCP_WND_DEFAULT=65535
# CONFIG_LWIP_TCP_RECVMBOX_SIZE=64
# CONFIG_LWIP_UDP_RECVMBOX_SIZE=64
# CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=64
# CONFIG_LWIP_TCP_SACK_OUT=y
# #CONFIG_LWIP_TCPIP_CORE_LOCKING=y
# #CONFIG_LWIP_TCPIP_CORE_LOCKING_INPUT=y
# 10. Optimizations
#-------------------
CONFIG_COMPILER_OPTIMIZATION_PERF=y
# 11. Stats
#-----------
#CONFIG_ESP_HOSTED_FUNCTION_PROFILING=y
#CONFIG_ESP_PKT_STATS=y
# # 12 iperf task
# #--------------
# Seeed XIAO ESP32-C6 as co-processor of a XIAO ESP32-C5 over SPI, wired D-pin to the same D-pin
CONFIG_EH_TRANSPORT_CP_SPI=y
CONFIG_EH_TRANSPORT_CP_SPI_MODE_3=y
CONFIG_EH_TRANSPORT_CP_SPI_HSPI_GPIO_CLK=19
CONFIG_EH_TRANSPORT_CP_SPI_HSPI_GPIO_MISO=20
CONFIG_EH_TRANSPORT_CP_SPI_HSPI_GPIO_MOSI=18
CONFIG_EH_TRANSPORT_CP_SPI_HSPI_GPIO_CS=21
CONFIG_EH_TRANSPORT_CP_SPI_GPIO_HANDSHAKE=0
CONFIG_EH_TRANSPORT_CP_SPI_GPIO_DATA_READY=1
# The XIAO has no EN pin: the host's reset pin goes to GPIO2 (D2)
CONFIG_EH_TRANSPORT_CP_SPI_GPIO_RESET=2
+160
View File
@@ -0,0 +1,160 @@
#pragma once
// Upcoming calendar events for mcu-m5paper: parsed from the calendar.get_events
// response and kept in flash (NVS), so they survive the power-off between RTC wake-ups.
#include <algorithm>
#include <cstdio>
#include <cstring>
#include "esphome/components/json/json_util.h"
#include "esphome/core/preferences.h"
#include "esphome/core/time.h"
namespace m5paper_calendar {
static constexpr uint8_t MAX_EVENTS = 32;
static constexpr size_t SUMMARY_LEN = 44;
static constexpr uint16_t ALL_DAY = 0xFFFF;
static constexpr uint32_t PREF_HASH = 0x6D35C41A;
enum Kind : uint8_t { BIRTHDAY = 0, WASTE };
struct Event {
uint16_t day; // local date, days since 1970-01-01
uint16_t minute; // local start time in minutes after midnight, ALL_DAY if none
uint8_t kind;
char summary[SUMMARY_LEN + 1];
};
struct Events {
uint32_t fetched_at{0}; // UTC epoch of the download
uint8_t count{0};
Event items[MAX_EVENTS]{};
bool valid() const { return this->fetched_at != 0; }
};
// the events in RAM, loaded from flash at boot
inline Events &events() {
static Events ev;
return ev;
}
// days since 1970-01-01 for a proleptic Gregorian date (H. Hinnant's algorithm)
inline int32_t days_from_civil(int y, int m, int d) {
y -= m <= 2;
const int era = (y >= 0 ? y : y - 399) / 400;
const int yoe = y - era * 400;
const int doy = (153 * (m + (m > 2 ? -3 : 9)) + 2) / 5 + d - 1;
const int doe = yoe * 365 + yoe / 4 - yoe / 100 + doy;
return era * 146097 + doe - 719468;
}
inline int32_t local_day(const esphome::ESPTime &t) { return days_from_civil(t.year, t.month, t.day_of_month); }
// 0 = Monday
inline int weekday(int32_t day) { return (day + 3) % 7; }
// "2026-10-01" (all-day) or "2026-10-01T10:00:00+02:00" -> local day and minute; false on error
inline bool parse_start(const char *s, uint16_t &day, uint16_t &minute) {
int y, mo, d, h, mi, sec = 0, oh = 0, om = 0;
char sign = '+';
int n = sscanf(s, "%d-%d-%dT%d:%d:%d%c%d:%d", &y, &mo, &d, &h, &mi, &sec, &sign, &oh, &om);
if (n < 3)
return false;
if (n < 5) {
day = days_from_civil(y, mo, d);
minute = ALL_DAY;
return true;
}
int64_t ts = int64_t(days_from_civil(y, mo, d)) * 86400 + h * 3600 + mi * 60 + sec;
if (n >= 8 && (sign == '+' || sign == '-')) {
int64_t offset = oh * 3600 + om * 60;
ts += sign == '+' ? -offset : offset;
}
if (ts <= 0)
return false;
const auto t = esphome::ESPTime::from_epoch_local(ts);
day = local_day(t);
minute = t.hour * 60 + t.minute;
return true;
}
// copy at most SUMMARY_LEN bytes without cutting a UTF-8 sequence
inline void copy_summary(char *dst, const char *src) {
size_t n = strnlen(src, SUMMARY_LEN + 1);
if (n > SUMMARY_LEN) {
n = SUMMARY_LEN;
while (n > 0 && (uint8_t(src[n]) & 0xC0) == 0x80)
n--;
}
memcpy(dst, src, n);
dst[n] = '\0';
}
// Parse the calendar.get_events response; Home Assistant wraps the action response as
// {"response": {"calendar.x": {"events": [...]}, ...}}; every calendar other than the waste one holds birthdays
inline bool parse(ArduinoJson::JsonObjectConst response, const char *waste, uint32_t now, Events &ev) {
ArduinoJson::JsonObjectConst root = response["response"].is<ArduinoJson::JsonObjectConst>()
? response["response"].as<ArduinoJson::JsonObjectConst>()
: response;
if (root.size() == 0)
return false;
Events out;
for (ArduinoJson::JsonPairConst cal : root) {
const uint8_t kind = strcmp(cal.key().c_str(), waste) == 0 ? WASTE : BIRTHDAY;
for (ArduinoJson::JsonObjectConst item : cal.value()["events"].as<ArduinoJson::JsonArrayConst>()) {
Event e;
if (!parse_start(item["start"] | "", e.day, e.minute))
continue;
e.kind = kind;
copy_summary(e.summary, item["summary"] | "");
// the same birthday in the contacts and the manual calendar
if (std::any_of(out.items, out.items + out.count,
[&e](const Event &o) { return o.day == e.day && strcmp(o.summary, e.summary) == 0; }))
continue;
if (out.count < MAX_EVENTS) {
out.items[out.count++] = e;
continue;
}
// full: keep the nearest events
Event *last = std::max_element(out.items, out.items + out.count,
[](const Event &a, const Event &b) { return a.day < b.day; });
if (e.day < last->day)
*last = e;
}
}
std::sort(out.items, out.items + out.count, [](const Event &a, const Event &b) {
// all-day (0xFFFF wraps to 0) first
return a.day != b.day ? a.day < b.day : uint16_t(a.minute + 1) < uint16_t(b.minute + 1);
});
out.fetched_at = now;
ev = out;
return true;
}
// battery cycle: refreshed once a day, after midnight
inline bool stale(const esphome::ESPTime &now) {
const auto &ev = events();
return !ev.valid() || !now.is_valid() || now.timestamp - ev.fetched_at >= 20 * 3600;
}
inline esphome::ESPPreferenceObject &pref() {
static esphome::ESPPreferenceObject p = esphome::global_preferences->make_preference<Events>(PREF_HASH, true);
return p;
}
inline bool load(Events &ev) {
if (!pref().load(&ev)) {
ev = Events{};
return false;
}
ev.count = std::min(ev.count, MAX_EVENTS);
return true;
}
// written to flash right away: the board may power off before the next preferences flush
inline bool save(const Events &ev) { return pref().save(&ev) && esphome::global_preferences->sync(); }
} // namespace m5paper_calendar
+148
View File
@@ -0,0 +1,148 @@
#pragma once
// Moonraker client for mcu-cnc-pendant on its own FreeRTOS task: esp_http_client blocks
// (DNS is not bounded by timeout_ms), so the main loop only queues commands and reads
// the last polled status. An unreachable Klipper shows as "offline" instead of starving
// the loop into the task watchdog.
#include <deque>
#include <mutex>
#include <string>
#include "esp_http_client.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esphome/components/json/json_util.h"
#include "esphome/core/hal.h"
#include "esphome/core/log.h"
namespace moonraker {
struct Status {
float pos[3]{};
std::string homed;
std::string state{"offline"};
};
class Client {
public:
void start(const char *base) {
this->base_ = base;
xTaskCreate(task, "moonraker", 6144, this, 1, nullptr);
}
// Run G-code; dropped when Klipper is not keeping up.
void gcode(const std::string &script) {
JsonDocument doc;
doc["script"] = script;
std::string body;
serializeJson(doc, body);
this->post("/printer/gcode/script", body);
}
// urgent: throw away everything queued and send this first (emergency stop)
void post(const std::string &path, const std::string &body = "", bool urgent = false) {
std::lock_guard<std::mutex> lock(this->mutex_);
if (urgent) {
this->queue_.clear();
} else if (this->queue_.size() >= MAX_QUEUE) {
return;
}
this->queue_.emplace_back(path, body);
}
Status status() {
std::lock_guard<std::mutex> lock(this->mutex_);
return this->status_;
}
protected:
static constexpr size_t MAX_QUEUE = 8;
static constexpr uint32_t POLL_MS = 250;
static constexpr int TIMEOUT_MS = 1000;
static void task(void *arg) {
auto *self = static_cast<Client *>(arg);
uint32_t last_poll = 0;
for (;;) {
std::pair<std::string, std::string> cmd;
bool have_cmd = false;
{
std::lock_guard<std::mutex> lock(self->mutex_);
if (!self->queue_.empty()) {
cmd = std::move(self->queue_.front());
self->queue_.pop_front();
have_cmd = true;
}
}
if (have_cmd) {
int code = self->request(cmd.first, &cmd.second, nullptr);
if (code != 200)
ESP_LOGW("moonraker", "POST %s failed (%d): %s", cmd.first.c_str(), code, cmd.second.c_str());
continue; // drain commands before the next poll
}
if (esphome::millis() - last_poll >= POLL_MS) {
last_poll = esphome::millis();
self->poll();
}
vTaskDelay(pdMS_TO_TICKS(10));
}
}
void poll() {
std::string body;
Status s;
if (this->request("/printer/objects/query?gcode_move=gcode_position&toolhead=homed_axes&print_stats=state",
nullptr, &body) == 200) {
auto doc = esphome::json::parse_json(body);
JsonObject st = doc["result"]["status"];
JsonArray p = st["gcode_move"]["gcode_position"];
for (int i = 0; i < 3; i++)
s.pos[i] = p[i];
s.homed = st["toolhead"]["homed_axes"].as<std::string>();
s.state = st["print_stats"]["state"].as<std::string>();
} else {
std::lock_guard<std::mutex> lock(this->mutex_);
s.pos[0] = this->status_.pos[0]; // keep the last position, only flag offline
s.pos[1] = this->status_.pos[1];
s.pos[2] = this->status_.pos[2];
}
std::lock_guard<std::mutex> lock(this->mutex_);
this->status_ = std::move(s);
}
// POST when body is set, GET otherwise; returns the HTTP status or -1
int request(const std::string &path, const std::string *body, std::string *out) {
std::string url = this->base_ + path;
esp_http_client_config_t cfg{};
cfg.url = url.c_str();
cfg.timeout_ms = TIMEOUT_MS;
cfg.method = body ? HTTP_METHOD_POST : HTTP_METHOD_GET;
esp_http_client_handle_t c = esp_http_client_init(&cfg);
if (c == nullptr)
return -1;
int code = -1;
int len = body ? body->size() : 0;
if (len > 0)
esp_http_client_set_header(c, "Content-Type", "application/json");
if (esp_http_client_open(c, len) == ESP_OK && (len == 0 || esp_http_client_write(c, body->data(), len) == len)) {
esp_http_client_fetch_headers(c);
code = esp_http_client_get_status_code(c);
char buf[256];
int n;
while (out != nullptr && (n = esp_http_client_read(c, buf, sizeof(buf))) > 0)
out->append(buf, n);
}
esp_http_client_cleanup(c);
return code;
}
std::string base_;
std::mutex mutex_;
std::deque<std::pair<std::string, std::string>> queue_;
Status status_;
};
inline Client client;
} // namespace moonraker
+18 -10
View File
@@ -1,4 +1,12 @@
--- ---
# Hardware: IKEA VINDRIKTNING (modded) + M5Stack M5Stamp Pico
# Pinout:
# GPIO21 PM1006 UART -> particle_uart (uart tx_pin)
# GPIO22 PM1006 UART -> particle_uart (uart rx_pin)
# GPIO25 TZT 8-bit WS2812 5050 stick (8 LEDs, 7 visible outside) -> NEO [neo] (light esp32_rmt_led_strip), also status
# GPIO27 Onboard RGB LED (1x WS2812, inside), unused
# GPIO32 Grove SDA -> i2c (i2c sda)
# GPIO33 Grove SCL -> i2c (i2c scl)
substitutions: substitutions:
device: air-office-r device: air-office-r
name: Office R Air name: Office R Air
@@ -16,10 +24,17 @@ esp32:
variant: esp32 variant: esp32
toolchain: esp-idf toolchain: esp-idf
framework: framework:
advanced:
flash_chip: gd
type: esp-idf type: esp-idf
packages: packages:
common: !include common/common.yaml common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
status_led: !include
file: common/status_led.yaml
vars:
light_id: neo
i2c: i2c:
# - id: i2c0 # - id: i2c0
@@ -46,20 +61,13 @@ uart:
# inverted: true # inverted: true
light: light:
- platform: esp32_rmt_led_strip # also the status light (common/status_led.yaml): back to its previous state when all is fine
# name: LED
id: neo
channel_colors: GRB
pin: 27
num_leds: 1
chipset: ws2812
restore_mode: ALWAYS_OFF
- platform: esp32_rmt_led_strip - platform: esp32_rmt_led_strip
name: NEO name: NEO
id: neo_strip id: neo
channel_colors: GRB channel_colors: GRB
pin: 25 pin: 25
num_leds: 7 num_leds: 7 # 8 on the stick, the 8th one is hidden
chipset: ws2812 chipset: ws2812
restore_mode: ALWAYS_OFF restore_mode: ALWAYS_OFF
effects: effects:
+91
View File
@@ -0,0 +1,91 @@
---
# Hardware: Aixun H310D hot air station WiFi/BLE module = bare ESP32-C3 (QFN32), 4MB flash.
# Flashed via header P2 (native USB): GND, D+(GPIO19), D-(GPIO18), 5V. Stock fw backup in ~/aixun-h310d-backup/.
# UART0 GPIO20(RX)/GPIO21(TX) <-> GD32 main MCU, 115200. Logger on USB-Serial/JTAG.
# The aixun component (model H310D) pairs as a BS08 remote: status, temperature/fan/presets, panel WiFi icon.
substitutions:
device: aixun-h310d
name: Aixun H310D
name_short: H310D
area: Lab
comment: Hot air station
esphome:
name: mcu-${device}
friendly_name: ${name}
area: ${area}
comment: ${comment}
esp32:
variant: esp32c3
board: esp32-c3-devkitm-1
framework:
type: esp-idf
logger:
hardware_uart: USB_SERIAL_JTAG
packages:
common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
external_components:
- source: github://randybb/esphome-components
components: [aixun]
uart:
id: mcu_uart
rx_pin: GPIO20
tx_pin: GPIO21
baud_rate: 115200
rx_buffer_size: 1024
aixun:
id: h310d
model: H310D
uart_id: mcu_uart
update_interval: 1s
text_sensor:
- platform: aixun
device_model:
name: MCU Model
firmware_version:
name: MCU Firmware
serial_number:
name: MCU Serial
heater_status:
name: Status
sensor:
- platform: aixun
current_temperature:
name: Temperature
current_fan_speed:
name: Fan
heating_power:
name: Heating Power
number:
- platform: aixun
target_temperature:
name: Target Temperature
fan_speed:
name: Fan Speed
button:
- platform: aixun
preset_m1:
name: Preset M1
preset_m2:
name: Preset M2
preset_m3:
name: Preset M3
# The panel's WiFi STA / AP menu toggles, repurposed as feature switches.
binary_sensor:
- platform: aixun
sta_mode:
name: STA Toggle
ap_mode:
name: AP Toggle
+12
View File
@@ -1,4 +1,14 @@
--- ---
# Hardware: Apollo Automation ESK-1 ESPHome Starter Kit
# Pinout:
# GPIO0 -> i2c_1 (i2c scl)
# GPIO1 -> i2c_1 (i2c sda)
# GPIO4 -> Accessory Power (switch gpio)
# GPIO5 -> Onboard RGB LED (light esp32_rmt_led_strip)
# GPIO14 -> RGB LEDs (light esp32_rmt_led_strip)
# GPIO18 -> buzzer_output (output ledc)
# I2C:
# 0x38 aht20 (sensor aht10)
substitutions: substitutions:
device: apollo-dev #test device: apollo-dev #test
name: Apollo DEV #test name: Apollo DEV #test
@@ -16,6 +26,8 @@ esp32:
flash_size: 8MB flash_size: 8MB
toolchain: esp-idf toolchain: esp-idf
framework: framework:
advanced:
flash_chip: generic
type: esp-idf type: esp-idf
packages: packages:
+60 -5
View File
@@ -1,4 +1,23 @@
--- ---
# Hardware: M5Stack AtomS3
# Pinout:
# GPIO1 Grove SCL -> motor_in1 (output gpio)
# GPIO2 Grove SDA -> motor_in2 (output gpio)
# GPIO5 -> canbus/esp32_can (canbus esp32_can tx_pin)
# GPIO6 -> canbus/esp32_can (canbus esp32_can rx_pin)
# GPIO15 -> display_tft (display mipi_spi cs_pin)
# GPIO16 -> gpio_tft_backlight (output ledc)
# GPIO17 -> spi (spi clk_pin)
# GPIO21 -> spi (spi mosi_pin)
# GPIO33 -> display_tft (display mipi_spi dc_pin)
# GPIO34 -> display_tft (display mipi_spi reset_pin)
# GPIO38 -> i2c_main (i2c sda)
# GPIO39 -> i2c_main (i2c scl)
# GPIO41 -> Button (binary_sensor gpio) (inverted)
# I2C:
# 0x21 pcf8574_hub (pcf8574)
# 0x26 m5stack_relay_1 (m5stack_4relay)
# 0x3C lcd (display ssd1306_i2c)
substitutions: substitutions:
device: atoms3 device: atoms3
name: AtomS3 name: AtomS3
@@ -23,6 +42,8 @@ esp32:
flash_size: 8MB flash_size: 8MB
toolchain: esp-idf toolchain: esp-idf
framework: framework:
advanced:
flash_chip: gd
type: esp-idf type: esp-idf
ota: ota:
@@ -33,12 +54,14 @@ pcf8574:
address: 0x21 address: 0x21
pcf8575: true pcf8575: true
animation: image:
- file: "assets/images/blinky.gif" - platform: animation
file: "assets/images/blinky.gif"
id: blinky id: blinky
resize: 128x128 resize: 128x128
type: RGB565 type: RGB565
- file: "assets/images/vault_boy_walking.gif" - platform: animation
file: "assets/images/vault_boy_walking.gif"
id: vaultboy id: vaultboy
resize: 168x121 resize: 168x121
type: RGB565 type: RGB565
@@ -108,6 +131,11 @@ external_components:
packages: packages:
common: !include common/common.yaml common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
status_led: !include
file: common/status_led.yaml
vars:
light_id: status_frame
# common: !include common/common_wo_debug.yaml # common: !include common/common_wo_debug.yaml
# common: !include common/common_dev.yaml # common: !include common/common_dev.yaml
@@ -211,12 +239,32 @@ output:
- platform: ledc - platform: ledc
pin: 16 pin: 16
id: gpio_tft_backlight id: gpio_tft_backlight
# virtual RGB light for common/status_led.yaml, shown full screen on the display
- platform: template
id: status_frame_r
type: float
write_action: []
- platform: template
id: status_frame_g
type: float
write_action: []
- platform: template
id: status_frame_b
type: float
write_action: []
light: light:
- platform: monochromatic - platform: monochromatic
id: display_tft_backlight id: display_tft_backlight
output: gpio_tft_backlight output: gpio_tft_backlight
restore_mode: ALWAYS_ON restore_mode: ALWAYS_ON
- platform: rgb
id: status_frame
internal: true
red: status_frame_r
green: status_frame_g
blue: status_frame_b
restore_mode: ALWAYS_OFF
switch: switch:
- platform: template - platform: template
@@ -372,6 +420,7 @@ display:
- platform: mipi_spi - platform: mipi_spi
model: ST7789V model: ST7789V
id: display_tft id: display_tft
byte_order: little_endian # colours were byte-swapped (purple showed as green)
dimensions: dimensions:
height: 128 height: 128
width: 128 width: 128
@@ -384,11 +433,18 @@ display:
# eightbitcolor: true # eightbitcolor: true
update_interval: 1s update_interval: 1s
lambda: |- lambda: |-
// status screen (common/status_led.yaml): the whole display in the status colour
auto &sv = id(status_frame)->current_values;
if (sv.is_on()) {
it.fill(Color(sv.get_red() * 255, sv.get_green() * 255, sv.get_blue() * 255));
return;
}
//Ingress shown animation Frame. //Ingress shown animation Frame.
id(blinky).next_frame(); id(blinky).next_frame();
// Draw the animation my_animation at position [x=0,y=0] // Draw the animation my_animation at position [x=0,y=0]
it.image(0, 0, id(blinky), COLOR_ON, COLOR_OFF); it.image(0, 0, id(blinky), COLOR_ON, COLOR_OFF);
// // it.print(0, 0, id(font_default), "Hello World!"); // // it.print(0, 0, id(font_default), "Hello World!");
// // it.strftime(0, 0, id(font_default), TextAlign::TOP_LEFT, "%H:%M", id(ha_time).now()); // // it.strftime(0, 0, id(font_default), TextAlign::TOP_LEFT, "%H:%M", id(ha_time).now());
// it.rectangle(0, 0, it.get_width(), it.get_height(), id(my_blue)); // it.rectangle(0, 0, it.get_width(), it.get_height(), id(my_blue));
@@ -491,8 +547,7 @@ sensor:
# name: Dallas Temp 4 # name: Dallas Temp 4
# one_wire_id: hub_1 # one_wire_id: hub_1
time: # time:
- !include common/time/homeassistant.yaml
# - platform: sntp # - platform: sntp
# id: sntp_time # id: sntp_time
# timezone: Europe/Bratislava # timezone: Europe/Bratislava
+9 -8
View File
@@ -1,4 +1,12 @@
--- ---
# Hardware: Sonoff Dual R2
# Pinout:
# GPIO0 Pin "button 0" on expansion header
# GPIO5 Relay #2 and green color on LED -> relay_2 (output gpio)
# GPIO9 Pin "button 1" on expansion header
# GPIO10 Push Button
# GPIO12 Relay #1 and red color on LED -> relay_1 (output gpio)
# GPIO13 Blue Status LED -> status_led (status_led) (inverted)
substitutions: substitutions:
device: basement-2 device: basement-2
name_short: Basement name_short: Basement
@@ -17,14 +25,7 @@ esp8266:
packages: packages:
common: !include common/common_esp8266.yaml common: !include common/common_esp8266.yaml
mdns_ipv6: !include common/esp8266_mdns_ipv6.yaml
# Sonoff Dual R2
# GPIO10 Push Button
# GPIO00 Pin "button 0" on expansion header
# GPIO09 Pin "button 1" on expansion header
# GPIO12 Relay #1 and red color on LED
# GPIO05 Relay #2 and green color on LED
# GPIO13 Blue Status LED
status_led: status_led:
pin: pin:
+10 -11
View File
@@ -1,4 +1,12 @@
--- ---
# Hardware: Sonoff Dual R2
# Pinout:
# GPIO0 Pin "button 0" on expansion header -> Light Switch (binary_sensor gpio) (inverted)
# GPIO5 Relay #2 and green color on LED -> Socket 1 (switch gpio)
# GPIO9 Pin "button 1" on expansion header -> Door (binary_sensor gpio) (inverted)
# GPIO10 Push Button -> Socket 1 Switch (binary_sensor gpio) (inverted)
# GPIO12 Relay #1 and red color on LED -> Sewage Treatment Aerator Pump [relay_1] (switch gpio)
# GPIO13 Blue Status LED -> status_led (status_led) (inverted)
substitutions: substitutions:
device: basement device: basement
name: Basement name: Basement
@@ -16,15 +24,7 @@ esp8266:
packages: packages:
common: !include common/common_esp8266.yaml common: !include common/common_esp8266.yaml
mdns_ipv6: !include common/esp8266_mdns_ipv6.yaml
# Sonoff Dual R2
# Pin Function
# GPIO10 Push Button
# GPIO00 Pin "button 0" on expansion header
# GPIO09 Pin "button 1" on expansion header
# GPIO12 Relay #1 and red color on LED
# GPIO05 Relay #2 and green color on LED
# GPIO13 Blue Status LED
globals: globals:
- id: aerator_auto - id: aerator_auto
@@ -139,8 +139,7 @@ switch:
id: relay_2 id: relay_2
time: time:
- platform: homeassistant - id: !extend ha_time
timezone: Europe/Bratislava
on_time: on_time:
- seconds: 0 - seconds: 0
minutes: /15 minutes: /15
+21 -8
View File
@@ -1,4 +1,23 @@
--- ---
# Hardware: Xiaomi Mi Bedside Lamp 2 (ESP-WROOM-32D, single core; RGBW LEDs)
# Pinout (github.com/mmakaay/esphome-xiaomi_bslamp2, doc/technical_details.md):
# GPIO1 Debug pad TX
# GPIO2 Debug pad, free I/O
# GPIO3 Debug pad RX
# GPIO4 LEDs master switch 2
# GPIO5 LEDs blue PWM
# GPIO12 LEDs white PWM
# GPIO13 LEDs red PWM
# GPIO14 LEDs green PWM
# GPIO16 Front panel interrupt
# GPIO17 EEPROM I2C SDA
# GPIO18 EEPROM I2C SCL
# GPIO19 Front panel I2C SCL -> front_panel_i2c (i2c scl)
# GPIO21 Front panel I2C SDA -> front_panel_i2c (i2c sda)
# GPIO33 LEDs master switch 1
# I2C:
# 0x10 EEPROM-like IC on its own bus (GPIO17/18), not configured
# 0x2C Front panel
substitutions: substitutions:
device: bedroom-lamp-left device: bedroom-lamp-left
name: Bedroom Lamp Left name: Bedroom Lamp Left
@@ -20,6 +39,7 @@ esp32:
sdkconfig_options: sdkconfig_options:
CONFIG_FREERTOS_UNICORE: y CONFIG_FREERTOS_UNICORE: y
advanced: advanced:
flash_chip: generic
ignore_efuse_custom_mac: true ignore_efuse_custom_mac: true
ignore_efuse_mac_crc: true ignore_efuse_mac_crc: true
@@ -32,14 +52,7 @@ external_components:
packages: packages:
common: !include common/common.yaml common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
# Mi Desk Lamp
# Pin Function (Name)
# GPIO02: Button (GPIO_KEY1)
# GPIO04: Cold White (GPIO_PWM1)
# GPIO05: Warm White (GPIO_PWM2)
# GPIO12: Rotary switch A pin (GPIO_ROT_A)
# GPIO13: Rotary switch B pin (GPIO_ROT_B)
# ------------------------------------------------------------------------ # ------------------------------------------------------------------------
# Behavior: default # Behavior: default
+22 -9
View File
@@ -1,4 +1,23 @@
--- ---
# Hardware: Xiaomi Mi Bedside Lamp 2 (ESP-WROOM-32D, single core; RGBW LEDs)
# Pinout (github.com/mmakaay/esphome-xiaomi_bslamp2, doc/technical_details.md):
# GPIO1 Debug pad TX
# GPIO2 Debug pad, free I/O
# GPIO3 Debug pad RX
# GPIO4 LEDs master switch 2
# GPIO5 LEDs blue PWM
# GPIO12 LEDs white PWM
# GPIO13 LEDs red PWM
# GPIO14 LEDs green PWM
# GPIO16 Front panel interrupt
# GPIO17 EEPROM I2C SDA
# GPIO18 EEPROM I2C SCL
# GPIO19 Front panel I2C SCL -> front_panel_i2c (i2c scl)
# GPIO21 Front panel I2C SDA -> front_panel_i2c (i2c sda)
# GPIO33 LEDs master switch 1
# I2C:
# 0x10 EEPROM-like IC on its own bus (GPIO17/18), not configured
# 0x2C Front panel
substitutions: substitutions:
device: bedroom-lamp-right device: bedroom-lamp-right
name: Bedroom Lamp Right name: Bedroom Lamp Right
@@ -20,6 +39,7 @@ esp32:
sdkconfig_options: sdkconfig_options:
CONFIG_FREERTOS_UNICORE: y CONFIG_FREERTOS_UNICORE: y
advanced: advanced:
flash_chip: generic
ignore_efuse_custom_mac: true ignore_efuse_custom_mac: true
ignore_efuse_mac_crc: true ignore_efuse_mac_crc: true
@@ -28,18 +48,11 @@ external_components:
type: git type: git
url: https://github.com/mmakaay/esphome-xiaomi_bslamp2 url: https://github.com/mmakaay/esphome-xiaomi_bslamp2
ref: dev ref: dev
refresh: 60s refresh: 1h
packages: packages:
common: !include common/common.yaml common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
# Mi Desk Lamp
# Pin Function (Name)
# GPIO02: Button (GPIO_KEY1)
# GPIO04: Cold White (GPIO_PWM1)
# GPIO05: Warm White (GPIO_PWM2)
# GPIO12: Rotary switch A pin (GPIO_ROT_A)
# GPIO13: Rotary switch B pin (GPIO_ROT_B)
# ------------------------------------------------------------------------ # ------------------------------------------------------------------------
# Behavior: default # Behavior: default
+3
View File
@@ -1,4 +1,7 @@
--- ---
# Hardware: Espressif ESP32-C6-DevKitC-1
# Pinout:
# GPIO8 -> LED (light esp32_rmt_led_strip)
substitutions: substitutions:
device: c6-test-1 device: c6-test-1
name: C6 TEST 1 name: C6 TEST 1
+3
View File
@@ -1,4 +1,7 @@
--- ---
# Hardware: Espressif ESP32-C6-DevKitC-1
# Pinout:
# GPIO8 -> LED (light esp32_rmt_led_strip)
substitutions: substitutions:
device: c6-test-2 device: c6-test-2
name: C6 TEST 2 name: C6 TEST 2
+17
View File
@@ -1,4 +1,21 @@
--- ---
# Hardware: ESP32-CAM (AI-Thinker style, runs hot)
# Pinout:
# GPIO0 -> Camera (esp32_camera)
# GPIO5 -> Camera (esp32_camera data_pins)
# GPIO18 -> Camera (esp32_camera data_pins)
# GPIO19 -> Camera (esp32_camera data_pins)
# GPIO21 -> Camera (esp32_camera data_pins)
# GPIO22 -> Camera (esp32_camera pixel_clock_pin)
# GPIO23 -> Camera (esp32_camera href_pin)
# GPIO25 -> Camera (esp32_camera vsync_pin)
# GPIO26 -> i2c_bus (i2c sda)
# GPIO27 -> i2c_bus (i2c scl)
# GPIO32 -> Enable (switch gpio)
# GPIO34 -> Camera (esp32_camera data_pins)
# GPIO35 -> Camera (esp32_camera data_pins)
# GPIO36 -> Camera (esp32_camera data_pins)
# GPIO39 -> Camera (esp32_camera data_pins)
substitutions: substitutions:
device: cam-1 device: cam-1
name: Cam 1 name: Cam 1
+6
View File
@@ -1,4 +1,10 @@
--- ---
# Hardware: ESP32 DevKit
# Pinout:
# GPIO0 -> Boot (binary_sensor gpio) (inverted)
# GPIO2 -> LED (switch gpio)
# GPIO22 -> can_bus (canbus esp32_can rx_pin)
# GPIO23 -> can_bus (canbus esp32_can tx_pin)
substitutions: substitutions:
device: can-node-1 device: can-node-1
name: CAN Node 1 name: CAN Node 1
+16
View File
@@ -1,4 +1,14 @@
--- ---
# Hardware: ESP32 DevKit
# Pinout:
# GPIO2 -> LED (switch gpio, on-board blue LED)
# GPIO17 -> i2c (i2c sda)
# GPIO18 -> i2c (i2c scl)
# GPIO19 -> as3935_i2c (as3935_i2c irq_pin)
# GPIO22 -> can_bus (canbus esp32_can rx_pin)
# GPIO23 -> can_bus (canbus esp32_can tx_pin)
# I2C:
# 0x03 as3935_i2c (as3935_i2c)
substitutions: substitutions:
device: can-node-2 device: can-node-2
name: CAN Node 2 name: CAN Node 2
@@ -136,3 +146,9 @@ sensor:
# canopen: DEBUG # canopen: DEBUG
# can_driver: DEBUG # can_driver: DEBUG
# timer_driver: DEBUG # timer_driver: DEBUG
switch:
- platform: gpio
name: LED
id: blue_led
pin: 2
+396
View File
@@ -0,0 +1,396 @@
---
# Hardware: M5Stamp Pico + CAN transceiver on the OBD-II port
# Pinout:
# GPIO33 -> car_can (canbus esp32_can tx_pin)
# GPIO32 -> car_can (canbus esp32_can rx_pin)
# OBD-II: pin 6 CAN-H, pin 14 CAN-L, pin 5 signal ground; 5 V supply into the Stamp 5V pin
# (3V3 from the USB-serial programmer browns out when WiFi starts)
substitutions:
device: car-can
name: Car CAN
area: DEV
comment: Auris CAN sniffer and OBD requests
# LISTENONLY to sniff first, NORMAL for the OBD requests
can_mode: LISTENONLY
esphome:
name: mcu-${device}
friendly_name: ${name}
area: ${area}
comment: ${comment}
on_boot:
# after setup, else can_tools starts its poller again
priority: -100
then:
- component.suspend: car
esp32:
variant: esp32
framework:
type: esp-idf
advanced:
flash_chip: gd
sram1_as_iram: true
packages:
common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
external_components:
- source: github://randybb/esphome-components
components: [can_tools]
logger:
logs:
# a DEBUG line per frame drops most of the traffic
canbus: INFO
globals:
# CAN ID -> frames seen and the last data
- id: frames_per_id
type: std::map<uint32_t, std::pair<uint32_t, std::vector<uint8_t>>>
- id: ecm_last_seen
type: uint32_t
initial_value: '0'
canbus:
- platform: esp32_can
id: car_can
tx_pin: GPIO33
rx_pin: GPIO32
can_id: 0x7DF
use_extended_id: false
bit_rate: 500KBPS
mode: ${can_mode}
# ~1000 frames/s on the Auris bus
rx_queue_len: 64
max_frames_per_loop: 200
on_frame:
# every frame: count per ID, dumped by the interval below
- can_id: 0
can_id_mask: 0
then:
- lambda: |-
auto &seen = id(frames_per_id);
auto &e = seen[can_id];
e.first++;
// body frames: log every change to match it with lock/doors
// all but the frames whose data changes all the time
static const uint16_t noisy[] = {0x020, 0x024, 0x025, 0x0AA, 0x0B4, 0x1C4, 0x224, 0x260,
0x262, 0x263, 0x266, 0x2C1, 0x2C3, 0x3A0, 0x3D3, 0x4AC,
0x440, 0x442, 0x443, 0x44D, 0x640};
bool watch = std::find(std::begin(noisy), std::end(noisy), can_id) == std::end(noisy);
bool changed = e.second != x;
// 0x224 (brake): byte 5 counts, compare the rest
if (can_id == 0x224 && x.size() > 5 && e.second.size() == x.size()) {
watch = true;
auto a = x, b = e.second;
a[5] = b[5] = 0;
changed = a != b;
}
if (watch && e.first > 1 && changed) {
char hex[format_hex_pretty_size(8)];
ESP_LOGI("chg", "0x%03" PRIX32 " %s", can_id, format_hex_pretty_to(hex, x));
}
e.second = x;
# ECM frame, gone right after the engine stops (sniffed 2026-11-03)
- can_id: 0x2C1
then:
- lambda: id(ecm_last_seen) = millis();
# signals from opendbc toyota_2017.dbc, checked against this car where noted
# DOOR_LOCKS: byte 2 = unlocked doors bitmask (0x1F all, 0x10 driver, 0x08 passenger, 0x00 locked)
- can_id: 0x638
then:
- lambda: if (x.size() > 2) id(locked).publish_state(x[2] == 0);
# BODY_CONTROL_STATE: byte 5 doors open (0x20 FL checked), byte 7 0x10 parking brake, 0x40 belt unlatched
- can_id: 0x620
then:
- lambda: |-
if (x.size() < 8) return;
id(driver_door).publish_state(x[5] & 0x20);
id(passenger_door).publish_state(x[5] & 0x10);
id(rear_left_door).publish_state(x[5] & 0x04);
id(rear_right_door).publish_state(x[5] & 0x08);
id(parking_brake).publish_state(x[7] & 0x10);
id(driver_belt).publish_state(!(x[7] & 0x40));
# ENGINE_RPM: bytes 0-1 signed x 0.78125 (741 at idle), byte 3 0x08 engine running
- can_id: 0x1C4
then:
- lambda: |-
if (x.size() < 4) return;
id(engine_rpm).publish_state(int16_t(x[0] << 8 | x[1]) * 0.78125f);
id(engine_running).publish_state(x[3] & 0x08);
# SPEED: bytes 5-6 x 0.01 km/h
- can_id: 0x0B4
then:
- lambda: if (x.size() > 6) id(speed).publish_state((x[5] << 8 | x[6]) * 0.01f);
# LIGHT_STALK: byte 2 0x08 tail, byte 3 0x08 fog, 0x10 parking, 0x20 low, 0x40 high, 0x80 DRL
- can_id: 0x622
then:
- lambda: |-
if (x.size() < 4) return;
id(tail_light).publish_state(x[2] & 0x08);
id(front_fog).publish_state(x[3] & 0x08);
id(low_beam).publish_state(x[3] & 0x20);
id(high_beam).publish_state(x[3] & 0x40);
# BLINKERS_STATE: byte 3 bits 5-4 = 1 left, 2 right, 3 none; 0x08 hazard; bytes 6-7 trip A x 0.1 km
- can_id: 0x614
then:
- lambda: |-
if (x.size() < 8) return;
id(trip_a).publish_state((x[6] << 8 | x[7]) / 10.0f);
uint8_t t = (x[3] >> 4) & 3;
id(blinker_left).publish_state(t == 1);
id(blinker_right).publish_state(t == 2);
id(hazard).publish_state(x[3] & 0x08);
# BRAKE_MODULE (older opendbc): byte 0 0x20 = brake pressed (checked), bytes 4-5 pressure?
- can_id: 0x224
then:
- lambda: if (x.size() > 0) id(brake).publish_state(x[0] & 0x20);
# climate, sniffed: 0x380 byte 2 0x20 = A/C on
- can_id: 0x380
then:
- lambda: if (x.size() > 2) id(ac_on).publish_state(x[2] & 0x20);
# 0x381 byte 1 0x80 = fan auto, byte 2 = fan level
- can_id: 0x381
then:
- lambda: |-
if (x.size() < 3) return;
id(fan_auto).publish_state(x[1] & 0x80);
id(fan_level).publish_state(x[2]);
# 0x382 byte 0 = set temperature in 0.5 °C steps, 0x11 = 24 °C
- can_id: 0x382
then:
- lambda: if (x.size() > 0) id(climate_temp).publish_state(15.5f + x[0] / 2.0f);
# trip computer, sniffed: 0x615 bytes 6-7 trip B x 0.1 km
- can_id: 0x615
then:
- lambda: if (x.size() > 7) id(trip_b).publish_state((x[6] << 8 | x[7]) / 10.0f);
# 0x619 byte 4 outside temp x 0.5 °C (guess), bytes 5-6 range km
- can_id: 0x619
then:
- lambda: |-
if (x.size() < 7) return;
id(outside_temp).publish_state(x[4] / 2.0f);
id(fuel_range).publish_state(x[5] << 8 | x[6]);
# 0x61A byte 6 average consumption x 0.1 l/100 km
- can_id: 0x61A
then:
- lambda: if (x.size() > 6) id(avg_consumption).publish_state(x[6] / 10.0f);
# 0x61C byte 6 hours (guess), byte 7 minutes of drive time since start; FF:FE with the engine off
- can_id: 0x61C
then:
- lambda: if (x.size() > 7 && x[6] != 0xFF) id(drive_time).publish_state(x[6] * 60 + x[7]);
# 0x396 byte 0 0x02 = reverse gear (sniffed 3x), bytes 2-3 maybe parking sensors
- can_id: 0x396
then:
- lambda: if (x.size() > 0) id(reverse).publish_state(x[0] & 0x02);
# UI_SETTING: bytes 4-7 odometer
- can_id: 0x611
then:
- lambda: |-
if (x.size() < 8) return;
id(odometer).publish_state(uint32_t(x[4]) << 24 | x[5] << 16 | x[6] << 8 | x[7]);
interval:
- interval: 5s
then:
- lambda: |-
auto &seen = id(frames_per_id);
auto st = id(car_can).get_status();
ESP_LOGI("sniff", "%u IDs in 5 s, rx_err %u, bus_err %" PRIu32 ", missed %" PRIu32, (unsigned) seen.size(),
st.rx_error_counter, st.bus_error_count, st.rx_missed_count);
for (auto &[can_id, e] : seen) {
char hex[format_hex_pretty_size(8)];
ESP_LOGI("sniff", " 0x%03" PRIX32 " %4" PRIu32 "x %s", can_id, e.first,
format_hex_pretty_to(hex, e.second));
}
seen.clear();
can_tools:
id: car
canbus_id: car_can
requests:
- id: engine_coolant
can_id: 0x7DF
data: [0x01, 0x05]
interval: 30s
sensor:
- platform: template
id: engine_rpm
name: Engine RPM
unit_of_measurement: rpm
accuracy_decimals: 0
state_class: measurement
filters:
- throttle: 1s
- platform: template
id: speed
name: Speed
unit_of_measurement: km/h
accuracy_decimals: 0
state_class: measurement
filters:
- throttle: 1s
- platform: template
id: fan_level
name: Fan level
accuracy_decimals: 0
filters:
- delta: 1
- platform: template
id: climate_temp
name: Climate set temperature
unit_of_measurement: °C
device_class: temperature
accuracy_decimals: 1
filters:
- delta: 0.4
- platform: template
id: trip_a
name: Trip A
unit_of_measurement: km
device_class: distance
accuracy_decimals: 1
filters:
- delta: 0.1
- platform: template
id: trip_b
name: Trip B
unit_of_measurement: km
device_class: distance
accuracy_decimals: 1
filters:
- delta: 0.1
- platform: template
id: outside_temp
name: Outside temperature
unit_of_measurement: °C
device_class: temperature
state_class: measurement
accuracy_decimals: 1
filters:
- delta: 0.4
- platform: template
id: fuel_range
name: Range
unit_of_measurement: km
device_class: distance
accuracy_decimals: 0
filters:
- delta: 1
- platform: template
id: avg_consumption
name: Average consumption
unit_of_measurement: l/100km
state_class: measurement
accuracy_decimals: 1
filters:
- delta: 0.05
- platform: template
id: drive_time
name: Drive time
unit_of_measurement: min
device_class: duration
accuracy_decimals: 0
filters:
- delta: 1
- platform: template
id: odometer
name: Odometer
unit_of_measurement: km
accuracy_decimals: 0
device_class: distance
state_class: total_increasing
filters:
- delta: 1
- platform: can_tools
request_id: engine_coolant
name: Coolant
unit_of_measurement: °C
device_class: temperature
lambda: return data[2] - 40.0f;
binary_sensor:
- platform: template
id: locked
name: Locked
device_class: lock
# HA lock class: on = unlocked
filters:
- invert:
- platform: template
id: driver_door
name: Driver door
device_class: door
- platform: template
id: passenger_door
name: Passenger door
device_class: door
- platform: template
id: rear_left_door
name: Rear left door
device_class: door
- platform: template
id: rear_right_door
name: Rear right door
device_class: door
- platform: template
id: parking_brake
name: Parking brake
- platform: template
id: driver_belt
name: Driver seatbelt
- platform: template
id: tail_light
name: Tail lights
- platform: template
id: front_fog
name: Front fog lights
- platform: template
id: low_beam
name: Low beam
- platform: template
id: high_beam
name: High beam
- platform: template
id: blinker_left
name: Blinker left
- platform: template
id: blinker_right
name: Blinker right
- platform: template
id: hazard
name: Hazard lights
- platform: template
id: brake
name: Brake pressed
- platform: template
id: ac_on
name: AC
- platform: template
id: fan_auto
name: Fan auto
- platform: template
id: reverse
name: Reverse
- platform: template
id: engine_running
name: Engine running
device_class: running
- platform: template
id: ignition
name: Ignition
lambda: return id(ecm_last_seen) != 0 && millis() - id(ecm_last_seen) < 2000;
switch:
# OBD requests on demand while testing (needs can_mode: NORMAL); later driven by ignition
- platform: template
name: OBD requests
optimistic: true
restore_mode: ALWAYS_OFF
turn_on_action:
- component.resume: car
turn_off_action:
- component.suspend: car
+13 -19
View File
@@ -1,4 +1,13 @@
--- ---
# Hardware: M5Stack M5Stamp Pico
# Pinout:
# GPIO22 -> uart_distance (uart rx_pin)
# GPIO25 -> uart_distance (uart tx_pin)
# GPIO26 -> hdmi_cec (hdmi_cec)
# GPIO27 -> LED (light esp32_rmt_led_strip)
# GPIO32 Grove SDA -> i2c (i2c sda)
# GPIO33 Grove SCL -> i2c (i2c scl)
# GPIO39 -> Bedroom TV Button (binary_sensor gpio) (inverted)
substitutions: substitutions:
device: cec-bedroom device: cec-bedroom
name: Bedroom TV name: Bedroom TV
@@ -13,29 +22,18 @@ esphome:
esp32: esp32:
variant: esp32 variant: esp32
toolchain: esp-idf
framework: framework:
type: esp-idf type: esp-idf
advanced:
flash_chip: gd
sram1_as_iram: true
external_components:
# - source: github://pr#3017
# components: [hdmi_cec]
# refresh: 1h
# - source: github://Palakis/esphome-hdmi-cec
# refresh: 1h
- source: github://pr#9189
components: [hdmi_cec]
refresh: 0min
packages: packages:
common: !include common/common.yaml common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
debug: debug:
time:
- platform: homeassistant
id: ha_time
timezone: Europe/Bratislava
i2c: i2c:
# - id: i2c0 # - id: i2c0
sda: 32 sda: 32
@@ -127,10 +125,6 @@ hdmi_cec:
address: 0x05 # Audio system address: 0x05 # Audio system
# Promiscuous mode can be enabled to allow receiving messages not intended for us # Promiscuous mode can be enabled to allow receiving messages not intended for us
promiscuous_mode: false promiscuous_mode: false
# Typically the physical address is discovered based on the point-to-point
# topology of the HDMI connections using the DDC line. We don't have access
# to that so we just hardcode a physical address.
physical_address: 0x4000
pin: 26 pin: 26
on_message: on_message:
- opcode: 0x36 # opcode for "Standby" - opcode: 0x36 # opcode for "Standby"
+18 -21
View File
@@ -1,4 +1,18 @@
--- ---
# Hardware: M5Stack M5Stamp C3
# Pinout:
# GPIO0 I2C SCL
# GPIO1 I2C SDA, BUTTON
# GPIO2 RGB
# GPIO4 DISPLAY CLOCK -> tm1637_display (display tm1637 clk_pin)
# GPIO5 DISPLAY DIO -> tm1637_display (display tm1637 dio_pin)
# GPIO6 GPIO
# GPIO7 GPIO
# GPIO8 GPIO
# GPIO9 GPIO
# GPIO10 GPIO (BUZZER?) -> rtttl_out (output ledc)
# GPIO20 UART RX
# GPIO21 UART TX
substitutions: substitutions:
device: clock-1 device: clock-1
name: Clock 1 name: Clock 1
@@ -17,27 +31,15 @@ esp32:
variant: esp32c3 variant: esp32c3
toolchain: esp-idf toolchain: esp-idf
framework: framework:
advanced:
flash_chip: generic
type: esp-idf type: esp-idf
# version: 5.4.2 # version: 5.4.2
# platform_version: 54.03.21 # platform_version: 54.03.21
packages: packages:
common: !include common/common.yaml common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
# GPIO21 UART TX
# GPIO20 UART RX
# GPIO0 I2C SCL
# GPIO1 I2C SDA
# GPIO2 RGB
# GPIO1 BUTTON
# GPIO4 DISPLAY CLOCK
# GPIO5 DISPLAY DIO
# GPIO6 GPIO
# GPIO7 GPIO
# GPIO8 GPIO
# GPIO10 GPIO
#
# GPIO9 GPIO (BUZZER?)
# https://github.com/granadaxronos/120-SONG_NOKIA_RTTTL_RINGTONE_PLAYER_FOR_ARDUINO_UNO/blob/master/RTTTL_PLAYER/songs.h # https://github.com/granadaxronos/120-SONG_NOKIA_RTTTL_RINGTONE_PLAYER_FOR_ARDUINO_UNO/blob/master/RTTTL_PLAYER/songs.h
api: api:
@@ -109,11 +111,6 @@ globals:
restore_value: no restore_value: no
initial_value: "false" initial_value: "false"
time:
- platform: homeassistant
id: ha_time
timezone: Europe/Bratislava
display: display:
- platform: tm1637 - platform: tm1637
id: tm1637_display id: tm1637_display
@@ -144,7 +141,7 @@ display:
output: output:
- platform: ledc - platform: ledc
pin: 9 pin: 10
id: rtttl_out id: rtttl_out
rtttl: rtttl:
+11 -5
View File
@@ -1,4 +1,13 @@
--- ---
# Hardware: M5Stack M5Stamp Pico
# Pinout:
# GPIO25 -> rtttl_out (output ledc)
# GPIO27 -> LED (light esp32_rmt_led_strip)
# GPIO32 Grove SDA -> i2c_main (i2c sda)
# GPIO33 Grove SCL -> i2c_main (i2c scl)
# GPIO39 -> Button (binary_sensor gpio) (inverted)
# I2C:
# 0x24 tm1650_display (display tm1650)
substitutions: substitutions:
device: clock-living-room device: clock-living-room
name: Living room Clock name: Living room Clock
@@ -15,6 +24,8 @@ esp32:
variant: esp32 variant: esp32
toolchain: esp-idf toolchain: esp-idf
framework: framework:
advanced:
flash_chip: gd # ESP32-PICO-D4, like the other M5Stamp Pico (not read from the device)
type: esp-idf type: esp-idf
external_components: external_components:
@@ -51,11 +62,6 @@ globals:
restore_value: no restore_value: no
initial_value: "false" initial_value: "false"
time:
- platform: homeassistant
id: ha_time
timezone: Europe/Bratislava
binary_sensor: binary_sensor:
- platform: gpio - platform: gpio
name: Button name: Button
+247
View File
@@ -0,0 +1,247 @@
---
# Hardware: M5Stack M5Stamp S3 in the ESPendant case (github.com/positron96/ESP32_CNC_Pendant),
# talks to Klipper over Moonraker HTTP API
# Pinout:
# GPIO0 Stamp button (boot) -> stamp_button (binary_sensor gpio) (inverted)
# GPIO1 Handwheel A -> handwheel (sensor rotary_encoder pin_a)
# GPIO2 Handwheel B -> handwheel (sensor rotary_encoder pin_b)
# GPIO4 Axis encoder A -> axis_encoder (sensor rotary_encoder pin_a)
# GPIO5 Axis encoder B -> axis_encoder (sensor rotary_encoder pin_b)
# GPIO6 Axis encoder push -> axis_button (binary_sensor gpio) (inverted)
# GPIO7 Step encoder A -> step_encoder (sensor rotary_encoder pin_a)
# GPIO8 Step encoder B -> step_encoder (sensor rotary_encoder pin_b)
# GPIO9 Step encoder push -> step_button (binary_sensor gpio) (inverted)
# GPIO10 BT1 -> bt1 (binary_sensor gpio) (inverted)
# GPIO11 BT2 -> bt2 (binary_sensor gpio) (inverted)
# GPIO12 BT3 -> bt3 (binary_sensor gpio) (inverted)
# GPIO13 LCD E (SCK) -> spi (spi clk_pin)
# GPIO14 LCD R/W (MOSI) -> spi (spi mosi_pin)
# GPIO15 LCD RS (CS) -> lcd (display st7920 cs_pin)
# GPIO21 RGB LED -> status_rgb (light esp32_rmt_led_strip)
# GPIO39-44 free (BT4-BT6 later)
# LCD RST: RC to 3.3 V, PSB to GND (serial mode)
substitutions:
device: cnc-pendant
name: CNC Pendant
area: Workshop
comment: Klipper CNC pendant
moonraker: http://klipper.local:7125
max_feed: "3000" # mm/min, handwheel jog feed cap
autolock: "60" # s without jogging or selecting until the handwheel locks
esphome:
name: mcu-${device}
friendly_name: ${name}
area: ${area}
comment: ${comment}
includes:
- include/moonraker.h
on_boot:
- lambda: 'moonraker::client.start("${moonraker}");'
esp32:
variant: esp32s3
flash_size: 8MB
toolchain: esp-idf
framework:
type: esp-idf
packages:
common: !include common/common.yaml
# ipv6_only: !include common/ipv6_only.yaml
status_led: !include
file: common/status_led.yaml
vars:
light_id: status_rgb
light:
- platform: esp32_rmt_led_strip
id: status_rgb
name: LED
pin: 21
num_leds: 1
chipset: ws2812
channel_colors: GRB
restore_mode: ALWAYS_OFF
# only links esp_http_client for include/moonraker.h, which runs requests on its own task
http_request:
globals:
- id: axis
type: int
initial_value: "-1" # -1 locked, 0 X, 1 Y, 2 Z
- id: step
type: int
initial_value: "1" # index into steps[] in the jog interval
- id: wheel_sent
type: float
initial_value: "0"
- id: last_active
type: uint32_t
initial_value: "0" # millis() of the last jog or selection, drives the autolock
interval:
# handwheel: send the counts since the last jog as one relative move
- interval: 100ms
then:
- lambda: |-
static const float steps[] = {0.01f, 0.1f, 1.0f};
if (id(axis) >= 0 && millis() - id(last_active) > ${autolock} * 1000) id(axis) = -1;
float delta = id(handwheel).state - id(wheel_sent);
if (delta == 0 || std::isnan(delta)) return;
id(wheel_sent) = id(handwheel).state;
if (id(axis) < 0) return; // locked: drop the counts
id(last_active) = millis();
float dist = delta * steps[id(step)];
// feed so the move takes ~100 ms, i.e. about one interval
// ponytail: capped feed lets fast spins queue moves that keep running after the wheel stops; drop excess counts if that bites
float feed = std::min(std::max(std::fabs(dist) * 600.0f, 60.0f), ${max_feed}.0f);
moonraker::client.gcode(str_sprintf("G91\nG1 %c%.3f F%.0f\nG90", "XYZ"[id(axis)], dist, feed));
sensor:
- platform: rotary_encoder
id: handwheel
pin_a:
number: 1
mode: INPUT_PULLUP
pin_b:
number: 2
mode: INPUT_PULLUP
resolution: 1 # calibration: counts per detent, flip pin_a/pin_b if direction is wrong
- platform: rotary_encoder
id: axis_encoder
pin_a:
number: 4
mode: INPUT_PULLUP
pin_b:
number: 5
mode: INPUT_PULLUP
on_clockwise:
- lambda: 'id(axis) = std::min(id(axis) + 1, 2); id(last_active) = millis();'
on_anticlockwise:
- lambda: 'id(axis) = std::max(id(axis) - 1, -1); id(last_active) = millis();'
- platform: rotary_encoder
id: step_encoder
pin_a:
number: 7
mode: INPUT_PULLUP
pin_b:
number: 8
mode: INPUT_PULLUP
on_clockwise:
- lambda: 'id(step) = std::min(id(step) + 1, 2); id(last_active) = millis();'
on_anticlockwise:
- lambda: 'id(step) = std::max(id(step) - 1, 0); id(last_active) = millis();'
binary_sensor:
- platform: gpio
id: stamp_button
name: Stamp Button
pin:
number: 0
inverted: true
# axis push: zero the selected axis in work coordinates (nothing while locked)
- platform: gpio
id: axis_button
name: Axis Button
pin:
number: 6
mode: INPUT_PULLUP
inverted: true
filters:
- delayed_on_off: 20ms
on_press:
- lambda: 'if (id(axis) >= 0) moonraker::client.gcode(str_sprintf("G92 %c0", "XYZ"[id(axis)]));'
- platform: gpio
id: step_button
name: Step Button
pin:
number: 9
mode: INPUT_PULLUP
inverted: true
filters:
- delayed_on_off: 20ms
# BT1: home all
- platform: gpio
id: bt1
name: BT1
pin:
number: 10
mode: INPUT_PULLUP
inverted: true
filters:
- delayed_on_off: 20ms
on_press:
- lambda: 'moonraker::client.gcode("G28");'
# BT2: pause / resume
- platform: gpio
id: bt2
name: BT2
pin:
number: 11
mode: INPUT_PULLUP
inverted: true
filters:
- delayed_on_off: 20ms
on_press:
- lambda: 'moonraker::client.post(moonraker::client.status().state == "paused" ? "/printer/print/resume" : "/printer/print/pause");'
# BT3: hold 1 s for emergency stop (Klipper needs FIRMWARE_RESTART afterwards)
- platform: gpio
id: bt3
name: BT3
pin:
number: 12
mode: INPUT_PULLUP
inverted: true
filters:
- delayed_on_off: 20ms
on_multi_click:
- timing:
- ON for at least 1s
then:
- lambda: 'moonraker::client.post("/printer/emergency_stop", "", true);'
font:
# Tiny5 Mono bitmap, 6x9 cell: axis letter + "-123.456" fits 64 px
- file: assets/fonts/Tiny5Mono.bdf
id: font_mono
spi:
clk_pin: 13
mosi_pin: 14
display:
- platform: st7920
id: lcd
cs_pin:
number: 15
inverted: true # ST7920 RS/CS is active high
data_rate: 1MHz # default 200kHz takes ~220 ms per frame; drop back if the picture garbles
width: 128
height: 64
rotation: 90 # mounted portrait, 270 if upside down
update_interval: 200ms
lambda: |-
static const char *steps[] = {"0.01", "0.1", "1"};
auto s = moonraker::client.status();
it.printf(0, 0, id(font_mono), "%s", s.state.c_str());
it.printf(0, 10, id(font_mono), "H:%s", s.homed.empty() ? "-" : s.homed.c_str());
for (int i = 0; i < 3; i++) {
int y = 21 + i * 11;
Color c = COLOR_ON;
if (i == id(axis)) {
it.filled_rectangle(0, y, 64, 10);
c = COLOR_OFF;
}
it.printf(1, y + 1, id(font_mono), c, "%c", "XYZ"[i]);
it.printf(63, y + 1, id(font_mono), c, TextAlign::TOP_RIGHT, "%.3f", s.pos[i]);
}
it.printf(0, 118, id(font_mono), "%s mm", steps[id(step)]);
// corner: seconds until the handwheel locks, LCK once it has
if (id(axis) < 0) {
it.print(63, 118, id(font_mono), TextAlign::TOP_RIGHT, "LCK");
} else {
int left = ${autolock} - (int) ((millis() - id(last_active)) / 1000);
it.printf(63, 118, id(font_mono), TextAlign::TOP_RIGHT, "%d", std::max(left, 0));
}
+10 -8
View File
@@ -1,4 +1,11 @@
--- ---
# Hardware: Xiaomi Mi Desk Lamp, brain transplant: M5Stack M5Stamp Pico (originally ESP8266)
# Pinout:
# GPIO18 Warm White (GPIO_PWM2) -> warm_white (output ledc)
# GPIO19 Cold White (GPIO_PWM1) -> cold_white (output ledc)
# GPIO21 Rotary switch A pin (GPIO_ROT_A) -> rotary (sensor rotary_encoder pin_a)
# GPIO26 Rotary switch B pin (GPIO_ROT_B) -> rotary (sensor rotary_encoder pin_b)
# GPIO36 Button (GPIO_KEY1) -> rotary_button (binary_sensor gpio) (inverted)
substitutions: substitutions:
device: desk-lamp device: desk-lamp
name: Desk Lamp name: Desk Lamp
@@ -15,18 +22,13 @@ esp32:
variant: esp32 variant: esp32
toolchain: esp-idf toolchain: esp-idf
framework: framework:
advanced:
flash_chip: gd
type: esp-idf type: esp-idf
packages: packages:
common: !include common/common.yaml common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
# Mi Desk Lamp
# Pin Function (Name)
# GPIO18: Warm White (GPIO_PWM2)
# GPIO19: Cold White (GPIO_PWM1)
# GPIO21: Rotary switch A pin (GPIO_ROT_A)
# GPIO26: Rotary switch B pin (GPIO_ROT_B)
# GPIO36: Button (GPIO_KEY1)
binary_sensor: binary_sensor:
+19 -2
View File
@@ -1,4 +1,14 @@
--- ---
# Hardware: M5Stack ATOM Echo
# Pinout:
# GPIO19 -> speaker_bus (i2s_audio i2s_bclk_pin)
# GPIO22 -> speaker_id (speaker i2s_audio i2s_dout_pin)
# GPIO23 -> echo_microphone (microphone i2s_audio i2s_din_pin)
# GPIO26 Grove SDA
# GPIO27 ATOM RGB LED -> LED [neo_buildin] (light esp32_rmt_led_strip), also status
# GPIO32 Grove SCL
# GPIO33 -> speaker_bus (i2s_audio i2s_lrclk_pin)
# GPIO39 -> Button (binary_sensor gpio) (inverted)
substitutions: substitutions:
device: echo-1 device: echo-1
name: Echo 1 name: Echo 1
@@ -15,10 +25,17 @@ esphome:
esp32: esp32:
variant: esp32 variant: esp32
framework: framework:
advanced:
flash_chip: gd
type: esp-idf type: esp-idf
packages: packages:
common: !include common/common.yaml common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
status_led: !include
file: common/status_led.yaml
vars:
light_id: neo_buildin
api: api:
actions: actions:
@@ -131,10 +148,10 @@ media_player:
buffer_size: 14000 buffer_size: 14000
media_pipeline: media_pipeline:
speaker: media_spk_resampling_input speaker: media_spk_resampling_input
format: NONE format: WAV # no PSRAM: HA transcodes to WAV, decoding MP3/FLAC here runs the heap out
announcement_pipeline: announcement_pipeline:
speaker: announcement_spk_resampling_input speaker: announcement_spk_resampling_input
format: NONE format: WAV # no PSRAM: HA transcodes to WAV, decoding MP3/FLAC here runs the heap out
rtttl: rtttl:
id: my_rtttl id: my_rtttl
+22 -11
View File
@@ -1,4 +1,16 @@
--- ---
# Hardware: Xiaomi Mijia Gateway, brain transplant: M5Stack ATOM Echo (kept the speaker, LEDs and PSU)
# Pinout:
# GPIO12 -> Button (binary_sensor gpio) (inverted)
# GPIO19 -> speaker_bus (i2s_audio i2s_bclk_pin)
# GPIO21 Gateway LED ring red -> led_red (output ledc)
# GPIO22 -> speaker_id (speaker i2s_audio i2s_dout_pin)
# GPIO23 Gateway LED ring blue -> led_blue (output ledc)
# GPIO25 Gateway LED ring green -> led_green (output ledc)
# GPIO26 Grove SDA -> i2c (i2c sda)
# GPIO27 ATOM onboard RGB LED (inside, not visible)
# GPIO32 Grove SCL -> i2c (i2c scl)
# GPIO33 -> speaker_bus (i2s_audio i2s_lrclk_pin)
substitutions: substitutions:
device: echo device: echo
name: Echo name: Echo
@@ -16,10 +28,17 @@ esp32:
variant: esp32 variant: esp32
toolchain: esp-idf toolchain: esp-idf
framework: framework:
advanced:
flash_chip: gd
type: esp-idf type: esp-idf
packages: packages:
common: !include common/common.yaml common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
status_led: !include
file: common/status_led.yaml
vars:
light_id: led_light
api: api:
actions: actions:
@@ -71,11 +90,6 @@ light:
red: led_red red: led_red
green: led_green green: led_green
blue: led_blue blue: led_blue
- platform: status_led
id: led_status
pin:
number: 23
allow_other_uses: true
output: output:
- platform: ledc - platform: ledc
@@ -86,9 +100,7 @@ output:
pin: 25 pin: 25
- platform: ledc - platform: ledc
id: led_blue id: led_blue
pin: pin: 23
number: 23
allow_other_uses: true
i2s_audio: i2s_audio:
- id: speaker_bus - id: speaker_bus
@@ -127,16 +139,15 @@ media_player:
- platform: speaker - platform: speaker
id: media_out id: media_out
name: Player name: Player
codec_support_enabled: false
buffer_size: 14000 buffer_size: 14000
media_pipeline: media_pipeline:
speaker: media_spk_resampling_input speaker: media_spk_resampling_input
# format: WAV format: WAV # only the WAV decoder is built (was codec_support_enabled: false)
# num_channels: 1 # num_channels: 1
# sample_rate: 8000 # Lower sample rate # sample_rate: 8000 # Lower sample rate
announcement_pipeline: announcement_pipeline:
speaker: announcement_spk_resampling_input speaker: announcement_spk_resampling_input
# format: WAV format: WAV
# num_channels: 1 # num_channels: 1
# sample_rate: 8000 # Lower sample rate # sample_rate: 8000 # Lower sample rate
on_play: on_play:
+172 -243
View File
@@ -1,4 +1,16 @@
--- ---
# Hardware: M5Stack M5Stamp C3, GNSS test bench with two receivers
# Pinout:
# GPIO0 Grove A pin 4, UART TX -> uart_m10 (uart tx_pin)
# GPIO1 Grove A pin 3, UART RX -> uart_m10 (uart rx_pin)
# GPIO18 Grove B pin 4 (USB D-), UART TX -> uart_at6668 (uart tx_pin)
# GPIO19 Grove B pin 3 (USB D+), UART RX -> uart_at6668 (uart rx_pin)
# GPIO20 UART0 RX (on-board USB to UART), unused: logger is API only
# GPIO21 UART0 TX (on-board USB to UART), unused: logger is API only
# Grove pin order: GND, 5V, signal, signal
# Receivers:
# Grove A XYZ GNSS YM-250, u-blox M10 (ROM SPG 5.10, PROTVER 34.10), 38400 baud -> gnss_m10 (ubx)
# Grove B M5Stack Cap LoRa-1262 GNSS, AT6668 (CASIC), 115200 baud -> gnss_at6668 (casic)
substitutions: substitutions:
device: eworkbench device: eworkbench
name: Electronics Workbench name: Electronics Workbench
@@ -18,259 +30,176 @@ esp32:
toolchain: esp-idf toolchain: esp-idf
framework: framework:
type: esp-idf type: esp-idf
advanced:
flash_chip: generic
packages: packages:
common: !include common/common.yaml common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
# GPIO20 UART RX, LOGGER external_components:
# GPIO21 UART TX, LOGGER # geolocation hub + nmea, ubx and casic platforms: esphome/esphome#23301 (stacked on #23293) + casic, not upstream yet
# GPIO9 GPIO - source: github://randybb/esphome@geolocation-casic
# components: [geolocation, nmea, ubx, casic]
# GPIO0 I2C SCL
# GPIO1 I2C SDA
# GPIO2 RGB
# GPIO1 BUTTON
# GPIO4 GPIO
# GPIO5 GPIO
# GPIO6 GPIO
# GPIO7 GPIO
# GPIO8 GPIO
# GPIO10 GPIO
# GPIO18 UART RX
# GPIO19 UART TX
i2c: logger:
- id: i2c_grove # The C3 has two UARTs and both receivers need one; logs go over the API only
sda: 1 baud_rate: 0
scl: 0
scan: true
# - id: i2c_grove_2
# sda: 19
# scl: 18
# scan: true
uart: uart:
- id: uart_log - id: uart_m10
rx_pin: 20 rx_pin: 1
tx_pin: 21 tx_pin: 0
baud_rate: 38400
# Test aid: decode the answers to the polls in interval below
debug:
direction: RX
after:
bytes: 1024
timeout: 50ms
sequence:
- lambda: |-
for (size_t i = 0; i + 8 <= bytes.size(); i++) {
if (bytes[i] != 0xB5 || bytes[i + 1] != 0x62)
continue;
const uint8_t cls = bytes[i + 2], id = bytes[i + 3];
const size_t len = bytes[i + 4] | (bytes[i + 5] << 8);
if (i + 6 + len > bytes.size())
break;
const uint8_t *p = bytes.data() + i + 6;
if (cls == 0x0A && id == 0x28 && len >= 8) {
ESP_LOGI("ubxdbg", "MON-GNSS supported 0x%02X default 0x%02X enabled 0x%02X (bit0 GPS 1 GLO 2 BDS 3 GAL), max %u at once",
p[1], p[2], p[3], p[4]);
} else if (cls == 0x01 && id == 0x35 && len >= 8) {
static const char *const NAMES[] = {"GPS", "SBAS", "GAL", "BDS", "IMES", "QZSS", "GLO", "NAVIC"};
int tracked[8] = {0}, used[8] = {0}, sbas_corr = 0;
std::string sbas;
const uint8_t num = p[5];
for (uint8_t k = 0; k < num && 8 + 12 * (k + 1) <= len; k++) {
const uint8_t *b = p + 8 + 12 * k;
const uint32_t flags = b[8] | (b[9] << 8) | (b[10] << 16) | ((uint32_t) b[11] << 24);
const uint8_t g = b[0] & 7;
if (b[2] > 0)
tracked[g]++;
if (flags & (1u << 3))
used[g]++;
if (flags & (1u << 16))
sbas_corr++;
if (b[0] == 1 && b[2] > 0) {
char buf[16];
snprintf(buf, sizeof(buf), " %u:%u", b[1], b[2]);
sbas += buf;
}
}
std::string summary;
for (int g = 0; g < 8; g++) {
if (tracked[g] == 0)
continue;
char buf[24];
snprintf(buf, sizeof(buf), " %s %d/%d", NAMES[g], used[g], tracked[g]);
summary += buf;
}
ESP_LOGI("ubxdbg", "NAV-SAT used/tracked:%s; SBAS-corrected %d; SBAS PRN:cno%s", summary.c_str(), sbas_corr,
sbas.c_str());
}
i += 5 + len;
}
- id: uart_at6668
rx_pin: 19
tx_pin: 18
baud_rate: 115200 baud_rate: 115200
- id: uart_hdmi_switch
rx_pin: 18
tx_pin: 19
baud_rate: 9600
pcf8574: geolocation:
- id: 'pcf8574_hub' - platform: ubx
address: 0x20 id: gnss_m10
pcf8575: true uart_id: uart_m10
update_interval: 10s
- platform: casic
id: gnss_at6668
uart_id: uart_at6668
update_interval: 10s
switch: sensor:
- platform: gpio - platform: geolocation
name: "PCF8574 Pin #0" geolocation_id: gnss_m10
pin: type: latitude
pcf8574: pcf8574_hub name: M10 Latitude
number: 0 - platform: geolocation
# One of INPUT or OUTPUT geolocation_id: gnss_m10
mode: type: longitude
output: true name: M10 Longitude
inverted: false - platform: geolocation
- platform: gpio geolocation_id: gnss_m10
name: "PCF8574 Pin #1" type: altitude
pin: name: M10 Altitude
pcf8574: pcf8574_hub - platform: geolocation
number: 1 geolocation_id: gnss_m10
# One of INPUT or OUTPUT type: speed
mode: name: M10 Speed
output: true - platform: geolocation
inverted: false geolocation_id: gnss_m10
- platform: gpio type: course
name: "PCF8574 Pin #7" name: M10 Course
pin: - platform: geolocation
pcf8574: pcf8574_hub geolocation_id: gnss_m10
number: 7 type: satellites
# One of INPUT or OUTPUT name: M10 Satellites
mode: - platform: geolocation
output: true geolocation_id: gnss_m10
inverted: false type: hdop
name: M10 HDOP
binary_sensor: - platform: geolocation
- platform: gpio geolocation_id: gnss_m10
name: "PCF8574 Pin #10" type: horizontal_accuracy
pin: name: M10 Horizontal Accuracy
pcf8574: pcf8574_hub - platform: geolocation
number: 8 geolocation_id: gnss_m10
# One of INPUT or OUTPUT type: vertical_accuracy
mode: INPUT name: M10 Vertical Accuracy
inverted: false - platform: geolocation
- platform: gpio geolocation_id: gnss_at6668
name: "PCF8574 Pin #11" type: latitude
pin: name: AT6668 Latitude
pcf8574: pcf8574_hub - platform: geolocation
number: 9 geolocation_id: gnss_at6668
# One of INPUT or OUTPUT type: longitude
mode: INPUT name: AT6668 Longitude
inverted: false - platform: geolocation
- platform: gpio geolocation_id: gnss_at6668
name: "PCF8574 Pin #12" type: altitude
pin: name: AT6668 Altitude
pcf8574: pcf8574_hub - platform: geolocation
number: 10 geolocation_id: gnss_at6668
# One of INPUT or OUTPUT type: speed
mode: INPUT name: AT6668 Speed
inverted: false - platform: geolocation
- platform: gpio geolocation_id: gnss_at6668
name: "PCF8574 Pin #13" type: course
pin: name: AT6668 Course
pcf8574: pcf8574_hub - platform: geolocation
number: 11 geolocation_id: gnss_at6668
# One of INPUT or OUTPUT type: satellites
mode: INPUT name: AT6668 Satellites
inverted: false - platform: geolocation
- platform: gpio geolocation_id: gnss_at6668
name: "PCF8574 Pin #14" type: hdop
pin: name: AT6668 HDOP
pcf8574: pcf8574_hub
number: 12
# One of INPUT or OUTPUT
mode: INPUT
inverted: false
- platform: gpio
name: "PCF8574 Pin #15"
pin:
pcf8574: pcf8574_hub
number: 13
# One of INPUT or OUTPUT
mode: INPUT
inverted: false
- platform: gpio
name: "PCF8574 Pin #16"
pin:
pcf8574: pcf8574_hub
number: 14
# One of INPUT or OUTPUT
mode: INPUT
inverted: false
- platform: gpio
name: "PCF8574 Pin #17"
pin:
pcf8574: pcf8574_hub
number: 15
# One of INPUT or OUTPUT
mode: INPUT
inverted: false
# binary_sensor:
# - platform: gpio
# id: rotary_encoder_button
# pin:
# number: 6
# # mode: INPUT_PULLUP
# inverted: true
# filters:
# - delayed_on: 30ms
# - delayed_off: 30ms
# on_press:
# - display_menu.enter:
# display:
# - platform: lcd_pcf8574
# id: my_lcd
# i2c_id: i2c_grove
# dimensions: 20x4
# address: 0x27
# user_characters:
# - position: 0
# data: # mark_back symbol
# - 0b00100
# - 0b01000
# - 0b11110
# - 0b01001
# - 0b00101
# - 0b00001
# - 0b11110
# - 0b00000
# lambda: |-
# id(my_lcd_menu).draw();
# if (!id(my_lcd_menu).is_active())
# it.print("Menu is not active");
# lcd_menu:
# id: my_lcd_menu
# display_id: my_lcd
# active: true
# mode: rotary
# mark_back: 0x08
# mark_selected: 0x3e
# mark_editing: 0x2a
# mark_submenu: 0x7e
# items:
# - type: back
# text: 'Back'
# - type: label
# text: 'Label 1'
# - type: label
# text: !lambda |-
# return "Templated label";
# select:
# - platform: template
# id: hdmi_switch
# optimistic: true
# options:
# - PC1
# - PC2
# - PC3
# - PC4
# initial_option: PC1
# # set_action:
# # - logger.log:
# # format: "Chosen option: %s (index %d)"
# # args: ["x.c_str()", "i"]
# # - uart.write:
# # id: uart_hdmi_switch
# # data: [0x47, 0x30, 0x31, 0x67, 0x41, 0x00]
# sensor:
# - platform: rotary_encoder
# id: rotary_encoder_sensor
# pin_a: 4
# pin_b: 5
# filters:
# debounce: 30ms
# on_anticlockwise:
# - display_menu.up:
# on_clockwise:
# - display_menu.down:
time: time:
- platform: homeassistant - platform: geolocation
id: ha_time id: gnss_time
timezone: Europe/Bratislava geolocation_id: gnss_m10
on_time_sync:
- logger.log: GNSS time synced
# display: interval:
# - platform: tm1637 # Test aid: constellations and satellites of the M10
# id: tm1637_display - interval: 60s
# clk_pin: 4 then:
# dio_pin: 5 - uart.write:
# update_interval: 500ms id: uart_m10
# # intensity: 0 data: [0xB5, 0x62, 0x0A, 0x28, 0x00, 0x00, 0x32, 0xA0]
# lambda: |- - delay: 2s
# static int i = 0; - uart.write:
# i++; id: uart_m10
# if (id(alarm_id)) { data: [0xB5, 0x62, 0x01, 0x35, 0x00, 0x00, 0x36, 0xA3]
# if ((i % 2) == 0)
# it.print("8 8 ");
# else
# it.print(" 8 8");
# } else {
# if (((i / 10) % 2) == 0) {
# //it.set_intensity(7);
# if ((i % 2) == 0)
# it.strftime("%H.%M", id(ha_time).now());
# else
# it.strftime("%H%M", id(ha_time).now());
# } else {
# //it.set_intensity(1);
# it.printf("%.0f~C", id(temperature).state);
# }
# }
+30 -68
View File
@@ -1,4 +1,22 @@
--- ---
# Hardware: M5Stack ATOM Lite + ATOM Hub Switch
# Pinout:
# GPIO1 UART0 TX
# GPIO3 UART0 RX
# GPIO12 IR
# GPIO19 Relay2
# GPIO21 I2C1 SCL -> i2c (i2c scl)
# GPIO22 Relay1
# GPIO23 RS485 Tx
# GPIO25 I2C1 SDA - red -> i2c (i2c sda)
# GPIO26 I2C0 SDA - white
# GPIO27 NEO 1x -> atom_led (status LED, common/status_led_atom.yaml)
# GPIO32 I2C0 SCL
# GPIO33 RS485 Rx
# GPIO39 BUTTON -> Status Button (binary_sensor gpio)
# I2C:
# 0x18 one_wire_bus (one_wire ds2482)
# 0x27 pca9554_module (pca9554)
substitutions: substitutions:
device: fireplace device: fireplace
name: Heating Fireplace name: Heating Fireplace
@@ -15,76 +33,30 @@ esp32:
variant: esp32 variant: esp32
toolchain: esp-idf toolchain: esp-idf
framework: framework:
advanced:
flash_chip: gd
type: esp-idf type: esp-idf
external_components:
# - source: github://pr#12717
# components: [ds248x]
# refresh: 1h
- source: github://pr#13534
components: [ds2482, ds2484, ds248x_base]
refresh: 1h
packages: packages:
common: !include common/common.yaml common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
status_led: !include common/status_led_atom.yaml
# PINOUTS: M5ATOM+Atom Hub Switch
# IR G12
# NEO G27 1x
# BUTTON G39
# I2C0 SDA G26 - white
# I2C0 SCL G32
# I2C1 SDA G25 - red
# I2C1 SCL G21
# UART0 RX G3
# UART0 TX G1
# RS485 Rx G33
# RS485 Tx G23
# Relay1 G22
# Relay2 G19
time:
- platform: homeassistant
id: ha_time
timezone: Europe/Bratislava
i2c: i2c:
# - id: i2c0
# sda: 26
# scl: 32
# scan: true #false
# - id: i2c1
sda: 25 sda: 25
scl: 21 scl: 21
scan: true #false scan: true #false
# ds248x: ds248x:
# # i2c_id: i2c_main id: ds2484_module
# address: 0x18 # should be the default type: ds2482-100
# # sleep_pin: 32 # remove if not needed, if set the ds248x sleeps when no transaction is in progress address: 0x18
# active_pullup: true # adds a active pullup which should improve signal integrity active_pullup: true
# strong_pullup: false # enables a strong pullup used to provide the needed current for temperature reading without vcc connected
# bus_sleep: true # power down the bus when no transaction is in progres
# one_wire:
# id: one_wire_bus
# platform: ds2484
# active_pullup: true
# ds248x:
# id: ds2484_module
# address: 0x18
# one_wire:
# - platform: ds248x
# ds248x_id: ds2484_module
# id: one_wire_bus
one_wire: one_wire:
id: one_wire_bus - platform: ds248x
platform: ds2482 ds248x_id: ds2484_module
active_pullup: true id: one_wire_bus
pca9554: pca9554:
- id: pca9554_module - id: pca9554_module
@@ -131,16 +103,6 @@ sensor:
# index: 0 # index: 0
name: Temperature name: Temperature
id: 'heating_fireplace_temperature' id: 'heating_fireplace_temperature'
# - platform: dht
# pin: 14
# temperature:
# name: "Kitchen Temperature"
# id: 'kitchen_temperature'
# humidity:
# name: "Kitchen Humidity"
# id: 'kitchen_humidity'
# update_interval: 60s
# model: si7021
bluetooth_proxy: bluetooth_proxy:
active: true active: true
+19 -15
View File
@@ -1,4 +1,19 @@
--- ---
# Hardware: M5Stack ATOM Lite + ATOM Hub Switch
# Pinout:
# GPIO1 UART0 TX
# GPIO3 UART0 RX
# GPIO12 IR
# GPIO19 RELAY-2 -> relay_2 (output gpio)
# GPIO21 I2C1 SCL
# GPIO22 RELAY-1 -> relay_1 (output gpio)
# GPIO23 RS485 TX
# GPIO25 I2C1 SDA red
# GPIO26 I2C0 SDA white
# GPIO27 NEO -> atom_led (status LED, common/status_led_atom.yaml)
# GPIO32 I2C0 SCL -> gate_ogi_state (binary_sensor gpio) (inverted); gate_ogi_blink (binary_sensor gpio) (inverted)
# GPIO33 RS485 RX
# GPIO39 BUTTON
substitutions: substitutions:
device: gate device: gate
name: Gate name: Gate
@@ -15,25 +30,14 @@ esp32:
variant: esp32 variant: esp32
toolchain: esp-idf toolchain: esp-idf
framework: framework:
advanced:
flash_chip: gd
type: esp-idf type: esp-idf
packages: packages:
common: !include common/common.yaml common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
# PINOUTS: M5ATOM status_led: !include common/status_led_atom.yaml
# IR G12
# NEO G27
# BUTTON G39
# I2C0 SDA G26 white
# I2C0 SCL G32
# I2C1 SDA G25 red
# I2C1 SCL G21
# UART0 RX G3
# UART0 TX G1
# RS485 RX G33
# RS485 TX G23
# RELAY-1 G22
# RELAY-2 G19
button: button:
- platform: output - platform: output
+29 -16
View File
@@ -1,4 +1,31 @@
--- ---
# Hardware: Olimex ESP32-POE-ISO
# Pinout:
# # UEXT
# 3V3 1 2 GND
# GPIO4 3 4 GPIO36 U1TXD/U1RXD
# GPIO16 5 6 GPIO13 I2C-SCL/I2C-SDA
# GPIO15 7 8 GPIO2 HS2_CMD/HS2_DATA0
# GPIO14 9 10 GPIO5 HS2_CLK/SPI_CS
#
# SD/MMC; shared with UEXT, no CS!!!
# GPIO15 HS2_CMD
# GPIO14 HS2_CLK
# GPIO2 HS2_DATA0
#
# GPIO34 BUT1
# GPIO35 Battery Measurment ADC
# GPIO39 Ext Power Sense ADC
# Used:
# GPIO4 uart_modbus (uart tx_pin)
# GPIO12 ethernet (ethernet power_pin)
# GPIO13 i2c (i2c sda)
# GPIO16 i2c (i2c scl)
# GPIO17 ethernet (ethernet)
# GPIO18 ethernet (ethernet mdio_pin)
# GPIO23 ethernet (ethernet mdc_pin)
# GPIO34 user_button (binary_sensor gpio) (inverted)
# GPIO36 uart_modbus (uart rx_pin)
substitutions: substitutions:
device: gateway device: gateway
name: Gateway name: Gateway
@@ -17,6 +44,7 @@ esp32:
framework: framework:
type: esp-idf type: esp-idf
advanced: advanced:
flash_chip: generic
minimum_chip_revision: 3.0 minimum_chip_revision: 3.0
sram1_as_iram: true sram1_as_iram: true
@@ -32,22 +60,7 @@ external_components:
packages: packages:
# common: !include common/common.yaml # common: !include common/common.yaml
common_eth: !include common/common_eth.yaml common_eth: !include common/common_eth.yaml
ipv6_only: !include common/ipv6_only_eth.yaml
## UEXT
# 3V3 1 2 GND
# GPIO4 3 4 GPIO36 U1TXD/U1RXD
# GPIO16 5 6 GPIO13 I2C-SCL/I2C-SDA
# GPIO15 7 8 GPIO2 HS2_CMD/HS2_DATA0
# GPIO14 9 10 GPIO5 HS2_CLK/SPI_CS
#
# SD/MMC; shared with UEXT, no CS!!!
# GPIO15 HS2_CMD
# GPIO14 HS2_CLK
# GPIO2 HS2_DATA0
# GPIO34 BUT1
# GPIO35 Battery Measurment ADC
# GPIO39 Ext Power Sense ADC
i2c: i2c:
sda: 13 sda: 13
+34 -56
View File
@@ -1,4 +1,22 @@
--- ---
# Hardware: M5Stack ATOM Lite + ATOM Hub Switch
# Pinout:
# GPIO1 UART0 TX
# GPIO3 UART0 RX
# GPIO12 IR
# GPIO19 NC -> Demand [heating_demand] (switch gpio)
# GPIO21 I2C1 SCL -> i2c (i2c scl)
# GPIO22 1-WIRE -> Demand [hot_water_demand] (switch gpio)
# GPIO23 UART1 RX -> uart_modbus (uart rx_pin)
# GPIO25 I2C1 SDA -> i2c (i2c sda)
# GPIO26 I2C0 SDA
# GPIO27 NEO -> atom_led (status LED, common/status_led_atom.yaml)
# GPIO32 I2C0 SCL
# GPIO33 UART1 TX -> uart_modbus (uart tx_pin)
# GPIO39 BUTTON
# I2C:
# 0x18 one_wire_bus (one_wire ds2482)
# 0x27 pca9554_module (pca9554)
substitutions: substitutions:
device: heater device: heater
name: Heater name: Heater
@@ -17,48 +35,24 @@ esphome:
- id: heating - id: heating
name: Heating name: Heating
area_id: local_area area_id: local_area
relation: child
- id: hot_water - id: hot_water
name: Hot Water name: Hot Water
area_id: local_area area_id: local_area
relation: child
esp32: esp32:
variant: esp32 variant: esp32
toolchain: esp-idf toolchain: esp-idf
framework: framework:
advanced:
flash_chip: gd
type: esp-idf type: esp-idf
external_components:
# - source: github://pr#12717
# components: [ds248x]
# refresh: 1h
- source: github://pr#13534
components: [ds2482, ds2484, ds248x_base]
refresh: 1h
packages: packages:
common: !include common/common.yaml common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
# PINOUTS: M5ATOM status_led: !include common/status_led_atom.yaml
# IR G12
# NEO G27
# BUTTON G39
# I2C0 SDA G26
# I2C0 SCL G32
# I2C1 SDA G25
# I2C1 SCL G21
# UART0 RX G3
# UART0 TX G1
# UART1 RX G23
# UART1 TX G33
# 1-WIRE G22
# NC G19
#logger:
# level: VERBOSE
# logs:
# dallas.component: ERROR
# uart.component: ERROR
# i2c.component: VERBOSE
# Heating / Hot water Controller # Heating / Hot water Controller
# temp_1: Solar Collector # temp_1: Solar Collector
@@ -129,9 +123,7 @@ globals:
initial_value: '20.5' initial_value: '20.5'
time: time:
- platform: homeassistant - id: !extend ha_time
id: ha_time
timezone: Europe/Bratislava
on_time: on_time:
- seconds: 0 - seconds: 0
minutes: /1 minutes: /1
@@ -165,36 +157,22 @@ climate:
default_target_temperature_high: 40 °C default_target_temperature_high: 40 °C
i2c: i2c:
# - id: i2c0
# sda: 26
# scl: 32
# scan: true #false
# - id: i2c1
sda: 25 sda: 25
scl: 21 scl: 21
scan: true #false scan: true #false
# one_wire:
# id: one_wire_bus
# # i2c_id: i2c_main
# platform: ds2484
# active_pullup: true
# ds248x: ds248x:
# id: ds2484_module id: ds2482_module
# address: 0x18 type: ds2482-100
# active_pullup: true address: 0x18
active_pullup: true
# one_wire:
# - platform: ds248x
# ds248x_id: ds2484_module
# id: one_wire_bus
one_wire: one_wire:
id: one_wire_bus - platform: ds248x
# i2c_id: i2c_main ds248x_id: ds2482_module
platform: ds2482 id: one_wire_bus
active_pullup: true
modbus: modbus:
uart_id: uart_modbus uart_id: uart_modbus
+206
View File
@@ -0,0 +1,206 @@
---
# Hardware: Seeed Studio XIAO ESP32-C5 (host, its own radio in 802.11p for ITS-G5)
# + Seeed Studio XIAO ESP32-C6 (esp32_hosted co-processor, Wi-Fi uplink over SPI)
# Wi-Fi on the C6 needs esphome/esphome#22819 and hn/esphome-its-g5#3 (external components below)
# and the co-processor firmware from hosted/xiao-c6-spi on the C6.
# Pinout:
# GPIO8 D8 -> esp32_hosted clk -> C6 D8 GPIO19
# GPIO9 D9 <- esp32_hosted miso <- C6 D9 GPIO20
# GPIO10 D10 -> esp32_hosted mosi -> C6 D10 GPIO18
# GPIO7 D3 -> esp32_hosted cs -> C6 D3 GPIO21
# GPIO1 D0 <- esp32_hosted handshake <- C6 D0 GPIO0
# GPIO0 D1 <- esp32_hosted data_ready <- C6 D1 GPIO1
# GPIO25 D2 -> esp32_hosted reset -> C6 D2 GPIO2 (CP firmware restarts itself on LOW)
# GND, 3V3 shared
substitutions:
device: its-g5
name: ITS-G5
area: DEV
comment: ITS-G5 receiver
# OpenTrafficMap node ID (MQTT topics its/<node_id>/...): the reference firmware uses the MAC as
# lowercase hex; replace it if opentrafficmap assigned a name (e.g. "node789")
node_id: "3844bebe8638"
esphome:
name: mcu-${device}
friendly_name: ${name}
area: ${area}
comment: ${comment}
includes:
- common/its_g5/decode.h # its_g5_decode:: header decoding for the lambdas below
esp32:
board: seeed_xiao_esp32c5
framework:
type: esp-idf
packages:
common: !include common/common.yaml
# ipv6_only off: eppp_link (pulled in by esp_wifi_remote) needs IPv4, fix belongs in esp-protocols
# ipv6_only: !include common/ipv6_only.yaml
# IPv4 only: the car hotspot (O2 SK) has no IPv6, but MQTT prefers the broker's AAAA record whenever
# IPv6 is enabled, even with only a link-local address, and never falls back to IPv4
network:
enable_ipv6: false
# MQTT only: HA can't reach the API on the car hotspot, and both would duplicate the entities
api: !remove
time: !remove # homeassistant time needs the API
ota:
- id: !extend ota_esphome
encryption:
key: !secret api_key # was inherited from api
external_components:
# Wi-Fi on the esp32_hosted co-processor of a host with its own radio
- source: github://pr#22819
components: [wifi]
# its_g5_receiver allowing wifi on the co-processor
- source: github://hn/esphome-its-g5@pull/3/head
components: [its_g5_receiver]
refresh: 1d
esp32_hosted:
type: spi
variant: ESP32C6
clk_pin: GPIO8
miso_pin: GPIO9
mosi_pin: GPIO10
cs_pin: GPIO7
handshake_pin: GPIO1
data_ready_pin: GPIO0
reset_pin: GPIO25
wifi:
use_coprocessor: true # Wi-Fi on the C6, the C5 radio is for 802.11p
# car: ESP joins the tablet's hotspot as a client
min_auth_mode: WPA2
networks:
- id: !remove wifi_iot
- ssid: !secret wifi_ssid_0
password: !secret wifi_password_0
# Raw 802.11 frames as UDP broadcasts; in Wireshark use the "UDP Listener"
# (udpdump) interface on port 18511 with payload "wlan".
udp:
id: its_udp
# Own broker as on the tracker: HA sees the entities (API is unreachable on the car hotspot), and an
# EMQX bridge forwards its/${node_id}/# to cits1.opentrafficmap.org:8883 (as hn's its-g5-opentrafficmap.yaml)
mqtt:
id: mqtt_client
broker: !secret mqtt_ext
# Own user, so the broker ACL can limit it to its own topics
username: !secret mqtt_its_g5_username
password: !secret mqtt_its_g5_password
discovery: true
# MAC in the unique_id: the default ESP<type><object_id> clashes with the tracker's common entities
discovery_unique_id_generator: mac
log_topic: null
birth_message:
topic: its/${node_id}/status
payload: online
retain: true
will_message:
topic: its/${node_id}/status
payload: offline
retain: true
on_connect:
- delay: 3s
- lambda: |-
uint8_t mac[6];
get_mac_address_raw(mac);
char info[160];
int n = snprintf(info, sizeof(info),
"{\"emac\":\"%02x:%02x:%02x:%02x:%02x:%02x\",\"ver\":\"%s\",\"hwv\":\"esphome\"}",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], ESPHOME_VERSION);
id(mqtt_client).publish("its/${node_id}/info", info, n, 0, false);
interval:
- interval: 60s
then:
- lambda: |-
char stats[48];
int n = snprintf(stats, sizeof(stats), "{\"rbt\":%llu}", millis_64() / 1000ULL);
id(mqtt_client).publish("its/${node_id}/stats", stats, n, 0, false);
its_g5_receiver:
id: g5
channel: 5900 # G5CC
broadcast_only: true
on_packet:
- lambda: |-
id(mqtt_client).publish("its/${node_id}/packet", (const char *) x.data(), x.size(), 0, false);
- udp.write:
id: its_udp
data: !lambda return x;
- lambda: |-
if (!its_g5_decode::handle(x))
return;
const auto &i = its_g5_decode::stats.last;
ESP_LOGD("its_g5", "%s from %s %.6f,%.6f %.0f km/h %.0f deg%s, rssi %.0f dBm",
its_g5_decode::port_name(i.port), its_g5_decode::station_name(i.station_type),
i.lat, i.lon, i.speed_kmh, i.heading, i.secured ? ", signed" : "", rssi);
// Decoded header for HA/maptool, 1 Hz per station (CAMs come up to 10 Hz per vehicle)
if (!its_g5_decode::due(i.addr, millis(), 1000))
return;
char json[192];
int n = snprintf(json, sizeof(json),
"{\"msg\":\"%s\",\"station\":\"%s\",\"id\":\"%016llx\",\"lat\":%.7f,\"lon\":%.7f,"
"\"speed\":%.1f,\"heading\":%.1f,\"secured\":%s,\"rssi\":%.0f}",
its_g5_decode::port_name(i.port), its_g5_decode::station_name(i.station_type),
(unsigned long long) i.addr, i.lat, i.lon, i.speed_kmh, i.heading,
i.secured ? "true" : "false", rssi);
// outside its/${node_id}/#, so the EMQX bridge keeps it off OpenTrafficMap
id(mqtt_client).publish("mcu-${device}/decoded", json, n, 0, false);
sensor:
- platform: its_g5_receiver
its_g5_receiver_id: g5
bytes_received:
name: Bytes Received
packets_received:
name: Packets Received
packets_dropped:
name: Packets Dropped
- platform: template
name: CAM Received
state_class: total_increasing
accuracy_decimals: 0
lambda: return its_g5_decode::stats.cam;
- platform: template
name: DENM Received
state_class: total_increasing
accuracy_decimals: 0
lambda: return its_g5_decode::stats.denm;
- platform: template
name: SPATEM Received
state_class: total_increasing
accuracy_decimals: 0
lambda: return its_g5_decode::stats.spatem;
- platform: template
name: MAPEM Received
state_class: total_increasing
accuracy_decimals: 0
lambda: return its_g5_decode::stats.mapem;
binary_sensor:
- platform: template
name: MQTT Connected
device_class: connectivity
entity_category: diagnostic
lambda: return id(mqtt_client).is_connected();
text_sensor:
- platform: template
name: Last Station
update_interval: 10s
lambda: |-
const auto &i = its_g5_decode::stats.last;
if (i.lat == 0 && i.lon == 0)
return {};
char buf[96];
snprintf(buf, sizeof(buf), "%s %s %.6f,%.6f %.0f km/h %.0f°", its_g5_decode::port_name(i.port),
its_g5_decode::station_name(i.station_type), i.lat, i.lon, i.speed_kmh, i.heading);
return std::string(buf);
+23 -22
View File
@@ -1,4 +1,21 @@
--- ---
# Hardware: M5Stack ATOM Lite + ATOM Hub Switch
# Pinout:
# GPIO1 UART0 TX
# GPIO3 UART0 RX
# GPIO12 IR
# GPIO19 Relay2
# GPIO21 I2C1 SCL -> i2c (i2c scl)
# GPIO22 Relay1 -> power_supply1 (power_supply)
# GPIO23 RS485 Tx
# GPIO25 I2C1 SDA - red -> i2c (i2c sda)
# GPIO26 I2C0 SDA - white
# GPIO27 NEO 1x -> atom_led (status LED, common/status_led_atom.yaml)
# GPIO32 I2C0 SCL
# GPIO33 RS485 Rx
# GPIO39 BUTTON -> Status Button (binary_sensor gpio)
# I2C:
# 0x40 pca9685_hub1 (pca9685)
substitutions: substitutions:
device: kitchen device: kitchen
name: Kitchen name: Kitchen
@@ -32,33 +49,17 @@ esp32:
variant: esp32 variant: esp32
toolchain: esp-idf toolchain: esp-idf
framework: framework:
advanced:
flash_chip: gd
type: esp-idf type: esp-idf
packages: packages:
common: !include common/common.yaml common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
status_led: !include common/status_led_atom.yaml
api: # api:
reboot_timeout: 300s # reboot_timeout: 300s
# PINOUTS: M5ATOM+Atom Hub Switch
# IR G12
# NEO G27 1x
# BUTTON G39
# I2C0 SDA G26 - white
# I2C0 SCL G32
# I2C1 SDA G25 - red
# I2C1 SCL G21
# UART0 RX G3
# UART0 TX G1
# RS485 Rx G33
# RS485 Tx G23
# Relay1 G22
# Relay2 G19
time:
- platform: homeassistant
id: ha_time
timezone: Europe/Bratislava
i2c: i2c:
# - id: i2c0 # - id: i2c0
+12
View File
@@ -1,4 +1,14 @@
--- ---
# Hardware: M5Stack M5Stamp Pico
# Pinout:
# GPIO22 -> i2c (i2c scl)
# GPIO25 -> i2c (i2c sda)
# GPIO26 -> as3935_i2c (as3935_i2c irq_pin)
# GPIO27 -> neo (light esp32_rmt_led_strip)
# GPIO32 Grove SDA
# GPIO33 Grove SCL
# I2C:
# 0x03 as3935_i2c (as3935_i2c)
substitutions: substitutions:
device: lightening device: lightening
name: Lightening detector name: Lightening detector
@@ -16,6 +26,8 @@ esp32:
variant: esp32 variant: esp32
toolchain: esp-idf toolchain: esp-idf
framework: framework:
advanced:
flash_chip: gd # ESP32-PICO-D4, like the other M5Stamp Pico (not read from the device)
type: esp-idf type: esp-idf
packages: packages:
+337
View File
@@ -0,0 +1,337 @@
---
# Hardware: Guition ESP32-S3-4848S040
# Pinout:
# # Display (RGB, pins in the mipi_rgb model)
# CS 39
# SCK 48 ST7701S init (3-wire SPI)
# SDA 47
# DE 18
# HSYNC 16
# VSYNC 17
# PCLK 21
# BL 38
# # Capacitive Touch (GT911)
# TP_SDA 19
# TP_SCL 45
# # Relays (86 box variant)
# RELAY1 40
# RELAY2 2
# RELAY3 1
# Used:
# GPIO0 main_display (display mipi_rgb data_pins.red)
# GPIO3 main_display (display mipi_rgb data_pins.green)
# GPIO4 main_display (display mipi_rgb data_pins.blue)
# GPIO5 main_display (display mipi_rgb data_pins.blue)
# GPIO6 main_display (display mipi_rgb data_pins.blue)
# GPIO7 main_display (display mipi_rgb data_pins.blue)
# GPIO8 main_display (display mipi_rgb data_pins.green)
# GPIO9 main_display (display mipi_rgb data_pins.green)
# GPIO10 main_display (display mipi_rgb data_pins.green)
# GPIO11 main_display (display mipi_rgb data_pins.red)
# GPIO12 main_display (display mipi_rgb data_pins.red)
# GPIO13 main_display (display mipi_rgb data_pins.red)
# GPIO14 main_display (display mipi_rgb data_pins.red)
# GPIO15 main_display (display mipi_rgb data_pins.blue)
# GPIO16 main_display (display mipi_rgb hsync_pin)
# GPIO17 main_display (display mipi_rgb vsync_pin)
# GPIO18 main_display (display mipi_rgb de_pin)
# GPIO19 i2c_main (i2c sda)
# GPIO20 main_display (display mipi_rgb data_pins.green)
# GPIO21 main_display (display mipi_rgb pclk_pin)
# GPIO38 gpio_backlight_pwm (output ledc)
# GPIO39 main_display (display mipi_rgb cs_pin)
# GPIO45 i2c_main (i2c scl)
# GPIO46 main_display (display mipi_rgb data_pins.green)
# GPIO47 lcd_spi (spi mosi_pin)
# GPIO48 lcd_spi (spi clk_pin)
# I2C:
# 0x5D main_touch (touchscreen gt911)
substitutions:
device: lvgl-4848s040
name: LVGL 4848S040
area: DEV
comment: "${area} | Guition ESP32-S3-4848S040"
esphome:
name: mcu-${device}
friendly_name: ${name}
area: ${area}
comment: ${comment}
on_boot:
- priority: -100
then:
- lvgl.page.show: status_page
esp32:
variant: esp32s3
flash_size: 16MB
framework:
advanced:
flash_chip: boya
type: esp-idf
# PSRAM bandwidth for the RGB panel (not set by ESPHome); without it the
# image shifts during flash/WiFi activity
sdkconfig_options:
CONFIG_ESP32S3_DATA_CACHE_64KB: y
CONFIG_SPIRAM_FETCH_INSTRUCTIONS: y
CONFIG_SPIRAM_RODATA: y
psram:
mode: octal
speed: 80MHz
packages:
common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
api:
# status page until Home Assistant connects (log viewers don't subscribe to states)
on_client_connected:
- delay: 2s
- if:
condition:
api.connected:
state_subscription_only: true
then:
- lvgl.page.show: main_page
on_client_disconnected:
- if:
condition:
not:
api.connected:
state_subscription_only: true
then:
- lvgl.page.show: status_page
i2c:
- id: i2c_main
sda: 19
scl: 45
scan: true
spi:
- id: lcd_spi
clk_pin: 48
mosi_pin: 47
display:
- platform: mipi_rgb
model: GUITION-4848S040
id: main_display
spi_id: lcd_spi
update_interval: never
auto_clear_enabled: false
touchscreen:
- platform: gt911
id: main_touch
display: main_display
i2c_id: i2c_main
# the mipi_rgb model mirrors the image on both axes, touch has to follow
transform:
mirror_x: true
mirror_y: true
output:
- platform: ledc
id: gpio_backlight_pwm
pin: 38
frequency: 1220
light:
- platform: monochromatic
id: back_light
name: Backlight
output: gpio_backlight_pwm
restore_mode: ALWAYS_ON
script:
- id: update_status
then:
- lambda: |-
// same colors as the other status screens: ok green, waiting orange, details gray
static const uint32_t OK = 0x4DD966, WAIT = 0xFFB300;
auto set = [](lv_obj_t *label, const std::string &text, uint32_t color) {
lv_label_set_text(label, text.c_str());
lv_obj_set_style_text_color(label, lv_color_hex(color), LV_PART_MAIN);
};
const bool wifi_ok = wifi::global_wifi_component->is_connected();
set(id(status_wifi),
wifi_ok ? str_sprintf("WiFi: connected (%d dBm)", wifi::global_wifi_component->wifi_rssi())
: std::string("WiFi: connecting..."),
wifi_ok ? OK : WAIT);
// IPv6 first (skip link-local), then IPv4
std::string ips;
if (wifi_ok) {
char buf[network::IP_ADDRESS_BUFFER_SIZE];
for (bool v6 : {true, false}) {
for (auto &ip : wifi::global_wifi_component->get_ip_addresses()) {
if (!ip.is_set() || ip.is_ip6() != v6)
continue;
ip.str_to(buf);
if (v6 && strncmp(buf, "fe80", 4) == 0)
continue;
if (!ips.empty())
ips += "\n";
ips += buf;
}
}
}
lv_label_set_text(id(status_ips), ips.c_str());
if (ips.empty())
lv_obj_add_flag(id(status_ips), LV_OBJ_FLAG_HIDDEN);
else
lv_obj_remove_flag(id(status_ips), LV_OBJ_FLAG_HIDDEN);
const bool api_ok = api::global_api_server->is_connected();
set(id(status_ha), api_ok ? "Home Assistant: connected" : "Home Assistant: waiting...",
api_ok ? OK : WAIT);
const uint32_t up = millis() / 1000;
lv_label_set_text(id(status_footer),
str_sprintf("ESPHome %s · up %ud %02u:%02u:%02u", ESPHOME_VERSION, up / 86400,
(up / 3600) % 24, (up / 60) % 60, up % 60).c_str());
interval:
- interval: 1s
then:
- lvgl.label.update:
id: clock_label
text: !lambda |-
auto now = id(ha_time).now();
if (!now.is_valid())
return std::string("--:--");
return now.strftime("%H:%M");
- if:
condition:
lvgl.page.is_showing: status_page
then:
- script.execute: update_status
image:
- platform: file
file: assets/images/made-for-esphome-white-on-black.svg
id: esphome_logo
resize: 320x95
type: RGB565
transparency: alpha_channel
font:
- file: "gfonts://Roboto@500"
id: font_clock
size: 150
glyphs: "0123456789:-"
- file: "gfonts://Roboto"
id: font_title
size: 32
- file: "gfonts://Roboto"
id: font_status
size: 20
glyphs: "·"
glyphsets: [GF_Latin_Kernel]
lvgl:
log_level: WARN
color_depth: 16
bg_color: 0x000000
text_color: 0xFFFFFF
theme:
buttonmatrix:
bg_opa: TRANSP
border_width: 0
items:
bg_color: 0x2B2F36
text_color: 0xFFFFFF
radius: 12
checked:
bg_color: 0xE08A00
top_layer:
widgets:
# same navigation bar as on mcu-trainer
- buttonmatrix:
id: nav_bar
align: bottom_mid
width: 100%
height: 60
pad_all: 4
pad_column: 6
items:
text_font: montserrat_28
rows:
- buttons:
- id: page_prev
text: ""
on_press:
then:
lvgl.page.previous:
- id: page_home
text: ""
on_press:
then:
lvgl.page.show: main_page
- id: page_next
text: ""
on_press:
then:
lvgl.page.next:
pages:
# 1: clock
- id: main_page
widgets:
- label:
id: clock_label
align: CENTER
y: -30
text_font: font_clock
text: "--:--"
# 2: status (shown until Home Assistant connects)
- id: status_page
on_load:
- script.execute: update_status
widgets:
- image:
src: esphome_logo
align: TOP_MID
y: 16
- label:
align: TOP_MID
y: 120
text_font: font_title
text: "${name}"
- obj:
id: status_lines
x: 24
y: 170
width: 440
height: SIZE_CONTENT
bg_opa: TRANSP
border_width: 0
pad_all: 0
scrollbar_mode: "OFF"
layout:
type: flex
flex_flow: column
pad_row: 6
widgets:
- label:
id: status_wifi
text_font: font_status
text: ""
- label:
id: status_ips
text_font: font_status
text_color: 0x8C8C8C
pad_left: 20
text: ""
- label:
id: status_ha
text_font: font_status
text: ""
- label:
id: status_footer
text_font: font_status
text_color: 0x8C8C8C
text: ""
+15
View File
@@ -1,4 +1,17 @@
--- ---
# Hardware: Guition JC3248W535
# Pinout:
# GPIO1 -> main_backlight (power_supply)
# GPIO4 -> touchscreen_bus (i2c sda)
# GPIO8 -> touchscreen_bus (i2c scl)
# GPIO21 -> display_qspi (spi data_pins)
# GPIO39 -> display_qspi (spi data_pins)
# GPIO40 -> display_qspi (spi data_pins)
# GPIO45 -> main_display (display mipi_spi cs_pin)
# GPIO47 -> display_qspi (spi clk_pin)
# GPIO48 -> display_qspi (spi data_pins)
# I2C:
# 0x3B main_touch (touchscreen axs15231)
substitutions: substitutions:
device: lvgl-eworkbench device: lvgl-eworkbench
name: Electronics Workbench Display name: Electronics Workbench Display
@@ -16,6 +29,8 @@ esp32:
flash_size: 16MB flash_size: 16MB
toolchain: esp-idf toolchain: esp-idf
framework: framework:
advanced:
flash_chip: generic # same board as mcu-trainer (not read from the device)
type: esp-idf type: esp-idf
packages: packages:
-289
View File
@@ -1,289 +0,0 @@
---
substitutions:
device: lvgl-trainer
name: Trainer Display
area: Basement
comment: "${area} | Pain Cave"
esphome:
name: mcu-${device}
friendly_name: ${name}
area: ${area}
comment: ${comment}
esp32:
variant: esp32s3
flash_size: 16MB
framework:
type: esp-idf
packages:
common: !include common/common.yaml
i2c:
- id: touchscreen_bus
sda: 4
scl: 8
psram:
mode: octal
speed: 80MHz
spi:
id: display_qspi
type: quad
clk_pin: 47
data_pins: [21, 48, 40, 39]
color:
- id: my_red
red: 100%
green: 0%
blue: 0%
- id: my_orange
red: 100%
green: 50%
blue: 0%
- id: my_yellow
red: 100%
green: 100%
blue: 0%
- id: my_green
red: 0%
green: 100%
blue: 0%
- id: my_blue
red: 0%
green: 0%
blue: 100%
- id: my_teal
red: 0%
green: 100%
blue: 100%
- id: my_gray
red: 70%
green: 70%
blue: 70%
- id: my_white
red: 100%
green: 100%
blue: 100%
font:
- file: "gfonts://Roboto"
id: Roboto_48
size: 48
- file: "gfonts://Roboto"
id: Roboto_36
size: 36
- file: "gfonts://Roboto"
id: Roboto_24
size: 24
- file: "gfonts://Roboto"
id: Roboto_12
size: 12
- file: "gfonts://Roboto"
id: font_std
size: 40
glyphs: "!\"%()+=,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz/\\[]|&@#'"
- file: "gfonts://Roboto@700"
id: font_title
size: 40
glyphs: "!\"%()+=,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz/\\[]|&@#'"
globals:
- id: bgcolor
type: Color
initial_value: "Color::random_color()"
# power_supply:
# id: main_backlight
# pin: 1
# enable_on_boot: true
output:
- platform: ledc
id: gpio_backlight_pwm
pin: 1
light:
- id: display_backlight
name: Backlight
platform: monochromatic
output: gpio_backlight_pwm
restore_mode: ALWAYS_ON
default_transition_length: 500ms
display:
- platform: mipi_spi
model: AXS15231
data_rate: 40MHz #20mhz is default
#spi_mode: MODE2
id: main_display
spi_id: display_qspi
dimensions:
height: 480
width: 320
cs_pin: 45
auto_clear_enabled: false
# show_test_card: true
# lambda: |-
# it.fill(id(bgcolor));
# it.print(it.get_width()/2, it.get_height()/2-20, id(font_title), TextAlign::CENTER, "ESPHome");
# it.print(it.get_width()/2, it.get_height()/2+20, id(font_std), TextAlign::CENTER, "@UTBDK");
touchscreen:
- platform: axs15231
id: main_touch
display: main_display
i2c_id: touchscreen_bus
update_interval: 100ms
# interrupt_pin:
# number: 3
# ignore_strapping_warning: true
calibration:
x_min: 0
x_max: 479
y_min: 0
y_max: 319
transform:
swap_xy: true
mirror_x: false
mirror_y: true
# on_touch:
# - lambda: |-
# Color newColor;
# do { newColor = Color::random_color(); } while (newColor == id(bgcolor));
# id(bgcolor) = newColor;
# 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:
- lvgl.resume:
- lvgl.widget.redraw:
- light.turn_on:
id: display_backlight
transition_length: 300ms
uart:
- id: ext_uart
tx_pin: 43
rx_pin: 44
baud_rate: 115200
stop_bits: 1
parity: NONE
binary_sensor:
- platform: homeassistant
id: exercise_room_light
entity_id: light.exercise_room
trigger_on_initial_state: true
on_state:
then:
lvgl.widget.update:
id: exercise_room_light_btn
state:
checked: !lambda return x;
- platform: homeassistant
id: exercise_room_fan
entity_id: light.mcu_dimmer_exercise_room_fan
trigger_on_initial_state: true
on_state:
then:
lvgl.widget.update:
id: exercise_room_fan_btn
state:
checked: !lambda return x;
lvgl:
rotation: 90
buffer_size: 100%
log_level: WARN
color_depth: 16
default_font: montserrat_18
# on_idle:
# - timeout: !lambda "return (id(display_timeout).state * 1000);"
# then:
# - logger.log: "LVGL is idle"
# - light.turn_off:
# id: display_backlight
# transition_length: 2500ms
# - lvgl.pause:
top_layer:
widgets:
- buttonmatrix:
align: bottom_mid
# styles: header_footer
pad_all: 0
outline_width: 0
id: top_layer
# items:
# styles: header_footer
rows:
- buttons:
- id: page_prev
text: "\uF053"
on_press:
then:
lvgl.page.previous:
- id: page_home
text: "\uF015"
on_press:
then:
lvgl.page.show: main_page
- id: page_next
text: "\uF054"
on_press:
then:
lvgl.page.next:
pages:
- id: main_page
widgets:
- label:
text: "ESPHome LVGL Display"
align: CENTER
text_align: CENTER
text_color: 0xFFFFFF
- id: excercise_page
widgets:
- label:
align: CENTER
text: 'Hello World!'
- button:
id: exercise_room_light_btn
align: TOP_LEFT
width: 100
height: 70
checkable: true
widgets:
- label:
align: CENTER
text: 'Light'
on_click:
- homeassistant.action:
action: light.toggle
data:
entity_id: light.exercise_room
- button:
id: exercise_room_fan_btn
align: TOP_RIGHT
width: 100
height: 70
checkable: true
widgets:
- label:
align: CENTER
text: 'Fan'
on_click:
- homeassistant.action:
action: light.toggle
data:
entity_id: light.mcu_dimmer_exercise_room_fan
+877 -599
View File
File diff suppressed because it is too large. Load diff
+932
View File
@@ -0,0 +1,932 @@
# Hardware: M5Stack Core2 (AXP192) on the Faces Bottom II (600 mAh battery) with the QWERTY keyboard face
# Pinout:
# GPIO2 M-Bus (Core G15 position) -> faces_leds (light esp32_rmt_led_strip), Faces base SK6812 x10;
# also the Core2 speaker DOUT (NS4168), so no speaker while the LEDs are used
# GPIO5 -> display_tft (display mipi_spi cs_pin)
# GPIO15 -> display_tft (display mipi_spi dc_pin)
# GPIO18 -> spi_bus (spi clk_pin)
# GPIO19 M-Bus (modded NSS, stock G33) -> lora (sx127x cs_pin), LoRa868 module (Ra-01H, SX1276)
# GPIO21 -> i2c_main (i2c sda), M-Bus SDA
# GPIO22 -> i2c_main (i2c scl), M-Bus SCL
# GPIO23 -> spi_bus (spi mosi_pin)
# GPIO26 M-Bus, Port B -> lora (sx127x rst_pin)
# GPIO27 M-Bus (modded DIO1) -> LoRa868 DIO1, unused (sx127x has no dio1)
# GPIO35 M-Bus (modded DIO0, stock G36) -> lora (sx127x dio0_pin)
# GPIO38 -> spi_bus (spi miso_pin)
# GPIO39 -> touch_lcd (touchscreen ft63x6 interrupt_pin)
# AXP192 GPIO4 -> LCD reset (on_boot)
# Grove (free):
# Port A red (Core2) I2C GPIO32 SDA, GPIO33 SCL
# Port B black (base) GPIO GPIO26 out/DAC, GPIO36 in/ADC (input only); GPIO26 taken by the LoRa868 RST
# Port C blue (base) UART GPIO13 RX, GPIO14 TX -> i2c_port_c (i2c scl GPIO13, sda GPIO14)
# Touch buttons (below the LCD, raw y 240-280): A prev page, B keyboard page, C next page
# I2C:
# 0x08 keyboard (m5stack_keyboard), Faces QWERTY
# 0x34 pmu_axp (axp192)
# 0x38 touch_lcd (touchscreen ft63x6)
# 0x51 rtc_time (time bm8563)
# MPU6886 IMU (0x68) is cut off while the Faces base is attached
# I2C Port C:
# 0x3C oled (display ssd1306_i2c), Unit OLED SH1107
# 0x3E unit_lcd (display m5stack_st7789v2), Unit LCD, firmware 0.3
# 0x33 thermal (mlx90640), MLX90640 32x24 thermal camera
# 0x5F cardkb (m5stack_keyboard), CardKB (unplugged for now, its warning at boot is expected)
substitutions:
device: m5core2
name: M5Core2
area: DEV
comment: Core2 + Faces keyboard
esphome:
name: mcu-${device}
friendly_name: ${name}
area: ${area}
comment: ${comment}
on_boot:
# After the I2C bus, before the display: LCD power (LDO2), backlight (DC3), M-Bus 5V boost (EXTEN)
# for the Faces base, then the LCD reset pulse on AXP GPIO4 (open drain), as M5Core2's AXP192::begin
- priority: 900
then:
- lambda: |-
auto *axp = id(pmu_axp);
axp->writeRegister(0x27, (3300 - 700) / 25); // DC3 (LCD backlight) 3.3 V
axp->writeRegister(0x28, (axp->readRegister(0x28) & 0x0F) | 0xF0); // LDO2 3.3 V
axp->writeRegister(0x12, axp->readRegister(0x12) | 0x46); // EXTEN, LDO2, DC3
axp->writeRegister(0x95, (axp->readRegister(0x95) & 0x72) | 0x84); // GPIO4 output
axp->writeRegister(0x96, axp->readRegister(0x96) & ~0x02);
delay(100);
axp->writeRegister(0x96, axp->readRegister(0x96) | 0x02);
delay(100);
- priority: -100
then:
# the m5stack component sets these in the AXP2101 layout: 4.1 V, 360 mA, end at 10 %
- lambda: id(pmu_axp)->writeRegister(0x33, 0x83);
# The SH1107 once stuck showing noise (even after a power cycle) with ESPHome's init alone;
# M5GFX's settings that ESPHome lacks or sets otherwise brought it back, kept as insurance:
# end read-modify-write, POR clock, SH1107 precharge, VCOMH, DC-DC, RAM content, on
- lambda: |-
for (uint8_t c : {0xEE, 0xD5, 0x50, 0xD9, 0x20, 0xDB, 0x35, 0xAD, 0x8B, 0xA4, 0xAF})
id(oled).write_byte(0x00, c);
- bm8563.read_time:
- lvgl.page.show: {id: status_page, lvgl_id: lvgl_main}
esp32:
variant: esp32
flash_size: 16MB
framework:
type: esp-idf
advanced:
flash_chip: generic
minimum_chip_revision: 3.0
sram1_as_iram: true
psram:
mode: quad
speed: 80MHz
packages:
common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
status_led: !include
file: common/status_led.yaml
vars:
light_id: faces_leds
external_components:
- source: github://m5stack/esphome-yaml
components: [axp192]
refresh: 1h
- source: github://randybb/esphome-components
components: [m5stack_keyboard, m5stack_st7789v2, meshtastic, mlx90640]
refresh: 0s
# MLX90640 on Port C; settings changed at runtime are saved on the device
mlx90640:
id: thermal
i2c_id: i2c_port_c
web_ui: false # the heatmap page at /thermal would pull in web_server_base
refresh_rate: 4Hz
update_interval: 10s
min_temperature:
name: Thermal Min
max_temperature:
name: Thermal Max
mean_temperature:
name: Thermal Mean
center_temperature:
name: Thermal Center
ambient_temperature:
name: Thermal Sensor Die
frame_rate:
name: Thermal Frame Rate
i2c_errors:
name: Thermal I2C Errors
camera:
name: Thermal Camera
resolution: 320x240
api:
# status page until Home Assistant connects (log viewers don't subscribe to states)
on_client_connected:
- delay: 2s
- if:
condition:
api.connected:
state_subscription_only: true
then:
- lvgl.page.show: {id: main_page, lvgl_id: lvgl_main}
on_client_disconnected:
- if:
condition:
not:
api.connected:
state_subscription_only: true
then:
- lvgl.page.show: {id: status_page, lvgl_id: lvgl_main}
i2c:
- id: i2c_main
sda: 21
scl: 22
scan: true
# Port C (blue) used as a second I2C bus, Grove yellow = SCL, white = SDA
- id: i2c_port_c
sda: 14
scl: 13
frequency: 400kHz
scan: true
spi:
id: spi_bus
clk_pin: 18
mosi_pin: 23
miso_pin: 38
# LoRa868 module on Meshtastic EU LongFast, RSSI/SNR of every packet (relays included)
sx127x:
id: lora
spi_id: spi_bus
cs_pin: GPIO19
rst_pin: GPIO26
dio0_pin: GPIO35 # modded, stock G36
modulation: LORA
frequency: 869525000 # Meshtastic EU_868 LongFast, slot 0
bandwidth: 250_0kHz
spreading_factor: 11
coding_rate: CR_4_5
preamble_size: 16
sync_value: 0x2B # Meshtastic
crc_enable: true
pa_pin: BOOST
pa_power: 14
on_packet:
- lambda: |-
id(lora_count) += 1;
id(lora_rssi).publish_state(rssi);
id(lora_snr).publish_state(snr);
- lvgl.label.update:
id: lora_stats
text: !lambda |-
return str_sprintf("%.0f dBm\n%.1f dB\n%u", id(lora_rssi).state, id(lora_snr).state, id(lora_count));
# Typed lines go to the LongFast channel, received texts to the LoRa page
meshtastic:
id: mesh
long_name: randy_m5c2
short_name: M5C2
on_message:
- text_sensor.template.publish:
id: lora_packet
state: !lambda 'return from_name + ": " + text;'
- lvgl.label.update:
id: lora_last
text: !lambda 'return from_name + ": " + text;'
# Example, off: randy_home's Meshtastic integration already gives HA every node. Without such
# a node this sends each node update to HA, an automation with device_tracker.see maps them.
# on_node:
# - homeassistant.event:
# event: esphome.meshtastic_node
# data:
# node: !lambda return node.id();
# long_name: !lambda return node.long_name;
# hops: !lambda 'return node.hops < 0 ? std::string() : to_string(node.hops);'
# rssi: !lambda return meshtastic::num(node.rssi, 0);
# latitude: !lambda return meshtastic::num(node.latitude, 7);
# longitude: !lambda return meshtastic::num(node.longitude, 7);
# altitude: !lambda return meshtastic::num(node.altitude, 0);
# battery_level: !lambda return meshtastic::num(node.battery_level, 0);
# voltage: !lambda return meshtastic::num(node.voltage, 2);
# temperature: !lambda return meshtastic::num(node.temperature, 1);
globals:
- id: lora_count
type: uint32_t
initial_value: "0"
axp192:
id: pmu_axp
i2c_id: i2c_main
m5stack_keyboard:
- id: keyboard
i2c_id: i2c_main
- id: cardkb
i2c_id: i2c_port_c
address: 0x5F
display:
- platform: mipi_spi
id: display_tft
model: M5CORE2
spi_id: spi_bus
auto_clear_enabled: false
update_interval: never
- platform: ssd1306_i2c
id: oled
i2c_id: i2c_port_c
model: "SH1107 128x64"
address: 0x3C
rotation: 90
offset_x: 32 # the 64 visible columns sit in the middle of the SH1107 RAM
update_interval: 1s
lambda: |-
auto now = id(ha_time).now();
it.strftime(it.get_width() / 2, 0, id(font_title), TextAlign::TOP_CENTER, "%H:%M:%S", now);
it.printf(0, it.get_height(), id(font_status), TextAlign::BOTTOM_LEFT, "%.2f V %.0f%%", id(battery_voltage).state,
id(battery_level).state);
- platform: m5stack_st7789v2
id: unit_lcd
i2c_id: i2c_port_c
brightness: 60%
update_interval: 10s # only reconnects a lost unit, LVGL flushes drive the transfer
auto_clear_enabled: false
touchscreen:
- platform: ft63x6
id: touch_lcd
display: display_tft
i2c_id: i2c_main
interrupt_pin: 39
light:
- platform: esp32_rmt_led_strip
id: faces_leds
name: LED Strip
pin: GPIO2
num_leds: 10
chipset: SK6812
channel_colors: GRB
restore_mode: ALWAYS_OFF
effects:
- addressable_rainbow:
- addressable_scan:
binary_sensor:
- platform: template
id: battery_charging
name: Battery Charging
device_class: battery_charging
# the three touch buttons lie below the 240 px of the LCD, only in raw coordinates
- platform: touchscreen
id: button_a
use_raw: true
x_min: 0
x_max: 106
y_min: 240
y_max: 300
on_press:
- lvgl.page.previous: {lvgl_id: lvgl_main}
- platform: touchscreen
id: button_b
use_raw: true
x_min: 107
x_max: 213
y_min: 240
y_max: 300
on_press:
- lvgl.page.show: {id: main_page, lvgl_id: lvgl_main}
- platform: touchscreen
id: button_c
use_raw: true
x_min: 214
x_max: 320
y_min: 240
y_max: 300
on_press:
- lvgl.page.next: {lvgl_id: lvgl_main}
# AXP192 ADCs read directly, the m5stack component decodes them as an AXP2101
sensor:
- platform: template
id: battery_voltage
name: Battery Voltage
unit_of_measurement: V
device_class: voltage
accuracy_decimals: 2
- platform: template
id: battery_level
name: Battery Level
unit_of_measurement: "%"
device_class: battery
accuracy_decimals: 0
- platform: template
id: battery_current
name: Battery Current # + charging, - discharging
unit_of_measurement: mA
device_class: current
accuracy_decimals: 0
- platform: template
id: vbus_voltage
internal: true
- platform: template
id: vbus_current
internal: true
- platform: template
id: acin_voltage
internal: true
- platform: template
id: acin_current
internal: true
- platform: template
id: aps_voltage
internal: true
- platform: template
id: pmu_temperature
name: PMU Temperature
unit_of_measurement: °C
device_class: temperature
accuracy_decimals: 1
- platform: template
id: lora_rssi
name: LoRa RSSI
unit_of_measurement: dBm
device_class: signal_strength
accuracy_decimals: 0
- platform: template
id: lora_snr
name: LoRa SNR
unit_of_measurement: dB
accuracy_decimals: 1
# RTC holds the time until Home Assistant connects, HA's time is written back on every sync
time:
- platform: bm8563
id: rtc_time
i2c_id: i2c_main
update_interval: never
- id: !extend ha_time
on_time_sync:
- bm8563.write_time:
# Typed line in the text area, Enter (CR LF) sends it, Backspace deletes
key_collector:
- id: line_collector
source_id: keyboard
end_keys: "\r\n"
back_keys: "\b"
min_length: 1 # the LF after CR is an empty line
max_length: 64
on_progress: &line_progress
- lvgl.textarea.update:
id: input_text
text: !lambda return x;
on_result: &line_result
- logger.log:
format: "Line: %s"
args: [x.c_str()]
- lvgl.label.update:
id: last_line
text: !lambda return x;
- lvgl.label.update:
id: unit_last_line
text: !lambda return x;
- lvgl.textarea.update:
id: input_text
text: ""
- text_sensor.template.publish:
id: keyboard_line
state: !lambda return x;
- meshtastic.send_text: !lambda return x;
- id: cardkb_collector
source_id: cardkb
end_keys: "\r\n"
back_keys: "\b"
min_length: 1
max_length: 64
on_progress: *line_progress
on_result: *line_result
select:
- platform: mlx90640
refresh_rate:
name: Thermal Refresh Rate
palette:
name: Thermal Palette
number:
- platform: mlx90640
emissivity:
name: Thermal Emissivity
range_min:
name: Thermal Range Min
range_max:
name: Thermal Range Max
switch:
- platform: mlx90640
auto_range:
name: Thermal Auto Range
mirror:
name: Thermal Mirror
- platform: template
name: Unit LCD Invert
icon: mdi:invert-colors
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
entity_category: config
on_turn_on:
- lambda: id(unit_lcd).set_invert(true);
on_turn_off:
- lambda: id(unit_lcd).set_invert(false);
- platform: template
name: Unit LCD Sleep
icon: mdi:sleep
optimistic: true
restore_mode: ALWAYS_OFF
on_turn_on:
- lambda: id(unit_lcd).set_sleep(true);
on_turn_off:
- lambda: id(unit_lcd).set_sleep(false);
text_sensor:
- platform: template
id: keyboard_line
name: Keyboard Line
- platform: template
id: lora_packet
name: Meshtastic Message
script:
# same as mcu-lvgl
- id: update_status
then:
- lambda: |-
// same colors as the other status screens: ok green, waiting orange, details gray
static const uint32_t OK = 0x4DD966, WAIT = 0xFFB300;
auto set = [](lv_obj_t *label, const std::string &text, uint32_t color) {
lv_label_set_text(label, text.c_str());
lv_obj_set_style_text_color(label, lv_color_hex(color), LV_PART_MAIN);
};
const bool wifi_ok = wifi::global_wifi_component->is_connected();
set(id(status_wifi),
wifi_ok ? str_sprintf("WiFi: connected (%d dBm)", wifi::global_wifi_component->wifi_rssi())
: std::string("WiFi: connecting..."),
wifi_ok ? OK : WAIT);
// IPv6 first (skip link-local), then IPv4
std::string ips;
if (wifi_ok) {
char buf[network::IP_ADDRESS_BUFFER_SIZE];
for (bool v6 : {true, false}) {
for (auto &ip : wifi::global_wifi_component->get_ip_addresses()) {
if (!ip.is_set() || ip.is_ip6() != v6)
continue;
ip.str_to(buf);
if (v6 && strncmp(buf, "fe80", 4) == 0)
continue;
if (!ips.empty())
ips += "\n";
ips += buf;
}
}
}
lv_label_set_text(id(status_ips), ips.c_str());
if (ips.empty())
lv_obj_add_flag(id(status_ips), LV_OBJ_FLAG_HIDDEN);
else
lv_obj_remove_flag(id(status_ips), LV_OBJ_FLAG_HIDDEN);
const bool api_ok = api::global_api_server->is_connected();
set(id(status_ha), api_ok ? "Home Assistant: connected" : "Home Assistant: waiting...",
api_ok ? OK : WAIT);
const uint32_t up = millis() / 1000;
lv_label_set_text(id(status_footer),
str_sprintf("ESPHome %s · up %ud %02u:%02u:%02u", ESPHOME_VERSION, up / 86400,
(up / 3600) % 24, (up / 60) % 60, up % 60).c_str());
- id: update_axp
then:
- lvgl.label.update:
id: axp_values
text: !lambda |-
return str_sprintf("%.2f V %.0f %%\n%+.0f mA%s\n%.2f V %.0f mA\n%.2f V %.0f mA\n%.2f V\n%.1f °C",
id(battery_voltage).state, id(battery_level).state, id(battery_current).state,
id(battery_charging).state ? " charging" : "",
id(vbus_voltage).state, id(vbus_current).state,
id(acin_voltage).state, id(acin_current).state,
id(aps_voltage).state, id(pmu_temperature).state);
interval:
- interval: 5s
then:
- lambda: |-
auto *a = id(pmu_axp);
auto r = [a](uint8_t reg) { return a->readRegister(reg) & 0xFF; };
auto adc12 = [&](uint8_t h) { return (r(h) << 4) | (r(h + 1) & 0x0F); };
auto adc13 = [&](uint8_t h) { return (r(h) << 5) | (r(h + 1) & 0x1F); };
const float bat = adc12(0x78) * 1.1f / 1000;
id(battery_voltage).publish_state(bat);
// ponytail: linear 3.3-4.1 V, a discharge curve if the percentage matters
id(battery_level).publish_state(clamp((bat - 3.3f) / 0.8f * 100, 0.0f, 100.0f));
id(battery_current).publish_state(adc13(0x7A) * 0.5f - adc13(0x7C) * 0.5f);
id(vbus_voltage).publish_state(adc12(0x5A) * 1.7f / 1000);
id(vbus_current).publish_state(adc12(0x5C) * 0.375f);
id(acin_voltage).publish_state(adc12(0x56) * 1.7f / 1000);
id(acin_current).publish_state(adc12(0x58) * 0.625f);
id(aps_voltage).publish_state(adc12(0x7E) * 1.4f / 1000);
id(pmu_temperature).publish_state(adc12(0x5E) * 0.1f - 144.7f);
id(battery_charging).publish_state(r(0x01) & 0x40);
# thermal page: the newest MLX90640 frame, 32x24 upscaled bilinear x8 with the iron palette
- interval: 125ms
then:
- if:
condition:
lvgl.page.is_showing: thermal_page
then:
- lambda: |-
static float px[32 * 24];
static uint32_t shown = 0;
static uint16_t palette[256];
static bool palette_ready = false;
if (!id(thermal).has_frame() || id(thermal).get_frame_count() == shown)
return;
shown = id(thermal).get_frame_count();
id(thermal).copy_display_frame(px);
if (!palette_ready) {
// iron: black, navy, magenta, orange, yellow, white
const float stop[][4] = {{0, 0, 0, 0}, {0.2f, 32, 0, 140}, {0.45f, 204, 0, 119},
{0.7f, 255, 140, 0}, {0.85f, 255, 215, 0}, {1, 255, 255, 255}};
for (int i = 0; i < 256; i++) {
const float t = i / 255.0f;
int k = 0;
while (k < 4 && t > stop[k + 1][0])
k++;
const float f = (t - stop[k][0]) / (stop[k + 1][0] - stop[k][0]);
auto mix = [&](int c) { return uint8_t(stop[k][c] + f * (stop[k + 1][c] - stop[k][c])); };
palette[i] = lv_color_to_u16(lv_color_make(mix(1), mix(2), mix(3)));
}
palette_ready = true;
}
float lo = px[0], hi = px[0];
for (float v : px) {
lo = std::min(lo, v);
hi = std::max(hi, v);
}
const float center = (px[11 * 32 + 15] + px[11 * 32 + 16] + px[12 * 32 + 15] + px[12 * 32 + 16]) / 4;
float a = lo, b = hi;
if (b - a < 2) { // flat scenes would show noise
a = (lo + hi) / 2 - 1;
b = a + 2;
}
const float k = 255 / (b - a);
lv_obj_t *canvas = id(thermal_canvas);
lv_draw_buf_t *buf = lv_canvas_get_draw_buf(canvas);
for (int y = 0; y < 192; y++) {
const float sy = std::clamp((y + 0.5f) / 8 - 0.5f, 0.0f, 23.0f);
const int y0 = int(sy), y1 = std::min(y0 + 1, 23);
const float fy = sy - y0;
auto *row = reinterpret_cast<uint16_t *>(buf->data + y * buf->header.stride);
for (int x = 0; x < 256; x++) {
const float sx = std::clamp((x + 0.5f) / 8 - 0.5f, 0.0f, 31.0f);
const int x0 = int(sx), x1 = std::min(x0 + 1, 31);
const float fx = sx - x0;
const float top = px[y0 * 32 + x0] + fx * (px[y0 * 32 + x1] - px[y0 * 32 + x0]);
const float bottom = px[y1 * 32 + x0] + fx * (px[y1 * 32 + x1] - px[y1 * 32 + x0]);
row[x] = palette[std::clamp(int((top + fy * (bottom - top) - a) * k), 0, 255)];
}
}
// crosshair on the center spot
const uint16_t white = lv_color_to_u16(lv_color_white());
for (int d = -6; d <= 6; d++) {
if (d > -2 && d < 2)
continue;
reinterpret_cast<uint16_t *>(buf->data + 96 * buf->header.stride)[128 + d] = white;
reinterpret_cast<uint16_t *>(buf->data + (96 + d) * buf->header.stride)[128] = white;
}
lv_obj_invalidate(canvas);
lv_label_set_text(id(thermal_max), str_sprintf("%.1f°", hi).c_str());
lv_label_set_text(id(thermal_center), str_sprintf("%.1f°", center).c_str());
lv_label_set_text(id(thermal_min), str_sprintf("%.1f°", lo).c_str());
- interval: 1s
then:
- lvgl.label.update:
id: unit_time
text: !lambda |-
auto now = id(ha_time).now();
return now.is_valid() ? now.strftime("%H:%M") : std::string("--:--");
- lvgl.bar.update:
id: unit_battery_bar
value: !lambda return id(battery_level).state;
- lvgl.label.update:
id: unit_battery
text: !lambda |-
return str_sprintf("%.2f V %.0f %%%s", id(battery_voltage).state, id(battery_level).state,
id(battery_charging).state ? " charging" : "");
- if:
condition:
lvgl.page.is_showing: status_page
then:
- script.execute: update_status
- if:
condition:
lvgl.page.is_showing: axp_page
then:
- script.execute: update_axp
image:
- platform: file
file: assets/images/made-for-esphome-white-on-black.svg
id: esphome_logo
resize: 280x83
type: RGB565
transparency: alpha_channel
font:
- file: "gfonts://Roboto"
id: font_title
size: 24
- file: "gfonts://Roboto"
id: font_status
size: 16
glyphs: "·°"
glyphsets: [GF_Latin_Kernel]
lvgl:
- id: lvgl_main
displays: display_tft
touchscreens: touch_lcd
buffer_size: 25%
log_level: WARN
bg_color: 0x000000
text_color: 0xFFFFFF
pages:
# 1: keyboard demo
- id: main_page
widgets:
- label:
align: TOP_MID
y: 6
text_font: font_title
text: ${name}
- textarea:
id: input_text
align: TOP_MID
y: 40
width: 300
height: 70
text_font: font_status
placeholder_text: Type on the keyboard...
- label:
align: TOP_LEFT
x: 10
y: 122
text_font: font_status
text: "Last line:"
- label:
id: last_line
align: TOP_LEFT
x: 90
y: 122
width: 220
long_mode: DOT
text_font: font_status
text: "-"
- slider:
id: demo_slider
align: BOTTOM_LEFT
x: 20
y: -40
width: 170
on_value:
- lvgl.arc.update:
id: demo_arc
value: !lambda return x;
- arc:
id: demo_arc
align: BOTTOM_RIGHT
x: -15
y: -15
width: 100
height: 100
adjustable: false
# 2: AXP192 diagnostics
- id: axp_page
on_load:
- script.execute: update_axp
widgets:
- label:
align: TOP_MID
y: 6
text_font: font_title
text: AXP192
- label:
x: 16
y: 44
text_font: font_status
text_color: 0x8C8C8C
text: "Battery\nCurrent\nUSB (VBUS)\nM-Bus 5V (ACIN)\nAPS\nTemperature"
- label:
id: axp_values
x: 170
y: 44
text_font: font_status
text: ""
# 3: LoRa, last received Meshtastic packet
- id: lora_page
widgets:
- label:
align: TOP_MID
y: 6
text_font: font_title
text: Meshtastic LongFast
- label:
x: 16
y: 44
text_font: font_status
text_color: 0x8C8C8C
text: "RSSI\nSNR\nPackets"
- label:
id: lora_stats
x: 170
y: 44
text_font: font_status
text: "-\n-\n0"
- label:
x: 16
y: 120
text_font: font_status
text_color: 0x8C8C8C
text: "Last message:"
- label:
id: lora_last
x: 16
y: 142
width: 288
long_mode: WRAP
text_font: font_status
text: "-"
# 4: MLX90640 thermal image, drawn by the 125 ms interval
- id: thermal_page
widgets:
- canvas:
id: thermal_canvas
x: 0
y: 24
width: 256
height: 192
- label:
x: 262
y: 24
text_font: font_status
text_color: 0x8C8C8C
text: Max
- label:
id: thermal_max
x: 262
y: 44
text_font: font_status
text_color: 0xFF6040
text: "-"
- label:
x: 262
y: 98
text_font: font_status
text_color: 0x8C8C8C
text: "Center"
- label:
id: thermal_center
x: 262
y: 118
text_font: font_status
text: "-"
- label:
x: 262
y: 172
text_font: font_status
text_color: 0x8C8C8C
text: Min
- label:
id: thermal_min
x: 262
y: 192
text_font: font_status
text_color: 0x40A0FF
text: "-"
- label:
align: TOP_MID
x: -32
y: 2
text_font: font_status
text: MLX90640
# 5: status (shown until Home Assistant connects)
- id: status_page
on_load:
- script.execute: update_status
widgets:
- image:
src: esphome_logo
align: TOP_MID
y: 8
- label:
align: TOP_MID
y: 96
text_font: font_title
text: "${name}"
- obj:
x: 16
y: 132
width: 288
height: SIZE_CONTENT
bg_opa: TRANSP
border_width: 0
pad_all: 0
scrollbar_mode: "OFF"
layout:
type: flex
flex_flow: column
pad_row: 4
widgets:
- label:
id: status_wifi
text_font: font_status
text: ""
- label:
id: status_ips
text_font: font_status
text_color: 0x8C8C8C
pad_left: 20
text: ""
- label:
id: status_ha
text_font: font_status
text: ""
- label:
id: status_footer
text_font: font_status
text_color: 0x8C8C8C
text: ""
# Unit LCD on Port C, rotated by LVGL (the display can't rotate under LVGL)
- id: lvgl_unit
displays: unit_lcd
rotation: 90
buffer_size: 100%
bg_color: 0x101830
text_color: 0xFFFFFF
widgets:
- label:
x: 6
y: 4
text_font: font_title
text_color: 0xFFB300
text: ${name}
- label:
id: unit_time
align: TOP_RIGHT
x: -6
y: 4
text_font: font_title
text: "--:--"
- label:
x: 6
y: 44
text_font: font_status
text_color: 0x8C8C8C
text: "Last line:"
- label:
id: unit_last_line
x: 6
y: 64
width: 228
long_mode: DOT
text_font: font_status
text: "-"
- bar:
id: unit_battery_bar
x: 6
y: 94
width: 228
height: 10
min_value: 0
max_value: 100
- label:
id: unit_battery
x: 6
y: 110
text_font: font_status
text: ""
+600 -77
View File
@@ -1,97 +1,404 @@
--- ---
# Hardware: M5Stack M5Paper
# Pinout:
# GPIO2 -> main_power (switch gpio)
# GPIO5 -> ext_power (switch gpio)
# GPIO12 -> spi (spi mosi_pin)
# GPIO13 -> spi (spi miso_pin)
# GPIO14 -> spi (spi clk_pin)
# GPIO15 -> m5paper_display (display it8951 cs_pin)
# GPIO21 -> i2c_main (i2c sda)
# GPIO22 -> i2c_main (i2c scl)
# GPIO23 -> m5paper_display (display it8951 reset_pin)
# GPIO27 -> m5paper_display (display it8951 busy_pin)
# GPIO35 -> Battery Voltage (sensor adc)
# GPIO36 -> gt911_touchscreen (touchscreen gt911 interrupt_pin)
# GPIO37 -> M5Paper Button UP (binary_sensor gpio) (inverted)
# GPIO38 -> M5Paper Button Press (binary_sensor gpio) (inverted)
# GPIO39 -> M5Paper Button Down (binary_sensor gpio) (inverted)
# I2C:
# 0x44 sensor sht3xd (sensor sht3xd)
# 0x51 rtc_time (time bm8563)
# 0x5D gt911_touchscreen (touchscreen gt911)
substitutions: substitutions:
device: m5paper device: m5paper
name: M5Paper name: M5Paper
area: DEV area: DEV
comment: M5Paper comment: M5Paper
waste_calendar: calendar.https_www_hviezdoslavov_sk_kalendar_icalfeed_category_0_ongoing_1
# contacts + manual
birthday_calendars: calendar.birthdays, calendar.narodeniny
# Power modes
# - USB: always on, WiFi + API, events refreshed and redrawn after midnight
# - battery: RTC wakes the board at 00:05, it refreshes the events, draws them and powers
# itself off; the RTC timer lasts at most 255 min, so the wake-ups on the way to
# midnight only re-arm it
# The power button (and USB) also connects to WiFi: the events are refreshed on every
# Home Assistant connection outside the battery cycle.
# Screens: status (after power-on, until Home Assistant connects) and calendar
# The mode is detected by trying to power off: on USB the board keeps running.
esphome: esphome:
name: mcu-${device} name: mcu-${device}
friendly_name: ${name} friendly_name: ${name}
area: ${area} area: ${area}
comment: ${comment} comment: ${comment}
includes:
- include/m5paper_calendar.h
on_boot:
- priority: 600
then:
- lambda: |-
// BM8563 CONTROL_STATUS_2: TF (bit 2) is set when the timer woke us up
const uint8_t reg = 0x01;
uint8_t status = 0;
if (id(i2c_main)->write_readv(0x51, &reg, 1, &status, 1) == i2c::ERROR_OK) {
id(rtc_wake) = status & 0x04;
// clear TF and TIE so the RTC releases the power latch
const uint8_t clear[2] = {reg, uint8_t(status & ~0x05)};
id(i2c_main)->write(0x51, clear, 2);
}
m5paper_calendar::load(m5paper_calendar::events());
ESP_LOGI("m5paper", "Wake-up: %s, events: %u", id(rtc_wake) ? "RTC" : "power-on", m5paper_calendar::events().count);
- priority: -100
then:
- if:
condition:
lambda: return id(rtc_wake);
then:
- script.execute: battery_cycle
else:
# power button / USB: stay awake for a while (logs, OTA), then decide the mode
- wifi.enable:
# IT8951 init runs asynchronously after setup
- delay: 3s
- component.update: m5paper_display
- delay: 2min
- script.execute: battery_cycle
esp32: esp32:
variant: esp32 variant: esp32
toolchain: esp-idf toolchain: esp-idf
framework: framework:
type: esp-idf type: esp-idf
advanced:
flash_chip: generic
minimum_chip_revision: 3.0
sram1_as_iram: true
psram: psram:
external_components:
- source: github://Passific/m5paper_esphome
packages: packages:
common: !include common/common.yaml common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
time: globals:
- platform: homeassistant - id: show_status
id: ha_time type: bool
timezone: Europe/Bratislava initial_value: 'true'
on_time_sync: - id: usb_mode
- bm8563.write_time type: bool
- platform: bm8563 initial_value: 'false'
id: rtc_time - id: rtc_wake
sleep_duration: 3600000ms type: bool
initial_value: 'false'
# battery cycle running: calendar screen regardless of the connection state
- id: calendar_page
type: bool
initial_value: 'false'
- id: fetch_done
type: bool
initial_value: 'false'
- id: sleep_s
type: int
initial_value: '900'
m5paper: wifi:
battery_power_pin: GPIO5 enable_on_boot: false
main_power_pin: GPIO2 on_connect:
# update_interval: 10s - if:
# battery_voltage: condition:
# name: "${name} Battery" lambda: return id(show_status) && !id(calendar_page);
then:
- component.update: m5paper_display
api:
# status screen until Home Assistant connects (log viewers don't subscribe to states)
on_client_connected:
- delay: 2s
- if:
condition:
api.connected:
state_subscription_only: true
then:
- lambda: id(show_status) = false;
- if:
condition:
lambda: return !id(calendar_page);
then:
- component.update: m5paper_display
# outside the battery cycle (power button, USB) WiFi is up anyway: always refresh
- if:
condition:
and:
- lambda: return !id(calendar_page);
- api.connected:
state_subscription_only: true
then:
- script.execute: fetch_events
on_client_disconnected:
- if:
condition:
not:
api.connected:
state_subscription_only: true
then:
- lambda: id(show_status) = true;
- if:
condition:
lambda: return !id(calendar_page);
then:
- component.update: m5paper_display
# I2C devices (i2c_main)
# 0x44 SHT30 # 0x44 SHT30
# 0x50 # 0x50 FM24C02 EEPROM (unused)
# 0x51 # 0x51 BM8563 RTC
# 0x5D GT911 # 0x5D GT911 touch (docs say 0x14; the driver tries 0x5D, then 0x14)
i2c: i2c:
- id: i2c_main - id: i2c_main
sda: 21 sda: 21
scl: 22 scl: 22
scan: true #false scan: true
# Port A
# - id: i2c_a # - id: i2c_a
# sda: 25 # sda: 25
# scl: 32 # scl: 32
# scan: true #false # Port B
# - id: i2c_b # - id: i2c_b
# sda: 26 # sda: 26
# scl: 33 # scl: 33
# scan: true #false # Port C
# - id: i2c_c # - id: i2c_c
# sda: 18 # sda: 18
# scl: 19 # scl: 19
# scan: true #false
spi: spi:
clk_pin: 14 clk_pin: 14
miso_pin: 13 miso_pin: 13
mosi_pin: 12 mosi_pin: 12
switch:
# Power control MOS (no PMU on M5Paper); on battery the device powers off when this goes low
- platform: gpio
id: main_power
pin:
number: GPIO2
ignore_strapping_warning: true
restore_mode: ALWAYS_ON
internal: true
# External power (Grove ports)
- platform: gpio
id: ext_power
pin:
number: GPIO5
ignore_strapping_warning: true
restore_mode: ALWAYS_ON
internal: true
script:
# One wake-up on battery: refresh the events if they are old, draw them, power off
- id: battery_cycle
mode: single
then:
- lambda: id(calendar_page) = true;
- wait_until:
condition:
lambda: return id(rtc_time).now().is_valid();
timeout: 10s
- if:
# RTC wake-up on the way to midnight: nothing to draw
condition:
lambda: |-
const auto now = id(rtc_time).now();
return id(rtc_wake) && now.is_valid() && now.hour != 0;
then:
- script.execute: try_sleep
else:
- if:
condition:
lambda: return m5paper_calendar::stale(id(rtc_time).now());
then:
- wifi.enable:
- wait_until:
condition:
api.connected:
state_subscription_only: true
timeout: 45s
- if:
condition:
api.connected:
state_subscription_only: true
then:
- script.execute: fetch_events
- wait_until:
condition:
lambda: return id(fetch_done);
timeout: 15s
- component.update: m5paper_display
# let the e-paper refresh finish before cutting power
- delay: 4s
- script.execute: try_sleep
# today and the next 31 days (the month grid and the list)
- id: fetch_events
mode: single
then:
- lambda: id(fetch_done) = false;
- homeassistant.action:
action: calendar.get_events
data:
entity_id: ${waste_calendar}, ${birthday_calendars}
start_date_time: !lambda return id(rtc_time).now().strftime("%Y-%m-%d 00:00:00");
duration: "744:00:00"
capture_response: true
on_success:
- lambda: |-
auto &ev = m5paper_calendar::events();
if (m5paper_calendar::parse(response, "${waste_calendar}", id(rtc_time).now().timestamp, ev)) {
const bool saved = m5paper_calendar::save(ev);
ESP_LOGI("m5paper", "Events: %u%s", ev.count, saved ? "" : " (flash write failed)");
} else {
ESP_LOGW("m5paper", "Events: unexpected response");
}
id(fetch_done) = true;
# the battery cycle draws on its own
- if:
condition:
lambda: return !id(calendar_page);
then:
- component.update: m5paper_display
on_error:
- lambda: |-
ESP_LOGW("m5paper", "Events: %s", error.c_str());
id(fetch_done) = true;
# Arm the RTC and cut power; if we are still running afterwards, we are on USB
- id: try_sleep
mode: single
then:
- lambda: |-
// next 00:05; the timer lasts at most 255 min, so get there in steps
const int MAX = 255 * 60;
int duration = MAX;
const auto now = id(rtc_time).now();
if (now.is_valid()) {
const int sod = now.hour * 3600 + now.minute * 60 + now.second;
int left = (86400 + 300 - sod) % 86400;
if (left < 600) // just drawn: the 1/60 Hz RTC timer may wake us up to a minute early
left += 86400;
// leave at least 20 min for the last step, so it cannot fall into the case above
duration = left > MAX ? std::min(MAX, left - 1200) : left;
}
if (duration > 255) // longer timers count whole minutes
duration = (duration + 59) / 60 * 60;
id(sleep_s) = std::min(duration, MAX);
ESP_LOGI("m5paper", "Powering off for %d s", id(sleep_s));
- bm8563.start_timer:
duration: !lambda return id(sleep_s);
# a battery wake-up is shorter than boot_is_good_after: confirm the OTA image
# before cutting power, otherwise the bootloader rolls back
- safe_mode.mark_successful:
- delay: 200ms
- switch.turn_off: main_power
- delay: 2s
# still alive -> USB power
- switch.turn_on: main_power
- lambda: |-
ESP_LOGI("m5paper", "Still running, USB power");
id(usb_mode) = true;
id(rtc_wake) = false;
id(calendar_page) = false;
id(show_status) = !api::global_api_server->is_connected_with_state_subscription();
- wifi.enable:
- component.update: m5paper_display
interval:
# USB mode: the battery voltage drops once USB is unplugged -> go to battery mode
- interval: 5min
then:
- if:
condition:
lambda: |-
static float last = NAN;
const float v = id(battery_voltage).state;
const bool dropped = id(usb_mode) && !std::isnan(last) && last - v > 0.03f;
last = v;
return dropped;
then:
- lambda: |-
ESP_LOGI("m5paper", "Battery voltage dropping, checking USB");
id(usb_mode) = false;
- script.execute: battery_cycle
time:
- id: !extend ha_time
on_time_sync:
- bm8563.write_time
- if:
condition:
lambda: return !id(calendar_page);
then:
- component.update: m5paper_display
on_time:
# new day
- seconds: 0
minutes: 0
hours: 0
then:
- if:
condition:
lambda: return !id(show_status) && !id(calendar_page);
then:
- component.update: m5paper_display
# USB mode: keep the stored events fresh for battery mode
- seconds: 0
minutes: 5
hours: 0
then:
- if:
condition:
and:
- lambda: return id(usb_mode);
- api.connected:
state_subscription_only: true
then:
- script.execute: fetch_events
- platform: bm8563
id: rtc_time
binary_sensor: binary_sensor:
- platform: gpio - platform: gpio
name: ${name} Button UP name: ${name} Button UP
id: button_up id: button_up
pin: pin:
number: 37 number: GPIO37
inverted: true inverted: true
on_press: on_press:
- component.update: m5paper_display - component.update: m5paper_display
on_release:
- component.update: m5paper_display
- platform: gpio - platform: gpio
name: ${name} Button Press name: ${name} Button Press
id: button_press id: button_press
pin: pin:
number: 38 number: GPIO38
inverted: true inverted: true
- platform: gpio - platform: gpio
name: ${name} Button Down name: ${name} Button Down
id: button_down id: button_down
pin: pin:
number: 39 number: GPIO39
inverted: true inverted: true
- platform: touchscreen - platform: touchscreen
name: ${name} Top Left Touch Button name: ${name} Top Left Touch Button
@@ -103,51 +410,19 @@ binary_sensor:
y_min: 0 y_min: 0
y_max: 100 y_max: 100
on_press: on_press:
# Example of applying the sleep duration and shutting down to the lowest power mode - script.execute: battery_cycle
- bm8563.apply_sleep_duration
- delay: 1s
- m5paper.shutdown_main_power
font: button:
- file: "gfonts://Roboto" - platform: template
id: font_default name: Refresh Display
size: 20 entity_category: config
- file: "gfonts://Roboto" on_press:
id: roboto_32 - component.update: m5paper_display
size: 32 - platform: template
- file: "gfonts://Roboto" name: Refresh Calendar
id: roboto_24 entity_category: config
size: 24 on_press:
- file: "gfonts://Roboto" - script.execute: fetch_events
id: roboto_12
size: 12
display:
- platform: it8951e
id: m5paper_display
cs_pin: GPIO15
reset_pin: GPIO23
busy_pin: GPIO27
rotation: 90
reversed: False
update_interval: "never"
lambda: |-
it.printf(25, 25, id(roboto_32), "%.1f°", id(current_temperature).state);
it.strftime(350, 25, id(roboto_32), "%H:%M:%S", id(rtc_time).now());
touchscreen:
- platform: gt911
display: m5paper_display
id: gt911_touchscreen
interrupt_pin: GPIO36
# display:
# - platform: waveshare_epaper
# cs_pin: 15
# model: 2.90in
# full_update_every: 30
# lambda: |-
# it.print(0, 0, id(font1), "Hello World!");
sensor: sensor:
- platform: sht3xd - platform: sht3xd
@@ -156,9 +431,257 @@ sensor:
id: current_temperature id: current_temperature
humidity: humidity:
name: Humidity name: Humidity
id: current_humidity
address: 0x44 address: 0x44
update_interval: 60s update_interval: 60s
- platform: adc
id: battery_voltage
name: Battery Voltage
pin: GPIO35
attenuation: 12db
samples: 16
update_interval: 60s
entity_category: diagnostic
filters:
- multiply: 2.0 # 1:2 voltage divider
- platform: copy
source_id: battery_voltage
id: battery_level
name: Battery
unit_of_measurement: "%"
device_class: battery
accuracy_decimals: 0
filters:
- calibrate_linear:
- 3.3 -> 0.0
- 4.15 -> 100.0
- clamp:
min_value: 0
max_value: 100
# touchscreen: .image_defaults:
# - platform: gt911 icon: &icon {platform: file, type: BINARY, transparency: chroma_key}
# interrupt_pin: 36
image:
- platform: file
file: assets/images/made-for-esphome-white-on-black.svg
id: esphome_logo
resize: 460x136
type: GRAYSCALE
transparency: alpha_channel
# same order as m5paper_calendar::Kind
- {<<: *icon, file: "mdi:cake-variant", id: icon_birthday, resize: 32x32}
- {<<: *icon, file: "mdi:trash-can", id: icon_waste, resize: 32x32}
- {<<: *icon, file: "mdi:cake-variant", id: mark_birthday, resize: 18x18}
- {<<: *icon, file: "mdi:trash-can", id: mark_waste, resize: 18x18}
font:
- file: "gfonts://Roboto"
id: font_title
size: 48
- file: "gfonts://Roboto"
id: font_status
size: 28
glyphs: &sk_glyphs "ÁÄČĎÉÍĹĽŇÓÔŔŠŤÚÝŽáäčďéíĺľňóôŕšťúýž°·"
glyphsets: [GF_Latin_Kernel]
- file: "gfonts://Roboto"
id: font_small
size: 24
glyphs: *sk_glyphs
glyphsets: [GF_Latin_Kernel]
- file: "gfonts://Roboto"
id: font_footer
size: 18
glyphs: "0123456789abcdef:. "
- file: "gfonts://Roboto@500"
id: font_date
size: 34
glyphs: *sk_glyphs
glyphsets: [GF_Latin_Kernel]
color:
- id: ink
red: 0%
green: 0%
blue: 0%
- id: paper
red: 100%
green: 100%
blue: 100%
display:
- platform: it8951
id: m5paper_display
model: m5stack-m5paper
rotation: 270
update_interval: never
# 1bpp: updates use the fast DU waveform, full GC16 refresh every 30 updates
grayscale: false
dithering: false
lambda: |-
// 540x960 portrait
it.fill(id(paper));
const int w = it.get_width();
const int cx = w / 2;
const float batt = id(battery_level).state;
// status screen after power-on, until Home Assistant connects
if (id(show_status) && !id(calendar_page)) {
it.image(cx, 200, id(esphome_logo), ImageAlign::CENTER);
it.print(cx, 320, id(font_title), id(ink), TextAlign::CENTER, "${name}");
const bool wifi_ok = wifi::global_wifi_component->is_connected();
if (wifi_ok) {
it.printf(40, 440, id(font_status), id(ink), "WiFi: connected (%d dBm)", wifi::global_wifi_component->wifi_rssi());
// IPv6 first (skip link-local), then IPv4
int y = 484;
char buf[network::IP_ADDRESS_BUFFER_SIZE];
for (bool v6 : {true, false}) {
for (auto &ip : wifi::global_wifi_component->get_ip_addresses()) {
if (!ip.is_set() || ip.is_ip6() != v6 || y > 590)
continue;
ip.str_to(buf);
if (v6 && strncmp(buf, "fe80", 4) == 0)
continue;
it.print(60, y, id(font_small), id(ink), buf);
y += 34;
}
}
} else {
it.print(40, 440, id(font_status), id(ink), "WiFi: connecting...");
}
const bool api_ok = api::global_api_server->is_connected_with_state_subscription();
it.print(40, 620, id(font_status), id(ink),
api_ok ? "Home Assistant: connected" : "Home Assistant: waiting...");
if (!std::isnan(batt))
it.printf(40, 670, id(font_status), id(ink), "Battery: %.0f%% (%.2f V)", batt, id(battery_voltage).state);
it.printf(40, 720, id(font_status), id(ink), "Calendar: %u events stored", m5paper_calendar::events().count);
it.printf(40, 900, id(font_small), id(ink), "ESPHome %s", ESPHOME_VERSION);
return;
}
// calendar screen
using namespace m5paper_calendar;
image::Image *icons[] = {id(icon_birthday), id(icon_waste)};
image::Image *marks[] = {id(mark_birthday), id(mark_waste)};
static const char *const DAYS[] = {"Pondelok", "Utorok", "Streda", "Štvrtok", "Piatok", "Sobota", "Nedeľa"};
static const char *const DAYS_SHORT[] = {"Po", "Ut", "St", "Št", "Pi", "So", "Ne"};
static const char *const MONTHS[] = {"Január", "Február", "Marec", "Apríl", "Máj", "Jún",
"Júl", "August", "September", "Október", "November", "December"};
const auto &ev = m5paper_calendar::events();
const auto now = id(rtc_time).now();
if (!now.is_valid()) {
it.print(cx, 400, id(font_status), id(ink), TextAlign::CENTER, "Čas nie je k dispozícii");
return;
}
const int32_t today = local_day(now);
// header: date, battery
it.printf(24, 16, id(font_date), id(ink), "%s %d. %d.", DAYS[weekday(today)], now.day_of_month, now.month);
if (!std::isnan(batt))
it.printf(w - 24, 22, id(font_small), id(ink), TextAlign::TOP_RIGHT, "%.0f %%", batt);
// month grid; days with events get the icons of their kinds
const int32_t first = days_from_civil(now.year, now.month, 1);
const int32_t next = now.month == 12 ? days_from_civil(now.year + 1, 1, 1) : days_from_civil(now.year, now.month + 1, 1);
const int dim = next - first, lead = weekday(first);
uint8_t kinds[32] = {};
for (int i = 0; i < ev.count; i++) {
if (ev.items[i].day >= first && ev.items[i].day < next)
kinds[ev.items[i].day - first + 1] |= 1 << ev.items[i].kind;
}
const int col_w = 70, row_h = 54, gx = (w - 7 * col_w) / 2, gy = 150;
it.printf(cx, 70, id(font_status), id(ink), TextAlign::TOP_CENTER, "%s %d", MONTHS[now.month - 1], now.year);
for (int c = 0; c < 7; c++)
it.print(gx + c * col_w + col_w / 2, 116, id(font_small), id(ink), TextAlign::TOP_CENTER, DAYS_SHORT[c]);
for (int d = 1; d <= dim; d++) {
const int cell = lead + d - 1;
const int x = gx + (cell % 7) * col_w, y = gy + (cell / 7) * row_h;
const bool is_today = first + d - 1 == today;
if (is_today)
it.filled_rectangle(x + 3, y + 1, col_w - 6, row_h - 2, id(ink));
const Color fg = is_today ? id(paper) : id(ink);
it.printf(x + col_w / 2, y + 4, id(font_small), fg, TextAlign::TOP_CENTER, "%d", d);
const int n = __builtin_popcount(kinds[d]);
int mx = x + (col_w - n * 20) / 2;
for (int k = 0; k < 2; k++) {
if (kinds[d] & (1 << k)) {
it.image(mx, y + 32, marks[k], fg);
mx += 20;
}
}
}
// next 14 days; waste collection today or tomorrow is inverted: put the bin out
const int top = 490, list_h = 50, max_rows = 8;
it.horizontal_line(24, top - 12, w - 48, id(ink));
int rows = 0, more = 0;
for (int i = 0; i < ev.count; i++) {
const Event &e = ev.items[i];
if (e.day < today || e.day >= today + 14)
continue;
if (rows == max_rows) {
more++;
continue;
}
const int y = top + rows++ * list_h;
const bool urgent = e.kind == WASTE && e.day <= today + 1;
if (urgent)
it.filled_rectangle(16, y, w - 32, list_h - 4, id(ink));
const Color fg = urgent ? id(paper) : id(ink);
const int ty = y + (list_h - 4) / 2;
if (e.day == today)
it.print(28, ty, id(font_small), fg, TextAlign::CENTER_LEFT, "Dnes");
else if (e.day == today + 1)
it.print(28, ty, id(font_small), fg, TextAlign::CENTER_LEFT, "Zajtra");
else {
const auto t = ESPTime::from_epoch_local(uint32_t(e.day) * 86400 + 43200);
it.printf(28, ty, id(font_small), fg, TextAlign::CENTER_LEFT, "%s %d. %d.", DAYS_SHORT[weekday(e.day)],
t.day_of_month, t.month);
}
if (e.kind < 2)
it.image(150, ty - 16, icons[e.kind], fg);
it.start_clipping(194, y, w - 28, y + list_h);
if (e.minute == ALL_DAY)
it.print(194, ty, id(font_small), fg, TextAlign::CENTER_LEFT, e.summary);
else
it.printf(194, ty, id(font_small), fg, TextAlign::CENTER_LEFT, "%02d:%02d %s", e.minute / 60, e.minute % 60,
e.summary);
it.end_clipping();
}
if (!ev.valid())
it.print(cx, top + 20, id(font_small), id(ink), TextAlign::TOP_CENTER, "Kalendár nie je k dispozícii");
else if (rows == 0)
it.print(cx, top + 20, id(font_small), id(ink), TextAlign::TOP_CENTER, "Žiadne udalosti v najbližších 14 dňoch");
else if (more > 0)
it.printf(w - 28, top + rows * list_h, id(font_small), id(ink), TextAlign::TOP_RIGHT, "+%d ďalšie", more);
// footer: IPv6 address (only while WiFi is up), last download
it.horizontal_line(24, 910, w - 48, id(ink));
char buf[network::IP_ADDRESS_BUFFER_SIZE];
for (auto &ip : wifi::global_wifi_component->get_ip_addresses()) {
if (!ip.is_set() || !ip.is_ip6())
continue;
ip.str_to(buf);
if (strncmp(buf, "fe80", 4) != 0) {
it.print(24, 944, id(font_footer), id(ink), TextAlign::BOTTOM_LEFT, buf);
break;
}
}
if (ev.valid()) {
const auto f = ESPTime::from_epoch_local(ev.fetched_at);
it.printf(w - 24, 944, id(font_footer), id(ink), TextAlign::BOTTOM_RIGHT, "%d. %d. %02d:%02d", f.day_of_month,
f.month, f.hour, f.minute);
}
touchscreen:
- platform: gt911
id: gt911_touchscreen
display: m5paper_display
# GPIO36 is input-only; INT is only driven as output when reset_pin is set
interrupt_pin:
number: GPIO36
mode:
input: true
output: false
+21 -18
View File
@@ -1,4 +1,19 @@
--- ---
# Hardware: M5Stack ATOM Lite
# Pinout:
# GPIO1 UART0 TX
# GPIO3 UART0 RX
# GPIO12 IR
# GPIO19 NC
# GPIO21 I2C1 SCL
# GPIO22 1-WIRE
# GPIO23 UART1 RX
# GPIO25 I2C1 SDA
# GPIO26 I2C0 SDA -> uart_modbus (uart rx_pin)
# GPIO27 NEO -> atom_led (status LED, common/status_led_atom.yaml)
# GPIO32 I2C0 SCL -> uart_modbus (uart tx_pin)
# GPIO33 UART1 TX
# GPIO39 BUTTON
substitutions: substitutions:
device: mains-power device: mains-power
name: Mains Power name: Mains Power
@@ -17,30 +32,20 @@ esphome:
- id: mains - id: mains
name: Mains name: Mains
area_id: local_area area_id: local_area
relation: child
esp32: esp32:
variant: esp32 variant: esp32
toolchain: esp-idf toolchain: esp-idf
framework: framework:
advanced:
flash_chip: gd
type: esp-idf type: esp-idf
packages: packages:
common: !include common/common.yaml common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
# PINOUTS: M5ATOM status_led: !include common/status_led_atom.yaml
# IR G12
# NEO G27
# BUTTON G39
# I2C0 SDA G26
# I2C0 SCL G32
# I2C1 SDA G25
# I2C1 SCL G21
# UART0 RX G3
# UART0 TX G1
# UART1 RX G23
# UART1 TX G33
# 1-WIRE G22
# NC G19
modbus: modbus:
uart_id: uart_modbus uart_id: uart_modbus
@@ -228,9 +233,7 @@ button:
- pzemac.reset_energy: pzemac_l3 - pzemac.reset_energy: pzemac_l3
time: time:
- platform: homeassistant - id: !extend ha_time
id: ha_time
timezone: Europe/Bratislava
on_time: on_time:
- cron: '0 0 0 * * *' - cron: '0 0 0 * * *'
then: then:
+231
View File
@@ -0,0 +1,231 @@
---
# Hardware: Nordic nRF52840 DK
# Flash: J-Link 683101126, it has no VCOM port, so with mcu-nrf-dk plugged in too run west from the NCS
# workspace (~/.cache/esphome/sdk-zephyr/frameworks/sdk-nrf-v3.4.1):
# west flash --no-rebuild -d ~/esphome/.esphome/build/mcu-nrf-ant/.west_build -i 000683101126
# Pinout:
# P0.06 UART0 TX -> logger (J-Link VCOM)
# P0.13 LED 1 (active low) -> ANT+ Connected (a configured device is received)
# P0.14 LED 2 (active low) -> ANT+ Unknown Device (an unconfigured one is in range)
# NFC1/2 NFC antenna connector -> nfc_tag (Type 2 tag, HA tag URL)
# P1.01 UART1 RX <- mcu-nrf-dk UART1 TX (P1.02), packet_transport
# P1.02 UART1 TX -> mcu-nrf-dk UART1 RX (P1.01), packet_transport; plus GND
# Radio: ANT+ receiver (RadiANT), no network of its own; values go to mcu-nrf-dk
# ANT+ devices:
# 655730 Garmin HRM-Pro heart rate
# 498521 Concept2 PM5 (rower) fitness equipment (FE-C)
# 1044953 Garmin Tempe environment (temperature)
# 604693 Garmin Varia RTL515 bike radar: vehicles, nearest distance + closing speed, battery
# 136052 Garmin HRM-Dual heart rate (pain cave)
# 334424 Garmin HRM-Tri heart rate (bike)
# 886796 Garmin Rally RS200 power + cadence
# 343922 Garmin Speed Sensor 2 speed
# 42898 SRAM Force AXS shifting (Cube Litening C:68X), battery only
# 13888 Tacx Neo 2 fitness equipment (FE-C), basement trainer
esphome:
name: mcu-nrf-ant
friendly_name: nRF ANT+
# needs the esphomeplatformzephyr fork (esphome-zephyr); RadiANT needs NCS
nrf:
variant: NRF52
board: nrf52840dk/nrf52840
framework:
type: ncs
logger:
hardware_uart: UART0
external_components:
- source: github://randybb/esphome-components
components: [ant_plus, nfc_tag]
output:
- platform: gpio
id: led_known
pin: {number: P0.13, inverted: true}
- platform: gpio
id: led_unknown
pin: {number: P0.14, inverted: true}
nfc_tag:
url: https://www.home-assistant.io/tag/mcu-nrf-ant
ant_plus:
network_key: !secret ant_plus_network_key
connected:
id: ant_connected
name: ANT+ Connected
on_press: {output.turn_on: led_known}
on_release: {output.turn_off: led_known}
unknown_device:
id: ant_unknown_device
name: ANT+ Unknown Device
on_press: {output.turn_on: led_unknown}
on_release: {output.turn_off: led_unknown}
devices:
- type: heart_rate # Garmin HRM-Pro
device_number: 655730
heart_rate:
id: hrm_pro_heart_rate
name: Garmin HRM-Pro Heart Rate
battery_level:
id: hrm_pro_battery
name: Garmin HRM-Pro Battery
- type: fitness_equipment # Concept2 PM5 (rower)
device_number: 498521
power:
id: pm5_power
name: Concept2 PM5 Power
cadence:
id: pm5_stroke_rate
name: Concept2 PM5 Stroke Rate
in_use:
id: pm5_in_use
name: Concept2 PM5 In Use
- type: temperature # Garmin Tempe
device_number: 1044953
temperature:
id: tempe_temperature
name: Garmin Tempe Temperature
temperature_min:
id: tempe_temperature_min
name: Garmin Tempe Temperature 24h Min
temperature_max:
id: tempe_temperature_max
name: Garmin Tempe Temperature 24h Max
battery_voltage:
id: tempe_battery
name: Garmin Tempe Battery
battery_low:
id: tempe_battery_low
name: Garmin Tempe Battery Low
- type: bike_radar # Garmin Varia RTL515
device_number: 604693
battery_voltage:
id: varia_battery
name: Garmin Varia RTL515 Battery
battery_low:
id: varia_battery_low
name: Garmin Varia RTL515 Battery Low
targets:
id: varia_vehicles
name: Garmin Varia RTL515 Vehicles
distance:
id: varia_distance
name: Garmin Varia RTL515 Vehicle Distance
speed:
id: varia_speed
name: Garmin Varia RTL515 Closing Speed
fast_approach:
id: varia_fast
name: Garmin Varia RTL515 Fast Vehicle
- type: heart_rate # Garmin HRM-Dual
device_number: 136052
heart_rate:
id: hrm_dual_heart_rate
name: Garmin HRM-Dual Heart Rate
battery_level:
id: hrm_dual_battery
name: Garmin HRM-Dual Battery
- type: heart_rate # Garmin HRM-Tri
device_number: 334424
heart_rate:
id: hrm_tri_heart_rate
name: Garmin HRM-Tri Heart Rate
battery_level:
id: hrm_tri_battery
name: Garmin HRM-Tri Battery
- type: power # Garmin Rally RS200 (a battery in each pedal)
device_number: 886796
power:
id: rally_power
name: Garmin Rally RS200 Power
cadence:
id: rally_cadence
name: Garmin Rally RS200 Cadence
battery_low:
id: rally_battery_low
name: Garmin Rally RS200 Battery Low
- type: speed # Garmin Speed Sensor 2
device_number: 343922
speed:
id: speed2_speed
name: Garmin Speed Sensor 2 Speed
battery_voltage:
id: speed2_battery
name: Garmin Speed Sensor 2 Battery
battery_low:
id: speed2_battery_low
name: Garmin Speed Sensor 2 Battery Low
- type: fitness_equipment # Tacx Neo 2
device_number: 13888
power:
id: neo_power
name: Tacx Neo 2 Power
cadence:
id: neo_cadence
name: Tacx Neo 2 Cadence
in_use:
id: neo_in_use
name: Tacx Neo 2 In Use
- type: shifting # SRAM Force AXS (Cube Litening C:68X)
device_number: 42898
battery_low:
id: sram_battery_low
name: SRAM Force AXS Battery Low
uart:
id: link
port: UART1
# the DK's default UART1 pins, same on both boards, wires crossed
tx_pin: P1.02
rx_pin: P1.01
baud_rate: 115200
# same layers as mcu-nrf-dk, both ends must match
packet_interface:
- platform: uart
id: link_packets
uart_id: link
reliability:
session:
packet_transport:
- platform: packet_interface
packet_interface: link_packets
update_interval: 1s
sensors:
- hrm_pro_heart_rate
- hrm_pro_battery
- pm5_power
- pm5_stroke_rate
- tempe_temperature
- tempe_temperature_min
- tempe_temperature_max
- tempe_battery
- varia_battery
- varia_vehicles
- varia_distance
- varia_speed
- hrm_dual_heart_rate
- hrm_dual_battery
- hrm_tri_heart_rate
- hrm_tri_battery
- rally_power
- rally_cadence
- speed2_speed
- speed2_battery
- neo_power
- neo_cadence
binary_sensors:
- ant_connected
- ant_unknown_device
- pm5_in_use
- tempe_battery_low
- varia_battery_low
- varia_fast
- rally_battery_low
- speed2_battery_low
- sram_battery_low
- neo_in_use
Loaded 100 of 141 files, more files were not shown because too many files have changed in this diff. Show more