Occusim Question

I am trying to get Occusim up and running and I can’t get it to fire the event. I don’t see anything in the logs that look like errors or point me in a direction. Below are my config files and logs.

editt: I can’t seem to get the formatting to show properly, sorry

Appdaemon.yaml
AppDaemon:
logfile: STDOUT
errorfile: STDERR
threads: 10
time_zone: America/Chicago
HASS:
ha_url: http://xxxxxx:8123
ha_key: xxxxxx
HADashboard:
dash_url: http://xxxxxxx:5050
# Apps
hello_world:
module: hello
class: HelloWorld
Occupancy Simulator:
module: occusim
class: OccuSim

Occusim appdaemon.yaml:
Occupancy Simulator:
module: occusim
class: OccuSim
log: ‘1’
enable: on
random_gameroom_name: Evening_Gameroom
random_gameroom_start: 04:00:00
random_gameroom_end: 12:30:00
random_gameroom_minduration: 00:01:00
random_gameroom_maxduration: 00:01:00
random_gameroom_number: ‘30’
random_gameroom_on_1: light.gameroom
random_gameroom_off_1: light.gameroom

Log:

date stream content
2017-08-23 10:35:32 stdout 2017-08-23 10:35:32.720823 INFO New dashboard connected: Main Panel
2017-08-23 10:35:28 stdout 2017-08-23 10:35:28.670849 INFO Connected to Home Assistant 0.51.2
2017-08-23 10:35:28 stdout 2017-08-23 10:35:28.655854 INFO Starting dashboard
2017-08-23 10:35:28 stdout 2017-08-23 10:35:28.655371 INFO App initialization complete
2017-08-23 10:35:28 stdout 2017-08-23 10:35:28.653632 INFO Loading Object Occupancy Simulator using class OccuSim from module occusim
2017-08-23 10:35:28 stdout 2017-08-23 10:35:28.652563 INFO Loading Module: /conf/apps/occusim.py
2017-08-23 10:35:28 stdout 2017-08-23 10:35:28.652262 INFO hello_world: You are now ready to run Apps!
2017-08-23 10:35:28 stdout 2017-08-23 10:35:28.650176 INFO hello_world: Hello from AppDaemon
2017-08-23 10:35:28 stdout 2017-08-23 10:35:28.476937 INFO Loading Object hello_world using class HelloWorld from module hello
2017-08-23 10:35:28 stdout 2017-08-23 10:35:28.474687 INFO Loading Module: /conf/apps/hello.py
2017-08-23 10:35:28 stdout 2017-08-23 10:35:28.473547 INFO Got initial state
2017-08-23 10:35:28 stdout 2017-08-23 10:35:28.289342 INFO Configuration read from: /conf/appdaemon.yaml
2017-08-23 10:35:28 stdout 2017-08-23 10:35:28.289008 INFO AppDaemon Version 2.0.3 starting

Lease fix the formatting or we can’t help you figure this out …

Also, the occusim arms need to be in the same file as the AppDaemon config not a separate file.

I originally had the two files combines but it caused an error and this was the only way not get an error.

Even using the cltr+shft+c formatting, it doesn’t seem to want to format so I pasted a few screen shots instead.

Thanks for your help.

appdaemon.yaml:
image

error message with the occusim on the same AppDaemon.yaml file.
image

To format code paste it in the edit box, select it with a spare line either end and press the </> button on the editor menu i.e. just above where i’m writing this.

The reason it was “working” when you separated the files is because the OccuSim file was being ignored.

The problem is that when defining a random, you need to give it a fixed event as start and stop, not times. So you need to define 2 steps, one for the beginning of the period, one for the end - e.g.:

step_evening_name: Evening
step_evening_start: 16:00:00

step_evening_name: Night
step_evening_start: 23:59:59

Then use Evening and Night instead of 04:00:00 and 12:30:00.

Couple of other points, the app uses military time, so as you have the times it would come on at 4am and stop at 12:30 pm , I suspect that’s not what you want so I corrected the times above.

Also, there is a limitation in that you can;t schedule events for the next day,so I adjusted that above also.

Ok. I’ll define the start and end times.

I was actually up at 4am this morning so when I was trying to get it work. When I get this to working I’ll have military time for the times I need.

Thank you.

1 Like

I was able to get it working. Thank you. I have a few questions.

Can Occusim use switches or do I need to setup scenes instead?

Also when I look at the log times they are several hours in the future and this effects the timing that I have to put. If i use the local time that I want an event to fire I get an error message “Ignoring, event in the past.” For example, it currently is 1:48PMCST but my log shows 18:48. I’ve searched for additional TZ files on my server but they all show the correct timezone. I have added time_zone: America/Chicago but no effect, also the other containers I have running are not effect and show the correct time.

Thanks!

You can use individual switches.

Correct - you can use anything that responds to homeassistant/turn_on and homeassistant/turn_off.

Regarding the timezone thing - I’m not sure, i’m trying to track that one down. Are you using Docker?

Thanks. I was able to get my switches working.

I am using Docker.

1 Like

I have a promising looking fix on the way with the help of @SupahNoob - if it pans out, should be in the next version.

1 Like

Great!

I was able to get everything working and it worked perfectly.

The only thing I noticed is that there were instances were the light would be on the next day. Normally it’s lights out around 11PM-12AM so having a light on all night could show someone that we are gone because it’s out of our normal schedule, if someone was paying close attention. Is there a way to make sure the lights are off by a certain time or at the end of the random schedule?

Make sure that the random schedule ends ahead of a “turn everything off” step

1 Like

I am having some issues with Occusim. I finally got around to updating AppDaemon to 2.1.10 today (Previously I was using the .cfg files) so I may have some things missing. It appears that AppDaemon and Occusim are running from the log but when I used to have it up and working the times posted out in the Log File. So I am afraid it is not working correctly. Below is my Log File now:

2017-10-19 12:39:24.575698 INFO AppDaemon Version 2.1.10 starting
2017-10-19 12:39:24.575794 INFO Configuration read from: conf/appdaemon.yaml
2017-10-19 12:39:24.678636 INFO Starting Apps
2017-10-19 12:39:24.796213 INFO Got initial state
2017-10-19 12:39:24.796562 INFO Loading Module: conf/apps/occusim.py
2017-10-19 12:39:24.796880 INFO Loading Module: conf/apps/switch_reset.py
2017-10-19 12:39:24.797433 INFO App initialization complete
2017-10-19 12:39:24.797543 INFO Dashboards are disabled
2017-10-19 12:39:24.797586 INFO API is disabled
2017-10-19 12:39:24.841851 INFO Connected to Home Assistant 0.55.0

Also here is my configuration file which is now a .yaml file:

AppDaemon:
  app_dir: conf/apps
  errorfile: conf/log/appdaemon_err.log
  logfile: conf/log/appdaemon_log.log
  threads: '10'
#HADashboard: {}
HASS:
  ha_key: XXXX
  ha_url: https://XXXX:8123
Occupancy Simulator:
  module: occusim
  class: OccuSim
  log: '1'
  notify: '1'
  enable: input_boolean.home,off
  dump_times: '1'
  reset_time: 02:00:00
  
  step_morning_name: Morning
  step_morning_start: 06:45:00
  step_morning_days: Monday,Tuesday,Wednesday,Thursday,Friday
  step_morning_end: 06:55:00
  step_morning_on_1: switch.kitchen_switch
  step_morning_start_offset: 00:01:05
  step_morning_end_offset: 00:05:00
  step_morning_on_2: switch.dining_switch
  
  step_morning_off_name: Morning Off
  step_morning_off_start: 07:00:00
  step_morning_off_days: Monday,Tuesday,Wednesday,Thursday,Friday
  step_morning_off_end: 07:10:00
  step_morning_off_off_1: switch.kitchen_switch
  step_morning_off_start_offset: 00:00:01
  step_morning_off_end_offset: 00:00:05
  step_morning_off_off_2: switch.dining_switch
  
  step_dinner_start_name: Dinner Start
  step_dinner_start_start: '17:45:00'
  #step_dinner_start_end: '21:45:00'
  #step_evening_off_off_1: switch_living_room_outlet_switch
  
  step_dinner_end_name: Dinner End
  step_dinner_end_start: '20:05:00'
  
  step_evening_name: Evening
  step_evening_start: sunset - 00:45:00
  #step_evening_end: sunset - 00:20:00
  #step_evening_on_1: switch.living_room_outlet_switch
  
  step_room_off_name: Room Off
  step_room_off_start: '22:15:00'
  #step_room_off_end: '23:15:00'
  
  random_dinner_name: Dinner
  random_dinner_start: Dinner Start
  random_dinner_end: Dinner End
  random_dinner_minduration: 00:40:00
  random_dinner_maxduration: 01:12:00
  random_dinner_number: '1'
  random_dinner_on_1: switch.dinig_switch
  random_dinner_on_2: switch.kitchen_switch
  random_dinner_off_1: switch.dining_switch
  random_dinner_off_2: switch.kitchen_switch
  
  random_kitchen_name: Kitchen
  random_kitchen_start: Evening
  random_front_room_end: Room Off
  random_kitchen_minduration: 00:05:00
  random_kitchen_maxduration: 00:23:00
  random_kitchen_number: '3'
  random_kitchen_on_1: switch.kitchen_switch
  random_kitchen_off_1: switch.kitchen_switch
  
  random_front_room_name: FrontRoom
  random_front_room_start: Evening
  random_kitchen_end: Room Off
  random_front_room_minduration: 00:10:00
  random_front_room_maxduration: 00:33:00
  random_front_room_number: '3'
  random_front_room_on_1: switch.front_room_switch
  random_front_room_off_1: switch.front_room_switch
  
  # step_tv_name: TV
  # step_tv_start: '19:45:00'
  # step_tv_end: '20:30:00'
  # step_tv_on_1: input_boolean.plex_away
  
  # step_tv_off_name: TV Off
  # step_tv_off_start: '22:15:00'
  # step_tv_off_end: '23:45:00'
  # step_tv_off_off_1: input_boolean.plex_away

Switch Reset:
  module: switch_reset
  class: SwitchReset
  file: /home/mgranger/.homeassistant/switches.db
  delay: '5'
  log: '1'

Any help would be appreciated. I just don’t know why the times aren’t posted in the log.

One of the recent changes in AD was to move all of the App configuration into a separate file called apps.yaml - you will need to move every thing in the occusim section to a new file with that name then you should be good to go.

1 Like

i think that also all times need to be changed to strings. (or did you update occusim for that?)

Ok just one last question. So my times are now showing up in the log after I split the files. But I noticed that the reset time wouldn’t work unless I put them in single quotes and made it a string like ReneTode said. The question is do I have to make all my times strings because the others seem to show up in the log even though they are not strings?

if it works, it works :wink:
but to be sure, you can better keep in mind to use the times in quotes.
and to make sure you dont forget that when you edit in the future, you better change them all to quotes.
i havent looked at the code but i know andrew a bit, and i am sure that quoted times will work in all cases.

Actually, ther culprit here is YAML - it tries to interpret 0 or 1 as true and false unless you put quotes around it. One of YAML’s greatest misfeatures in my opinion!