Modbus sensor

Hi The solution is to correct
/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/binary_sensor/modbus.py

and add missing def at line 54:

def name(self):
    """Return the name of the sensor."""
    return self._name

@property

it should look like this

class ModbusCoilSensor(BinarySensorDevice):
“”“Modbus coil sensor.”""

def __init__(self, name, slave, coil):
    """Initialize the modbus coil sensor."""
    self._name = name
    self._slave = int(slave) if slave else None
    self._coil = int(coil)
    self._value = None

@property
def name(self):
    """Return the name of the sensor."""
    return self._name

@property
def is_on(self):
    """Return the state of the sensor."""
    return self._value

def update(self):
    """Update the state of the sensor."""
    result = modbus.HUB.read_coils(self._slave, self._coil, 1)
    self._value = result.bits[0]
3 Likes