From bab53a1c9445da5729bbebd5a030fda6be3258b3 Mon Sep 17 00:00:00 2001 From: gertdb <42268196+gertdb@users.noreply.github.com> Date: Sun, 10 Mar 2019 16:08:29 +0100 Subject: [PATCH] Modbus write_register accept single value and array (#21621) * Update __init__.py * Update services.yaml --- homeassistant/components/modbus/__init__.py | 4 +++- homeassistant/components/modbus/services.yaml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/modbus/__init__.py b/homeassistant/components/modbus/__init__.py index 182e3dc28fa4ac..0500a904cb9c86 100644 --- a/homeassistant/components/modbus/__init__.py +++ b/homeassistant/components/modbus/__init__.py @@ -60,7 +60,9 @@ vol.Optional(ATTR_HUB, default=DEFAULT_HUB): cv.string, vol.Required(ATTR_UNIT): cv.positive_int, vol.Required(ATTR_ADDRESS): cv.positive_int, - vol.Required(ATTR_VALUE): vol.All(cv.ensure_list, [cv.positive_int]) + vol.Required(ATTR_VALUE): vol.Any( + cv.positive_int, + vol.All(cv.ensure_list, [cv.positive_int])) }) SERVICE_WRITE_COIL_SCHEMA = vol.Schema({ diff --git a/homeassistant/components/modbus/services.yaml b/homeassistant/components/modbus/services.yaml index 0fd9e5a49e7385..48e9e815aaa5e9 100644 --- a/homeassistant/components/modbus/services.yaml +++ b/homeassistant/components/modbus/services.yaml @@ -9,4 +9,4 @@ write_register: fields: address: {description: Address of the holding register to write to., example: 0} unit: {description: Address of the modbus unit., example: 21} - value: {description: Value to write., example: 0} + value: {description: Value (single value or array) to write., example: 0 or [4,0]}