Hi,
Following the documentation I found that I can register an MQTT device as:
configuration.yaml
sensor bedroom:
platform: mqtt
state_topic: "home/bedroom/temperature"
name: "MQTT Sensor 1"
Right now I trying to declare a simple app to monitor (log) the temperature (example from the documentation)
bedroom_temperature.py
import appdaemon.plugins.hass.hassapi as hass
class BedroomTemperature(hass.Hass):
def initialize(self):
self.log('BedroomTemperature.initialize')
self.listen_state(self.state_change, "sensor.bedroom")
def state_change(self, entity, attribute, old, new, kwargs):
self.log('BedroomTemperature.state_change: '+ new)
apps.yaml
bedroom:
module: bedroom_temperature
class: BedroomTemperature
but I get the following error during its initialization: … “Entity sensor.bedroom not found in AppDaemon”
2019-07-19 15:39:58.465360 INFO AppDaemon: Initializing app bedroom using class BedroomTemperature from module bedroom_temperature
2019-07-19 15:39:58.466493 INFO bedroom: BedroomTemperature.initialize
2019-07-19 15:39:58.466588 WARNING AppDaemon: bedroom: Entity sensor.bedroom not found in AppDaemon
If I change the listen_state from sensor.bedroom to sensor bedroom I don get the error, but the callback state_change it’s never called when I inject manually a new value to MQTT topic.
Any suggestion of what I’m doing wrong? or did I misunderstand something about MQTT+HA?
Notes:
- First day using HA
- I’m using Mosquito with its default configuration
This is my complete configuration.yaml file
default_config:
# 1 New content added
mqtt:
broker: 127.0.0.1
tts:
- platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
# 2 New content added
sensor bedroom:
platform: mqtt
state_topic: "home/bedroom/temperature"
name: "MQTT Sensor 1"