[Bug] SWV-ZFE Water Valve: irrigation_schedule_status sensor state is truncated JSON
Description
The irrigation_schedule_status sensor exposed by Zigbee2MQTT for the SWV-ZFE Water Valve device returns a truncated JSON string as its state in Home Assistant.
Steps to reproduce
- Pair a Water Valve device (e.g. Tuya TS0601
_TZE204_r0jdjrvi) - Trigger an irrigation schedule
- Read the state of the
irrigation_schedule_statussensor in Home Assistant
Expected result
A complete, valid JSON string such as:
{
"actual_end_time": "2026-05-26T13:57:42+02:00",
"actual_irrigation_amount": 1,
"expected_end_time": "2026-05-26T14:19:37+02:00",
"expected_irrigation_amount": 30,
"irrigation_amount_unit": "liter",
"irrigation_mode": "duration",
"schedule_index": 0
}
Actual result
The sensor state is cut off mid-JSON string. Example of what is received:
{'actual_end_time': '2026-05-26T13:57:42+02:00', 'actual_irrigation_amount': 1, 'expected_end_time': '2026-05-26T14:19:37+02:00', 'expected_irrigation_amount': 30, 'irrigation_amount_unit': 'liter', 'irrigation_mode': 'duration', 'schedule_index': 0, 'sc
The string is abruptly truncated at 'sc — the rest of the payload is missing.
Impact
- The
expected_end_timefield (useful for dashboard timers and automations) is present in the truncated portion, but the sensor state cannot be reliably parsed viafrom_jsonbecause the JSON is invalid/incomplete. - Any automation or template relying on this sensor state will fail to parse the JSON.
Possible cause
The MQTT payload for this attribute may exceed the maximum state length allowed by Home Assistant (255 characters), causing it to be truncated. This could be addressed by splitting the value across multiple attributes or exposing individual fields (e.g. irrigation_schedule_expected_end_time) as separate sensor attributes.
Environment
- Zigbee2MQTT version: latest
- Home Assistant: current
- Device: Water Valve (Tuya TS0601, manufacturer
_TZE204_r0jdjrvior similar)
I got the exact same problem. so that it messes up in home assistant. Using a Sonoff SWV-ZFE Valve using 2.11.0. Just updated the valve to 1.0.8.
This is because HA does not support showing long strings
is it possible to expose these as individual sensors? The actual irrigation amount is tied up in this and it would be great to run automations based on the actual water flow.
Worst case could be to use MQTT broker like emqx to manipulate the json to create additional sensors (but also when receiving update on a value from HA then reconstitute the overall json).
But would really prefer having Z2M fiting HA specs.
@vchatela You can create a custom MQTT sensor for this entity.
Here is an example YAML config:
mqtt:
sensor:
- name: "Sonoff Irrigation Schedule Status"
state_topic: "zigbee2mqtt/{FRIENDLY_NAME}"
unique_id: sonoff_irrigation_schedule_status
force_update: true
value_template: >-
{{ value_json["irrigation_schedule_status"] | default('',True) | string | truncate(254, True, '', 0) }}
json_attributes_topic: "zigbee2mqtt/{FRIENDLY_NAME}"
json_attributes_template: >-
{{ value_json["irrigation_schedule_status"] | tojson }}
Change {FRIENDLY_NAME} to your Device Name in Zigbee2Mqtt.
I will create a Pull-Request to add this to the Auto-Configuration for this special Sensors
@vchatela You can create a custom MQTT sensor for this entity.
Here is an example YAML config:
mqtt: sensor: - name: "Sonoff Irrigation Schedule Status" state_topic: "zigbee2mqtt/{FRIENDLY_NAME}" unique_id: sonoff_irrigation_schedule_status force_update: true value_template: >- {{ value_json["irrigation_schedule_status"] | default('',True) | string | truncate(254, True, '', 0) }} json_attributes_topic: "zigbee2mqtt/{FRIENDLY_NAME}" json_attributes_template: >- {{ value_json["irrigation_schedule_status"] | tojson }}Change
{FRIENDLY_NAME}to your Device Name in Zigbee2Mqtt.I will create a Pull-Request to add this to the Auto-Configuration for this special Sensors
The value_template is still a malformed string (because of the 255 char limit), thus json_attributes_topic and json_attributes_template don't work. What I did is to extract the 'schedule_status' form the payload, for example:
mqtt:
sensor:
- name: "Irrigation Status"
state_topic: "zigbee2mqtt/{FRIENDLY_NAME}"
device:
hw_version: 0
identifiers:
- {IDENTIFIER} # check with your payload data
manufacturer: SONOFF
model: Zigbee smart water valve
model_id: SWV-ZFE
name: water irrigation
unique_id: irrigation_status
force_update: true
value_template: >-
{{ value_json["irrigation_schedule_status"]["schedule_status"] | default('unknown',True) }}
json_attributes_topic: "zigbee2mqtt/{FRIENDLY_NAME}"
json_attributes_template: >-
{{ value_json["irrigation_schedule_status"] | tojson }}
Then, you can use a helper in HA to extract all other state_attr
Confirming the issue & temporary workaround
Home Assistant has a hard limit of 255 characters for entity states. When Zigbee2MQTT pushes a long JSON string like irrigation_schedule_status as a standard sensor state, Home Assistant truncates it, breaking valid JSON formatting.
Regarding the exposed sensors:
x_real_time_irrigation_volumeis misleadingly named. It actually behaves like a daily total consumption (it updates every 5 minutes and resets at midnight), rather than showing real-time volume per irrigation cycle;actual_irrigation_amountinside irrigation_schedule_status is the actual real-time water consumption that resets to zero at each new irrigation cycle.
It would be ideal if Zigbee2MQTT exposed actual_irrigation_amount as a standalone sensor.
In the meantime, if anyone needs to extract the real-time value from the truncated state (e.g., using custom:template-entity-row or a template sensor), you can use this extraction logic:
{% set value = states('sensor.irrigazione_giardino_irrigation_schedule_status') %}
{% if 'actual_irrigation_amount' in value %}
{{ value.split("'actual_irrigation_amount': ")[1].split(',')[0] | trim }} L
{% else %}
N/D
{% endif %}
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days