Fix handling zero values for state_on/state_off (#11264)

pull/11268/head
Zio Tibia 2017-12-21 14:24:19 +01:00 committed by Martin Hjelmare
parent b866687cd7
commit 2e4e3a42cc
1 changed files with 11 additions and 4 deletions

View File

@ -141,10 +141,17 @@ class ModbusRegisterSwitch(ModbusCoilSwitch):
self._verify_register = (
verify_register if verify_register else self._register)
self._register_type = register_type
self._state_on = (
state_on if state_on else self._command_on)
self._state_off = (
state_off if state_off else self._command_off)
if state_on is not None:
self._state_on = state_on
else:
self._state_on = self._command_on
if state_off is not None:
self._state_off = state_off
else:
self._state_off = self._command_off
self._is_on = None
def turn_on(self, **kwargs):