Skip to content

Conversation

@sevorl
Copy link
Contributor

@sevorl sevorl commented Sep 3, 2025

Overview

This PR implements a comprehensive remote lock control system with two components:

  1. Modbus Remote Lock Status Sensor (always available) - reads lock status from register 259
  2. Physical Lock Control via GPIO Relay (optional with build flag) - controls wallbox lock hardware

Key Features

🔍 Core Functionality

  • Remote lock status sensor from Modbus register 259
  • Optional physical lock control via GPIO relay
  • Home Assistant auto-discovery for both entities
  • Build flag system (ENABLE_LOCK_RELAY) for optional compilation
  • Fail-safe design: defaults to locked on ESP32 power loss

🏗️ Build Environments

Standard (sensor only): esp32, lilygo, dummy
With relay control: esp32_with_lock_relay, lilygo_with_lock_relay, dummy_with_lock_relay

🏠 Home Assistant Integration

  • Binary Sensor: binary_sensor.{device}_remote_lock_status (always available)
  • Lock Entity: lock.{device}_lock_control (with relay builds only)

📖 Documentation

  • Complete implementation guide
  • Relay wiring guide with diagrams
  • Benefits explanation (fail-safe behavior)
  • Migration instructions

Safety & Reliability

✅ Fail-safe default: locks when ESP32 loses power
✅ Conditional compilation for memory efficiency
✅ No impact on existing installations
✅ Comprehensive error handling

Ready for testing and deployment!

Features added:
- Modbus remote lock status sensor (always available from register 259)
- Optional physical lock control via GPIO relay (with ENABLE_LOCK_RELAY flag)
- Home Assistant auto-discovery for both binary sensor and lock entities
- Build flag system for optional relay control compilation
- GPIO pin configuration (GPIO25 for ESP32, GPIO18 for LILYGO)
- Fail-safe default to locked state on ESP32 power loss
- Comprehensive documentation including wiring guide

Build environments:
- Standard builds: esp32, lilygo, dummy (Modbus sensor only)
- Relay builds: esp32_with_lock_relay, lilygo_with_lock_relay, dummy_with_lock_relay

Documentation:
- Remote lock status sensor and lock control implementation guide
- Physical lock control benefits and use cases
- Detailed relay wiring guide with diagrams and safety notes

Technical details:
- New LockController component with singleton pattern
- Board abstraction updated for conditional GPIO pin support
- MQTT integration with Home Assistant lock entity discovery
- Error handling with safe defaults (unlocked state on Modbus read failure)
- Conditional compilation for memory efficiency without relay hardware
@sevorl
Copy link
Contributor Author

sevorl commented Sep 3, 2025

IMG_5302
IMG_5301

This is how it looks when wired up.

The other side of the relay would connect to the remote lock connector of the wallbox.

In Home Assistant, this will add a control element and a (modbus) sensor like this:

image

I tested with the Lilygo board and a regular esp32.

@sevorl sevorl closed this Oct 17, 2025
@sevorl
Copy link
Contributor Author

sevorl commented Oct 17, 2025

The remote lock status sensor does not report correct values.
After using this for a bit, it turned out that the extra physical lock does not provide a lot of benefits over changing the current limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant