This Gist describes how to READ and DIPLAY the Manual Schedule of Marstek Venus 3 batteries in Home Assistant using https://github.com/fonske/MarstekVenusV3-modbus-TCP-IP
It is probably applicable to other Marstek batteries with little changes.
**Note: The schedule registers are probably writable but this is not yet implemented. See the TODO list below **
Changelog:
- 2026-01-16 : First version
Manual schedule macros for Marstek Batteries Modbus
A Venus battery provides 6 schedules each controlled using 5 consecutive Modbus 16bit registers starting at address 43100 (Venus 3)
Those 5 registers must be interpreted as follow:
- bitmask for the week days (bit 0=monday, 1=tuesday, ..., 6=sunday)
- the start time encoded as
hour*100+minute - the end time encoded as
hour*100+minute - The operating mode:
- if 100 or more then discharging
- if -100 or less then charging
- if -1 then automatic (i.e. anti-feed)
- 0 is also found in unused schedule entries.
- Other values are unknown behavior
- When charging and discharging, the value must not exceed the allowed limit. For the Venus3 that is typically 2500W for charging and 800W or 2500W for discharging.
- enable (1) or disable (0) the schedule
Also, the 5 registers are always set to 0 in unused entries.
In Home Assistant, the schedule sensor are provided by the Modbus Integration:
The macros provided in that Gist are assuming the registers are following the naming scheme used in MarstekVenusV3-modbus-TCP-IP.
For example, sensor.marstek_m3_schedule_4 contains the 4th schedule of the 3rd battery.
As of 2016-01-16, those registers are not yet declared by MarstekVenusV3-modbus-TCP-IP so you will have to add them yourself as explained below.
Note: You can skip that step if you only care about the demo.
The attached file m1-sensor-definition.yaml contains an example for the 1st battery.
After restarting HA, new entities such as sensor.m1-sensor-definition.yaml should be provided and each one should provide a comma separated list of 5 values.
Step 2 - If it does not already exist, create a directory custom_templates in your Home Assistant configuration directory.
{% import 'marstek_schedule.jinja' as ms %}
{{ ms.dump(rank=1) }}The card should now display the schedule for the 1st battery.
(optional) A demo showing some fake schedules can be created as follow
{% import 'marstek_schedule.jinja' as ms %}
{{ ms.demo() }}The dump() and demo() macros accept a printer argument to specify the macro reponsible for formatting the output.
to_markdownfor Markdown output (default).to_textfor a raw text output
Example: Display the demo with the to_text printer.
{% import 'marstek_schedule.jinja' as ms %}
<pre>
{{ ms.demo(printer=ms.to_text) }}
</pre>You can customize the output by editing to_markdown or to_text or by creating your own printer macro.
Notes for editing:
- Use the action 'homeassistant.reload_custom_templates' after modifying this file.
- Then force the update of the Markdown card by modifying its content.
It can be more convenient to edit a copy of the printer macro directly in a Mardown card.
In that case, the variables referenced by the copy may have to be included as well:
Example: A local copy of to_markdown in a Markdown card may requires markdown_off and markdown_on **
{% from 'marstek_schedule.jinja' import markdown_off, markdown_on %}
{%- macro my_copy_of_to_markdown(s,all=true) -%}
... # here is interesting stuff
{%- endmacro -%}
{{ ms.demo(my_copy_of_to_markdown) }}- Create some HA script to manipulate the schedules (add, remove, enable/disable/toggle).
- Is the firmware robust enough to handle inconsistancies without crashing?
- overlaping schedules, illegal power values, firmware changes (e.g.
anti-feedschedule since v146), ...
- overlaping schedules, illegal power values, firmware changes (e.g.
- Is the firmware robust enough to handle inconsistancies without crashing?
- Implement a proper schedule editor in HA.
- Indicate which schedule is currently active while in manual mode.
Screenshot showing the demo in Markdown and text and a real schedule on a my Venus 3
The
[-xx--x]in each line represents the days from Monday to Sunday.