Occusim - has something changed?

Hello @aimc

I have just been updating various HA bits after ignoring things for a while. In my AD error log I am now getting

2018-06-06 07:23:41.979177 WARNING AppDaemon: ------------------------------------------------------------
2018-06-06 07:23:41.979750 WARNING AppDaemon: Unexpected error running initialize() for Occupancy Simulator
2018-06-06 07:23:41.980130 WARNING AppDaemon: ------------------------------------------------------------
2018-06-06 07:23:41.983865 WARNING AppDaemon: Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.5/site-packages/appdaemon/appdaemon.py", line 1513, in init_object
    init()
  File "/home/pi/appdaemon/apps/03_occusim/occusim.py", line 33, in initialize
    self.create_events({})
  File "/home/pi/appdaemon/apps/03_occusim/occusim.py", line 66, in create_events
    start = self.parse_time(start_p)
  File "/home/pi/.local/lib/python3.5/site-packages/appdaemon/appapi.py", line 277, in parse_time
    return self.AD.parse_time(time_str, name)
  File "/home/pi/.local/lib/python3.5/site-packages/appdaemon/appdaemon.py", line 1052, in parse_time
    parsed_time = (self.sunset() - datetime.timedelta(
  File "/home/pi/.local/lib/python3.5/site-packages/appdaemon/appdaemon.py", line 1008, in sunset
    return datetime.datetime.fromtimestamp(self.calc_sun("next_setting"))
  File "/home/pi/.local/lib/python3.5/site-packages/appdaemon/appdaemon.py", line 840, in calc_sun
    return self.sun[type_].timestamp()
KeyError: 'next_setting'

Looking at github, it looks like Occusim hasn’t been updated for a few months, so just wanted to check to see if I am missing something obvious?

did you update appdaemon?
from which version to which version?
if you have updated from 2 to 3 you need to take care of the breaking changes.

and the occusim examples are not really up to date, because if i remember correctly from other problems, you need to put times between quotes.

No, I didn’t update AD, as I have been using AD3 for some time. (Though it may well be the case that that error has been present for a while and I only just noticed it.)

Now you mention it - how can one tell what version of AD is running? My recollection is that I am on 3.0.0, though I see that 3.0.1 is now current …

its in the logs when you restart AD.
but i think you need to look at the yaml, you probably dont have all time elements between quotes so like “00:00:00”

Thanks - that does indeed seem to have sorted it. I had a mix-up of no-quotes and single quotes on clock times.

Though it seems happy enough with no quotes around time intervals eg step_dusk_start: sunset - 00:45:00

its yaml.

yaml tries to interpret what you put there.

a single time like 00:45:00 gets translated to a time object in python.
and because AD didnt have yaml in the past it expects a string.

but “sunset - 00:45:00” cant be interpreted as a time object, so its a string anyway.

but im glad you worked it out, and it was then indeed something you had there for quite some time :wink: