I am having issue of not getting called my state listener everytime, looks like it works for few times initially and then never gets called. Below is the details
.
- I have AppDaemon running on Windows 10 under Bash shell
- My HA is running on same network but on different computer which is running latest Ubuntu.
- What issue I am noticing is the status change for HA entity are not reflected here in my app which has listener set to receive the status updates.
a. It does call my callback for initial few times when status gets updated and then stops and no other status changes causes to call my callback.
b. There is no error in log (console)
c. I have added logging to prove my callback got called as well it sends PushBullet notification, and I don’t see any log or PushBullet notification.
d. My HA runs securely and I have ha_url set to use https but I have not provider cert_path in config file as you see in the code
e. I have automation trigger set in HA which occurs and sends me PushBullet notification which proves there was change in status but not from my AppDaemon app
f. I have set many listeners on different entities and none of them works after few times
g. While development I was just keep saving the python app file and AppDeamon was keep loading to get latest changes and I thought dynamic loading may be an issue and I tried stopping the AppDaemon and running again still same issue.
h. I have most of the sensor where I have listener set are templated sensor, what I mean is I have some kind of device which gives sensor data but that sensor has attributes that I want to monitor so I have set template sensor to pull that specific attribute and that works great in HA to trigger automation. - I have another app which is purely time based (every two hours) which calls my callback without any fail and works flawlessly.
- I have attached config and app file to review the code if I missed anything.
Config file:
[AppDaemon]
ha_url = https://myha.duckdns.org
ha_key = ******
logfile = STDOUT
errorfile = STDERR
app_dir = conf/apps
threads = 10
latitude = xxxxx
longitude = -xxxxx
elevation = xxxx
time_zone = America/Chicago
# Apps
[TestPushBullet]
module = test_pushbullet
class = TestPushBullet
[EcobeeAutomation]
module = ecobee_automation
class = EcobeeAutomation
App code:
import appdaemon.appapi as appapi
import datetime
class EcobeeAutomation(appapi.AppDaemon):
def initialize(self):
self.log("Starting EcobeeAutomation App")
self.listen_state(self.cb_dn_status, "sensor.thermostat_downstairs_current_status")
self.listen_state(self.cb_dn_fan, "sensor.thermostat_downstairs_current_status_fan")
self.listen_state(self.cb_dn_away, "sensor.thermostat_downstairs_away_mode")
self.listen_state(self.cb_dn_temp, "sensor.thermostat_downstairs_set_temp_ac")
def cb_dn_status(self, entity, attribute, old, new, kwargs):
msgStr = "cb_dn_status: old=" + old + ", new=" + new + " at " + datetime.datetime.now().strftime('%H:%M:%S.%f')[:-3]
self.log(msgStr)
self.call_service("notify/pushbullet", title = "AppDaemon", message = msgStr, target = "channel/somechannel")
def cb_dn_fan(self, entity, attribute, old, new, kwargs):
msgStr = "cb_dn_fan: old=" + old + ", new=" + new + " at " + datetime.datetime.now().strftime('%H:%M:%S.%f')[:-3]
self.log(msgStr)
self.call_service("notify/pushbullet", title = "AppDaemon", message = msgStr, target = "channel/somechannel")
def cb_dn_away(self, entity, attribute, old, new, kwargs):
msgStr = "cb_dn_away: old=" + old + ", new=" + new + " at " + datetime.datetime.now().strftime('%H:%M:%S.%f')[:-3]
self.log(msgStr)
self.call_service("notify/pushbullet", title = "AppDaemon", message = msgStr, target = "channel/somechannel")
def cb_dn_temp(self, entity, attribute, old, new, kwargs):
msgStr = "cb_dn_temp: old=" + old + ", new=" + new + " at " + datetime.datetime.now().strftime('%H:%M:%S.%f')[:-3]
self.log(msgStr)
self.call_service("notify/pushbullet", title = "AppDaemon", message = msgStr, target = "channel/somechannel")
Home Assistant sensor definition
- platform: template
sensors:
thermostat_downstairs_current_status:
value_template: '{% if states.climate.downstairs %}{{ states.climate.downstairs.attributes.operation }}{% else %}??{% endif %}'
thermostat_downstairs_current_status_fan:
value_template: '{% if states.climate.downstairs %}{{ states.climate.downstairs.attributes.fan }}{% else %}??{% endif %}'
thermostat_downstairs_away_mode:
value_template: '{% if states.climate.downstairs %}{{ states.climate.downstairs.attributes.away_mode }}{% else %}??{% endif %}'
thermostat_downstairs_hvac_mode:
value_template: '{% if states.climate.downstairs %}{{ states.climate.downstairs.attributes.operation_mode }}{% else %}??{% endif %}'
thermostat_downstairs_set_temp_ac:
value_template: '{% if states.climate.downstairs %}{{ states.climate.downstairs.attributes.target_temp_high }}{% else %}??{% endif %}'
thermostat_downstairs_set_temp_heat:
value_template: '{% if states.climate.downstairs %}{{ states.climate.downstairs.attributes.target_temp_low }}{% else %}??{% endif %}'