Announcement: AppDaemon 1.3.4

Sure:

Thanks - so the permissions look good now, but that double db is weird - mine doesn’t do that,

Just for testing I removed the .db from the config file (so changing it to file = /home/hass/.homeassistant/TempApp/switches).

AppDaemon created a new switches.db immidatelly (with just one .db). User root. Updates where not saved. Then changed also permission to Hass/777 and tested again.

Now I actually see that something is happening with the file as the time stamp changes to the time of the latest change.

Changed some switches and let it sit a bit. Did a full sudo reboot to see what happens. And…boom. Seems to work (at least ones).

p.s. looking at the code of the app I see:

  if type == "input_boolean" or type == "input_select" or type == "input_slider" or type == "device_tracker":

Can’t I just remove the "or type == “device_tracker” resulting in device trackers not being saved/restored?

1 Like

Excellent News!

Yes, if you remove that piece the device trackers won;t get restored. Also, you could remove this line:

    self.listen_state(self.state_change, "device_tracker")

To prevent it saving state for the device trackers.

When I get around to it I’ll make a new version that does a better job of telling the program what to save/restore.

Cool. Based on some posts from the forum I’m surprised there is not more talk about this small app to restore the states

1 Like

Mhh, Think there are still issues. Last write was of a few hours ago while the Appdaemon log file shows active state changes in the last few mins…

Did the permissions change?

nope. Still identical to what they where. I see there was a new write to the file at 1:59 (night) while last changes where from about 23:30. Just made some other changes but last write does not change (no restarts in between)

Any ideas on what I can do to get this working properly? Happy to try stuff if you give me some instructions

Would it alternatively not be possible to have the app actually pull these states from exitsting hass history database?

Hi,

Same problem here, it only writes to the db file on creation and even though the log mentions the state change it never updates the db again.
When I do a stat on the db file the last modification date is the creation date.

That’s probably “that” issue with the python dbm modules, see this:

(the solution is at the end).
If you’re not running appdaemon as a docker image, try this:

sudo apt-get install python3-gdbm

Otherwise use the Dockerfile I posted at the end of the linked thread.

Sebastian

1 Like

Installing python3-gdbm did indeed solve the issue.

Thanks Sebastian

Another issue that has started since installing appdaemon is that my home assistant log is filling up with:
homeassistant.core: Unable to find service notify/notify

The timestamps of each line in the log file are the same as the timestamps of the appdaemon/switch reset service events.

One of your apps is probably using the self.notify() function - that defaults to calling the service notify/notify however if you have more than one notification service or have named the one you have that will not work as the service will be called something else. To fix it use a service call for the notification service you actually do have.

thanks that solved it.

1 Like

the logs shows the states being changed in the real time. But on restarts its sets input Boolean and slider to zero. device trackers state are fine. kindly guide me to solve this issue

2017-04-05 17:52:44.864342 INFO AppDaemon Version 1.5.2 starting
2017-04-05 17:52:44.889782 WARNING Unable to connect to Home Assistant, retrying in 5 seconds
2017-04-05 17:52:49.902575 WARNING Unable to connect to Home Assistant, retrying in 5 seconds
2017-04-05 17:52:54.915313 WARNING Unable to connect to Home Assistant, retrying in 5 seconds
2017-04-05 17:52:59.926269 WARNING Unable to connect to Home Assistant, retrying in 5 seconds
2017-04-05 17:53:04.945448 WARNING Unable to connect to Home Assistant, retrying in 5 seconds
2017-04-05 17:53:20.205170 INFO Got initial state
2017-04-05 17:53:20.207272 INFO Loading Module: /home/pi/appdaemon/conf/apps/hello.py
2017-04-05 17:53:20.225457 INFO Loading Module: /home/pi/appdaemon/conf/apps/switch_reset.py
2017-04-05 17:53:20.233513 INFO Loading Object Switch Reset using class SwitchReset from module switch_reset
2017-04-05 17:53:20.406991 INFO App initialization complete
2017-04-05 17:53:20.433484 INFO Connected to Home Assistant 0.41.0
2017-04-05 17:53:20.513760 INFO Switch Reset: AppDaemon restart detected
2017-04-05 17:53:31.881505 WARNING Scheduler clock skew detected - delta = 7.881346940994263 - resetting
2017-04-05 17:53:31.888497 WARNING Scheduler clock skew detected - delta = 1.1116209030151367 - resetting
2017-04-05 17:53:31.896820 WARNING Scheduler clock skew detected - delta = 1.1032979488372803 - resetting
2017-04-05 17:53:31.901899 INFO Switch Reset: Setting switches
2017-04-05 17:53:31.907073 WARNING Scheduler clock skew detected - delta = 1.0930390357971191 - resetting
2017-04-05 17:53:31.913211 INFO Switch Reset: Adding input_boolean.home_bedroom_curtain, setting value to current state (off)
2017-04-05 17:53:31.919770 INFO Switch Reset: Adding device_tracker.amna_amna, setting value to current state (home)
2017-04-05 17:53:31.924654 INFO Switch Reset: Adding device_tracker.ahmad_ahmad, setting value to current state (Office)
2017-04-05 17:53:31.929663 INFO Switch Reset: Adding input_slider.bedroom_curtain, setting value to current state (0.0)

got it working

I had my db in /home/pi/appdaemon/database/switches.db
changed it to /etc/appdaemon/switches.db

I do not know what made it work now.

Have one issue that I am sending values over mqtt. When it restarts it first send zero then it sends the last state value that was stores in the switches.db

Any idea on how to overcome this

I guess I can solve this issue by change the order appdaemon changes the states. Kindly guide me how to change the order of states update

This isn’t an AppDaemon issue I am afraid - when the system starts up is sets the switches to their default values which is why you see the zero. A little while later AppDaemon kicks in and restores the previous state so you then see them switched to the correct value.

Thank you for your response. I solved it through some automation in HA and changing the order appdaemon check for states
Btw Thank you for your contribution. This app solved my issue of reseting the states

changes in switch_reset.py

self.device_db = shelve.open(self.args["file"])
self.listen_event(self.ha_event, "ha_started")
self.listen_event(self.appd_event, "appd_started")
self.listen_state(self.state_change, "input_slider")
self.listen_state(self.state_change, "input_boolean")
self.listen_state(self.state_change, "input_select")

***** self.listen_state(self.state_change, “input_slider”)
self.listen_state(self.state_change, “device_tracker”)