Announcement: Occupancy Simulator for AppDaemon v 1.0

Introducing:

#OccuSim !!!

OK, by now you all know that naming isn’t my strong suit, hopefully my coding is better.

This is a fully functional and very versatile occupancy simulator App for AppDaemon, intended to make your house look occupied when you are away. It has too many features to list, but you can check it out here.

As ever, let me have any comments, feedback and questions, I hope this is useful.

1.0.0 (2016-09-16)

Initial Release

8 Likes

This is exactly the reason why I wanted home automation, holiday lighting without timers in wall socket with lamps. I’ve installed Occusim and AppDaemon and it is running perfectly thank you so much.

However, always a however with me :slight_smile: how does the boolean trigger work please? Say I want to put a switch on my HA status pages, how does it work please? does Appdaemon read the boolean name I put in occusim’s config then pass to HA or? As I have this setup and when I switch the switch, nothing actually happens

appdeamon
enable = input_boolean.holiday,off

HA config

input_boolean:
  holiday:
    name: On Holiday
    initial: off
    icon: mdi:car 

groups.yaml

default_view:
  name: Rooms
  view: Yes
  icon: mdi:map-marker
  entities:
    - input_boolean.holiday
    - group.temperature
    - group.sensor_bathroom
    - group.sensor_kitchen
    - device_tracker.mark
    - device_tracker.helen
    - group.cams

Yu can choose to activate OccuSim when the switch is either on or off for flexibility. That is what the second parameter means. The way you have it set, OccuSim will only operate if the switch is off.

ah thanks, so the way I have set it up is correct? so the HA input Boolean will pass onto accusim? would I see anything in the logs to say it has been activated?

Nothing in the logs, but OccuSim will just work when the switch is off.

brilliant thanks. This is working beautifully.

How does it work with current automation’s I have running please? Should I switch them all off when away and just leave this one active?

That depends on what you have setup. They will fight each other so some care is needed. In my case, I left the usual ones in place, e.g. lights on near sunset because that is what the house does when it is occupied. The Occusim piece for me recreates the manual stuff we would do during the evening and at bedtime so there wasn’t much conflict. You can do it any way you like but you just have to be sure you end up with a consistent whole when OccuSim is running.

ok nice one thanks.

Just wanted to say thank you aimc, really good work, this was exactly what I was looking for!

2 Likes

This looks like exactly what I want, but I’m having some issues getting it to work.

No new commits in about 3 years - is anyone still actively using this?
Should I look elsewhere, or should I try to debug?

2022-12-11 16:42:58.932966 WARNING Occupancy Simulator: Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/appdaemon/app_management.py", line 165, in initialize_app
    await utils.run_in_executor(self, init)
  File "/usr/lib/python3.10/site-packages/appdaemon/utils.py", line 337, in run_in_executor
    response = future.result()
  File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/appdaemon/apps/occusim.py", line 32, in initialize
    self.create_events({})
  File "/config/appdaemon/apps/occusim.py", line 68, in create_events
    end = self.parse_time(end_p)
  File "/usr/lib/python3.10/site-packages/appdaemon/utils.py", line 226, in inner_sync_wrapper
    f = run_coroutine_threadsafe(self, coro(self, *args, **kwargs))
  File "/usr/lib/python3.10/site-packages/appdaemon/utils.py", line 346, in run_coroutine_threadsafe
    result = future.result(self.AD.internal_function_timeout)
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 458, in result
    return self.__get_result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
  File "/usr/lib/python3.10/site-packages/appdaemon/adapi.py", line 2068, in parse_time
    return await self.AD.sched.parse_time(time_str, name, aware)
  File "/usr/lib/python3.10/site-packages/appdaemon/scheduler.py", line 727, in parse_time
    return self.make_naive((await self._parse_time(time_str, name))["datetime"]).time()
  File "/usr/lib/python3.10/site-packages/appdaemon/scheduler.py", line 739, in _parse_time
    parts = re.search(r"^(\d+)-(\d+)-(\d+)\s+(\d+):(\d+):(\d+)$", time_str)
  File "/usr/lib/python3.10/re.py", line 200, in search
    return _compile(pattern, flags).search(string)
TypeError: expected string or bytes-like object
2022-12-11 16:42:58.935036 WARNING Occupancy Simulator: ------------------------------------------------------------

It happens when I try to add a line with just an absolute time in it:

  step_night_end: 23:59:59

As usual, five minutes after I post a question, I solve the problem…

While this doesn’t work,

  step_night_end: 23:59:59

This DOES:

  step_night_end: "23:59:59"

Now I get to actually see how Occusim works tomorrow, I hope. The logs claim to have scheduled the events.