Update code

This commit is contained in:
Fabian Affolter 2017-04-30 23:11:34 +02:00
parent 3bef0ad30f
commit 07112d8772
No known key found for this signature in database
GPG key ID: DDF3D6F44AAB1336
4 changed files with 18 additions and 18 deletions

View file

@ -22,7 +22,7 @@ This example follows a topic on MQTT and updates the state of an entity to the l
import homeassistant.loader as loader
# The domain of your component. Should be equal to the name of your component.
DOMAIN = "hello_mqtt"
DOMAIN = 'hello_mqtt'
# List of component names (string) your component depends upon.
DEPENDENCIES = ['mqtt']
@ -33,14 +33,14 @@ DEFAULT_TOPIC = 'home-assistant/hello_mqtt'
def setup(hass, config):
"""Setup the Hello MQTT component."""
"""Set up the Hello MQTT component."""
mqtt = loader.get_component('mqtt')
topic = config[DOMAIN].get('topic', DEFAULT_TOPIC)
entity_id = 'hello_mqtt.last_message'
# Listener to be called when we receive a message.
def message_received(topic, payload, qos):
"""A new MQTT message has been received."""
"""Handle new MQTT messages."""
hass.states.set(entity_id, payload)
# Subscribe our listener to a topic.