diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index 5b92da90d0a..c27abbebe58 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -129,6 +129,7 @@ def setup(hass, config): return True +# pylint: disable=too-few-public-methods class _JsonFmtParser(object): """ Implements a json parser on xpath""" def __init__(self, jsonpath): @@ -139,16 +140,17 @@ class _JsonFmtParser(object): return match[0].value if len(match) > 0 else payload +# pylint: disable=too-few-public-methods class FmtParser(object): """ wrapper for all supported formats """ def __init__(self, fmt): - self._parser = lambda x: x + self._parse = lambda x: x if fmt: if fmt.startswith('json:'): - self._parser = _JsonFmtParser(fmt[5:]) + self._parse = _JsonFmtParser(fmt[5:]) def __call__(self, payload): - return self._parser(payload) + return self._parse(payload) # This is based on one of the paho-mqtt examples: diff --git a/homeassistant/components/sensor/mqtt.py b/homeassistant/components/sensor/mqtt.py index 384d0f8a48a..2bbed97e40c 100644 --- a/homeassistant/components/sensor/mqtt.py +++ b/homeassistant/components/sensor/mqtt.py @@ -46,11 +46,11 @@ class MqttSensor(Entity): self._state_topic = state_topic self._qos = qos self._unit_of_measurement = unit_of_measurement - self._parser = mqtt.FmtParser(state_format) + self._parse = mqtt.FmtParser(state_format) def message_received(topic, payload, qos): """ A new MQTT message has been received. """ - self._state = self._parser(payload) + self._state = self._parse(payload) self.update_ha_state() mqtt.subscribe(hass, self._state_topic, message_received, self._qos) diff --git a/homeassistant/components/switch/mqtt.py b/homeassistant/components/switch/mqtt.py index eeb4551b921..ed99a87868a 100644 --- a/homeassistant/components/switch/mqtt.py +++ b/homeassistant/components/switch/mqtt.py @@ -55,11 +55,11 @@ class MqttSwitch(SwitchDevice): self._payload_on = payload_on self._payload_off = payload_off self._optimistic = optimistic - self._parser = mqtt.FmtParser(state_format) + self._parse = mqtt.FmtParser(state_format) def message_received(topic, payload, qos): """ A new MQTT message has been received. """ - payload = self._parser(payload) + payload = self._parse(payload) if payload == self._payload_on: self._state = True self.update_ha_state()