A comprehensive Home Assistant custom integration for the Marstek Venus E battery energy storage system. This integration provides full local control and monitoring via the device's UDP JSON-RPC API.
-
- 2.1. HACS (Recommended)
- 2.2. Manual Installation
-
- 3.1. Adding the Integration
- 3.2. Configuring Manual Schedules
- 3.2.1. Method 1: Through the UI (Recommended for Single Slots)
- 3.2.2. Method 2: Through Automations (Recommended for Multiple Slots)
-
- 4.1. Sensors
- 4.1.1. Battery
- 4.1.2. Solar PV
- 4.1.3. Grid & Energy
- 4.1.4. CT Meter (if installed)
- 4.1.5. System
- 4.2. Binary Sensors
- 4.3. Select Entities
- 4.1. Sensors
-
- 6.1. Battery Status Card
- 6.2. Energy Flow Card
- 6.3. Complete Dashboard
-
- 9.1. Integration Not Appearing
- 9.2. Cannot Connect to Device
- 9.3. Missing Sensors
- 9.4. Enable Debug Logging
✅ Automatic Device Discovery
- UDP broadcast discovery on local network
- Automatic device detection during setup
- Manual IP entry fallback option
✅ Complete Monitoring
- Battery status (SOC, temperature, capacity, charge/discharge state)
- Solar PV generation (power, voltage, current)
- Grid power flow (import/export)
- Energy totals (PV, grid, load)
- CT clamp readings (3-phase power monitoring)
- WiFi signal strength
✅ Full Control
- UI Mode Selector: Change modes directly from Home Assistant UI
- UI Schedule Configuration: Set up charging/discharging schedules through UI (no YAML needed)
- Operating Modes: Auto (Self-Consuming), AI, Manual, Passive
- Real-time mode changes
- Up to 10 time-based schedules (slots 0-9)
- Automation Support: Configure all 10 schedules via Home Assistant automations
✅ Home Assistant Integration
- Native Energy Dashboard support
- Service calls for automation
- Select entity for easy mode switching
- Options flow for schedule configuration
- 5-minute polling interval (configurable via options)
- Non-blocking async implementation
- Comprehensive device information
- Multi-language support (English, French)
- Open HACS in Home Assistant
- Click the three dots in the top right corner
- Select "Custom repositories"
- Add this repository URL:
https://github.com/yuyuki/hacs_marstek_venus_e - Category:
Integration - Click "Add"
- Find "Marstek Venus E" in HACS and click "Download"
- Restart Home Assistant
- Copy the
custom_components/marstek_venus_efolder to your Home Assistant'scustom_componentsdirectory - Restart Home Assistant
- Go to Settings → Devices & Services
- Click + Add Integration
- Search for "Marstek Venus E"
- Automatic Discovery:
- The integration scans your network for Marstek devices
- Found devices are displayed in a list
- Select your device and click Submit
- Manual Configuration (if no devices found):
- Select "Enter IP manually"
- Enter device IP address, port (30000), and optional BLE MAC
- Click Submit
After adding the integration, you can configure charging/discharging schedules in two ways:
- Go to Settings → Devices & Services
- Find Marstek Venus E integration
- Click Configure (gear icon)
- Select "Configure Manual Mode Schedule"
- Set up your schedule:
- Time Slot: Choose 0-9 (you can create 10 different schedules)
- Start/End Time: When the schedule runs
- Active Days: Select days of the week
- Power: Negative to charge (-1000W), positive to discharge (+1000W)
- Enable: Toggle to activate
- Click Submit
Configure all 10 schedule slots automatically when you switch to Manual mode using Home Assistant automations. This is the easiest way to set up complex schedules!
Quick Start:
- Copy the example automation from
example_automation.yamlin this repository - Paste it into your Home Assistant automations
- Adjust times, power levels, and days to match your needs
- Save and test by switching to Manual mode!
Benefits:
- Configure all 10 slots in one action
- Different schedules for weekdays vs weekends
- Dynamic schedules based on battery level, weather, or electricity prices
- Seasonal adjustments (winter vs summer patterns)
See the Manual Mode Automation Guide for detailed examples and best practices.
sensor.marstek_venus_e_battery_state_of_charge- Battery SOC (%)sensor.marstek_venus_e_battery_temperature- Battery temperature (°C)sensor.marstek_venus_e_battery_capacity- Current battery capacity (Wh)sensor.marstek_venus_e_battery_rated_capacity- Rated battery capacity (Wh)sensor.marstek_venus_e_battery_power- Battery charging/discharging power (W)
sensor.marstek_venus_e_pv_power- Solar generation power (W)sensor.marstek_venus_e_pv_voltage- PV voltage (V)sensor.marstek_venus_e_pv_current- PV current (A)
sensor.marstek_venus_e_grid_power- Grid import/export power (W)sensor.marstek_venus_e_offgrid_power- Off-grid power (W)sensor.marstek_venus_e_total_pv_energy- Total PV energy generated (kWh)sensor.marstek_venus_e_total_grid_export_energy- Total energy exported to grid (Wh)sensor.marstek_venus_e_total_grid_import_energy- Total energy imported from grid (Wh)sensor.marstek_venus_e_total_load_energy- Total load consumption (kWh)
sensor.marstek_venus_e_phase_a_power- Phase A power (W)sensor.marstek_venus_e_phase_b_power- Phase B power (W)sensor.marstek_venus_e_phase_c_power- Phase C power (W)sensor.marstek_venus_e_total_ct_power- Total CT power (W)
sensor.marstek_venus_e_wifi_signal_strength- WiFi RSSI (dBm)sensor.marstek_venus_e_wifi_ssid- Connected WiFi networksensor.marstek_venus_e_operating_mode- Current operating mode
binary_sensor.marstek_venus_e_battery_charging- Battery charging statusbinary_sensor.marstek_venus_e_battery_discharging- Battery discharging statusbinary_sensor.marstek_venus_e_ct_meter_connected- CT meter connection status
select.operating_mode- Change operating mode (Auto, AI, Manual, Passive)- Auto: Self-consumption optimization
- AI: Intelligent mode based on usage patterns
- Manual: Time-based schedules (configure via integration options)
- Passive: Fixed power target mode
Set the operating mode of your system.
Modes:
Auto- Automatic operation based on device algorithmsAI- AI-optimized operationManual- Time-based schedule controlPassive- Follow a specific power target
service: marstek_venus_e.set_mode
data:
mode: "Auto"Configure a manual charging/discharging schedule.
service: marstek_venus_e.set_manual_schedule
data:
time_num: 0 # Time slot 0-9 (10 slots available!)
start_time: "09:00"
end_time: "17:00" # MUST be greater than start_time
week_set: 127 # All days (byte-based: 1=Mon, 2=Tue, 4=Wed, 8=Thu, 16=Fri, 32=Sat, 64=Sun)
mode: "Charging" # "Charging" or "Discharging"
power: 500 # 100-2500W magnitude (always positive)
enable: trueImportant Constraints:
end_timemust be greater thanstart_timemodemust be "Charging" (negative power) or "Discharging" (positive power)powermagnitude must be between 100 and 2500 watts (always positive)week_setuses byte-based bitmask
Week Set Bitmask:
- Monday: 1
- Tuesday: 2
- Wednesday: 4
- Thursday: 8
- Friday: 16
- Saturday: 32
- Sunday: 64
- All days: 127 (sum of all)
- Weekdays only: 31
- Weekend only: 96
Set passive mode with a power target.
service: marstek_venus_e.set_passive_mode
data:
power: 2000 # Target power in watts
cd_time: 3600 # Countdown in seconds (0 = indefinite)type: vertical-stack
cards:
- type: gauge
entity: sensor.marstek_venus_e_battery_state_of_charge
name: Battery Level
min: 0
max: 100
needle: true
severity:
green: 60
yellow: 30
red: 0
- type: entities
entities:
- entity: sensor.marstek_venus_e_battery_power
name: Battery Power
- entity: sensor.marstek_venus_e_battery_temperature
name: Temperature
- entity: binary_sensor.marstek_venus_e_battery_charging
name: Charging
- entity: binary_sensor.marstek_venus_e_battery_discharging
name: Discharging
- entity: sensor.marstek_venus_e_battery_capacity
name: Current Capacitytype: vertical-stack
cards:
- type: horizontal-stack
cards:
- type: statistic
entity: sensor.marstek_venus_e_pv_power
name: Solar
icon: mdi:solar-power
stat_type: mean
period:
calendar:
period: day
- type: statistic
entity: sensor.marstek_venus_e_grid_power
name: Grid
icon: mdi:transmission-tower
stat_type: mean
period:
calendar:
period: day
- type: statistic
entity: sensor.marstek_venus_e_battery_power
name: Battery
icon: mdi:battery
stat_type: mean
period:
calendar:
period: day
- type: entities
title: Energy Today
entities:
- entity: sensor.marstek_venus_e_total_pv_energy
name: PV Generated
- entity: sensor.marstek_venus_e_total_grid_import_energy
name: Grid Import
- entity: sensor.marstek_venus_e_total_grid_export_energy
name: Grid Export
- entity: sensor.marstek_venus_e_total_load_energy
name: Total Consumptiontitle: Marstek Venus E
type: vertical-stack
cards:
# Header with mode
- type: entities
entities:
- entity: sensor.marstek_venus_e_operating_mode
name: Operating Mode
# Battery gauge
- type: gauge
entity: sensor.marstek_venus_e_battery_state_of_charge
name: Battery
min: 0
max: 100
needle: true
severity:
green: 60
yellow: 30
red: 0
# Power flow
- type: horizontal-stack
cards:
- type: entity
entity: sensor.marstek_venus_e_pv_power
name: Solar
icon: mdi:solar-power
- type: entity
entity: sensor.marstek_venus_e_grid_power
name: Grid
icon: mdi:transmission-tower
- type: entity
entity: sensor.marstek_venus_e_battery_power
name: Battery
icon: mdi:battery
# Energy totals
- type: entities
title: Energy
entities:
- sensor.marstek_venus_e_total_pv_energy
- sensor.marstek_venus_e_total_grid_import_energy
- sensor.marstek_venus_e_total_grid_export_energy
- sensor.marstek_venus_e_total_load_energy
# Mode control buttons
- type: horizontal-stack
cards:
- type: button
name: Auto
icon: mdi:autorenew
tap_action:
action: call-service
service: marstek_venus_e.set_mode
data:
mode: "Auto"
- type: button
name: AI
icon: mdi:brain
tap_action:
action: call-service
service: marstek_venus_e.set_mode
data:
mode: "AI"
- type: button
name: Manual
icon: mdi:clock-outline
tap_action:
action: call-service
service: marstek_venus_e.set_mode
data:
mode: "Manual"Add your Marstek Venus E to Home Assistant's Energy Dashboard:
- Go to Settings → Dashboards → Energy
- Click Add Consumption:
- Select
sensor.marstek_venus_e_total_load_energy
- Select
- Click Add Solar Production:
- Select
sensor.marstek_venus_e_total_pv_energy
- Select
- Click Add Battery:
- Energy in:
sensor.marstek_venus_e_total_grid_import_energy - Energy out:
sensor.marstek_venus_e_total_grid_export_energy
- Energy in:
- Click Add Grid Consumption:
- Grid import:
sensor.marstek_venus_e_total_grid_import_energy
- Grid import:
- Click Add Return to Grid:
- Grid export:
sensor.marstek_venus_e_total_grid_export_energy
- Grid export:
The best way to use Manual mode is to automatically configure all 10 schedule slots when you switch to it:
automation:
- alias: "Marstek - Auto-Configure on Manual Mode"
trigger:
- platform: state
entity_id: select.operating_mode
to: "Manual"
action:
# Slot 0: Night charging
- service: marstek_venus_e.set_manual_schedule
data:
time_num: 0
start_time: "01:00"
end_time: "06:00"
week_set: 127 # All days
mode: "Charging"
power: 2500 # Charge at 2500W (maximum)
enable: true
# Slot 1: Morning peak discharge (weekdays)
- service: marstek_venus_e.set_manual_schedule
data:
time_num: 1
start_time: "07:00"
end_time: "09:00"
week_set: 31 # Weekdays only
mode: "Discharging"
power: 700 # Discharge at 700W
enable: true
# Slot 2: Evening peak discharge
- service: marstek_venus_e.set_manual_schedule
data:
time_num: 2
start_time: "18:00"
end_time: "22:00"
week_set: 127 # All days
mode: "Discharging"
power: 750 # Discharge at 750W
enable: true
# ... configure remaining slots 3-9 as needed📖 See the Manual Mode Automation Guide for:
- Complete 10-slot configuration examples
- Seasonal schedules (winter vs summer)
- Dynamic schedules based on battery level
- Price-based charging strategies
- Weekend vs weekday patterns
automation:
- alias: "Charge Battery at Night"
trigger:
- platform: time
at: "23:00:00"
action:
- service: marstek_venus_e.set_manual_schedule
data:
time_num: 0
start_time: "01:00"
end_time: "07:00" # Must be > start_time
week_set: 127 # Every day
power: 2500 # Maximum (2500W)
enable: true
- service: marstek_venus_e.set_mode
data:
mode: "Manual"automation:
- alias: "Auto Mode During Day"
trigger:
- platform: time
at: "07:00:00"
action:
- service: marstek_venus_e.set_mode
data:
mode: "Auto"automation:
- alias: "Low Battery Warning"
trigger:
- platform: numeric_state
entity_id: sensor.marstek_venus_e_battery_state_of_charge
below: 20
action:
- service: notify.mobile_app
data:
title: "Low Battery"
message: "Marstek battery is at {{ states('sensor.marstek_venus_e_battery_state_of_charge') }}%"automation:
- alias: "Store Excess Solar"
trigger:
- platform: numeric_state
entity_id: sensor.marstek_venus_e_pv_power
above: 2000
condition:
- condition: numeric_state
entity_id: sensor.marstek_venus_e_battery_state_of_charge
below: 95
action:
- service: marstek_venus_e.set_passive_mode
data:
power: -2000 # Charge battery
cd_time: 0 # Until solar drops- Ensure you've restarted Home Assistant after installation
- Check
custom_components/marstek_venus_e/manifest.jsonexists - Review Home Assistant logs for errors
- Verify the device IP address is correct
- Ensure device and Home Assistant are on the same network
- Check if port 30000 (UDP) is accessible
- Try pinging the device:
ping <device_ip> - Verify the device is powered on and connected to WiFi
Some sensors depend on hardware configuration:
- CT sensors require CT clamps to be installed
- Check that the device firmware supports all API endpoints
Add to configuration.yaml:
logger:
default: info
logs:
custom_components.marstek_venus_e: debugThen check logs at Settings → System → Logs
This integration uses the Marstek Device Local API (UDP JSON-RPC). For complete API documentation, refer to the local API reference document in doc/MarstekDeviceOpenApi 2.0.pdf.
- Issues: GitHub Issues #- Discussions: GitHub Discussions
- Home Assistant Community: Community Forum
Contributions are welcome. This repository is a Home Assistant custom integration, so the best changes are usually small, focused, and easy to validate locally before opening a pull request.
- Fork or clone the repository.
- Open the project in VS Code or your editor of choice.
- Make your changes under
custom_components/marstek_venus_e/. - Keep the code style consistent with the existing files.
- Update
README.md, tests, or docs when behavior changes.
If you are adding or changing an entity, service, or config flow, check the corresponding file in custom_components/marstek_venus_e/ and keep the names, translations, and platform registration aligned.
This project uses pytest for automated tests. The test suite is split into individual scripts under tests/ so you can run either a single scenario or the whole suite.
Run all tests:
pytest testsRun a specific test script:
python tests/test_api_functions.py
python tests/test_discovery.py
python tests/test_es_get_status.py --ip 192.168.0.225If you want a more detailed guide for the available scripts, see tests/README_TESTS.md.
For real device testing, you can run Home Assistant in a container and mount this integration into the container’s /config/custom_components directory.
When you mount a local Home Assistant config directory to /config, that mount replaces the /config directory from the image. If you want to use a persistent config directory and the local development version of this integration, mount both paths:
- Your Home Assistant config directory to
/config. - This repository's integration folder to
/config/custom_components/hacs_marstek_venus_e.
The official image is:
homeassistant/home-assistant
To download it before you run the container, use:
docker pull homeassistant/home-assistant:stableWith Podman, the equivalent command is:
podman pull docker.io/homeassistant/home-assistant:stable
podman build -f docker/Dockerfile -t marstek-ha .This pulls the stable tag from Docker Hub, which is the version most people use for local testing.
podman run -d \
--name homeassistant \
--network=host \
-e TZ=Europe/Brussels \
-v /path/to/your/config:/config \
-v /path/to/this/repo/custom_components/hacs_marstek_venus_e:/config/custom_components/hacs_marstek_venus_e \
homeassistant/home-assistant:stableUse --network=host when you need the container to discover your local Marstek device by UDP broadcast.
On Windows, Podman usually runs the container inside a Linux VM, so the simplest setup is to use a named volume or a bind mount from a directory that Podman can access.
podman machine init
podman machine start
podman run -d `
--name homeassistant `
--network=host `
-e TZ=Europe/Brussels `
-v C:\ha-config:/config `
-v E:\Projets\hacs_marstek_venus_e\custom_components\hacs_marstek_venus_e:/config/custom_components/hacs_marstek_venus_e `
homeassistant/home-assistant:stableNotes for Windows:
- Use a path that Podman can share with the VM.
- If the bind mount is awkward, copy the integration folder into your Home Assistant config directory instead.
- If UDP discovery does not work in container mode, prefer a manual IP setup for the first test pass.
- Start Home Assistant in the container.
- Copy or mount the integration into
custom_components/hacs_marstek_venus_e. - Add the integration in Home Assistant.
- Validate discovery and status sensors.
- Use the service calls and manual schedule features to confirm write operations.
Contributions are usually easiest to review when they include:
- A clear description of the behavior change.
- A test case or test script update.
- Any README or documentation updates needed for new behavior.
This project is licensed under the MIT License - see the LICENSE file for details.
This is an unofficial integration. It is not affiliated with or endorsed by Marstek. Use at your own risk.
- Integration developed for Home Assistant
- Based on Marstek Device Open API documentation
- Inspired by the Home Assistant community
Enjoy your Marstek Venus E integration! ⚡🔋
