Announcement: Occupancy Simulator for AppDaemon v 1.1.0

After a successful test run over the last week while on vacation, I have added a few tweaks:

1.1.0 (2016-10-01)

Features

  • Steps can now fire arbitrary number of Home Assistant Events
  • Day constraints are now applied per step not globally
  • An arbitrary number of input_select can be set for each step instead of a single global input_select

Fixes

  • None

Breaking Changes

  • input_select changes are now specified per step
  • day constraints are no longer global and have to be specified per step
1 Like

Andrew, what is the best way to update an App? If I re-execute

git clone https://github.com/acockburn/occusim.git

I get:

Update; Just deleted the directory and started from scratch. Works but would like to know if this is the best way.

Andrew; Now all basics seem to be working; Could you post your personal example of your occusim config? The documentation is quite comprehensive but without a complete example from real life (there a bits but not a complete one) a bit tough.

p.s. I copied below in my appdaemon.cfg but get error in the log.

[Occupancy Simulator Weekdays]
module = occupancy_sim
class = OccupancySimulator

log = 1
notify = 1
enable = input_boolean.vacation,off
test = 1
dump_times = 1
reset_time = 02:00:00

Should the first line (Module = occupancy_sim) not be Module=Occusim ?

Hi there - check the latest version, it has some new features and a few bugfixes. It also contains a full example in appdaemon.cfg.example - also, if you use the latest version you shouldn’t get the error above - there were some typos in the readme that I have now fixed.

Also, thanks for pointing out the missing upgrade instructions, they are also now in the readme, and look like this:

Updating OccuSim

To update OccuSim after I have released new code, just run the following command to update your copy:

$ git pull origin

Then copy occusim.py to your App directory as in the original installation.

Just released 1.1.1 with a bugfix:

1.1.1 (2016-10-02)

Features

None

Fixes

  • Fixed a bug where custome events were not honoring test mode

Breaking Changes

None

Ok, cool. Thanks.

Let me just continue bothering you;

In the example you use “scene.office_on”. I’m assuming this is calling the HASS scene, correct? What is you just want one light to go on or off?

Yes, that will activate a scene. To do a light just use its entity id, e.g. light.office

In an automation some extra elements are needed. Let’s say I want a light to dim to level x like the example below:

- service: light.turn_on
  entity_id: light.qubino_zmnhdd1_flush_dimmer_level_11
  data:
    brightness: 52

How would I formulate? e.g. what would I change from you example code below?

random_office_on_1 = scene.office_on
random_office_off_1 = scene.office_off

The whole point of scenes is that they contain all that information such as levels or even colors, that is why I use scenes rather than lights. Just set up the scene as you want it in Home Assistant, then use it in occusim.

Generally I do not use a scene when I just have one light I want to change (like bathroom, toilet, hallway). But no issue for me to create them. Just want to understand the logic so I don’t need to keep asking as soon as I starts doing something else then the examples.

Love your work! Many thanks for all the energy you put into this!

1 Like

@aimc expanding my Occusim a bit. Currently have below but it gives and error in the log I don’t get:

2016-10-18 21:12:23.031378 WARNING Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/appdaemon/appdaemon.py", line 604, in check_config
    new_config.read_file(open(config_file))
  File "/usr/lib/python3.4/configparser.py", line 691, in read_file
    self._read(f, source)
  File "/usr/lib/python3.4/configparser.py", line 1070, in _read
    fpname, lineno)
configparser.DuplicateOptionError: While reading from '/home/pi/appdaemon/conf/appdaemon.cfg' [line 79]: option 'random_toilet_name' in section 'Occupancy Simulator' already exists




    [Occupancy Simulator]
    module = occusim
    class = OccuSim

    log = 1
    notify = 1
    enable = input_boolean.vacation,on
    test = 1
    dump_times = 1
    reset_time = 02:00:00

    step_morning_name = Morning
    step_morning_start = 06:30:00
    step_morning_end = 07:30:00
    step_morning_on_1 = switch.badkamer_licht
    step_morning_on_2 = light.bank_tolomeo
    step_morning_on_3 = light.qubino_zmnhdd1_flush_dimmer_level_11

    step_day_name = Day
    step_day_start = sunrise + 00:45:00
    step_day_off_1 = switch.badkamer_licht
    step_day_off_2 = light.bank_tolomeo
    step_day_off_3 = light.qubino_zmnhdd1_flush_dimmer_level_11

    step_evening_name = Evening
    step_evening_start = sunset - 00:45:00
    step_evening_on_1 = light.bank_tolomeo

    step_night_name = Night
    step_night_start = 22:30:00 
    step_night_end = 23:30:00
    step_night_on_1 = scene.evening_off
    step_night_on_2 = light.gang_boven
    step_night_on_3 = switch.badkamer_licht
    step_night_on_4 = light.slaapkamer_ouders

    step_upstairs_hall_off_name = Upstairs Hall Off
    step_upstairs_hall_off_relative = Night
    step_upstairs_hall_off_start_offset = 00:01:00
    step_upstairs_hall_off_end_offset = 00:10:00
    step_upstairs_hall_off_1 = light.gang_boven
    step_upstairs_hall_off_2 = switch.badkamer_licht

    step_lightsout_name = Lights Out
    step_lightsout_relative = Night
    step_lightsout_start_offset = 00:01:00
    step_lightsout_end_offset = 00:20:00
    step_lightsout_off_1 = light.slaapkamer_ouders

    random_toilet_name = Evening toilet
    random_toilet_start = Evening
    random_toilet_end = Night
    random_toilet_minduration = 00:03:00
    random_toilet_maxduration = 00:05:00
    random_toilet_number = 3
    random_toilet_on_1 = light.licht_toilet
    random_toilet_off_1 = light.licht_toilet

Can you post your whole appdaemon.cfg please?

here you go:

[AppDaemon]
ha_url = http://192.168.1.196:8123
ha_key = xxxxx
logfile = /home/pi/appdaemon/logs/appdaemon.log
errorfile = /home/pi/appdaemon/logs/error.log
app_dir = /home/pi/appdaemon/conf/apps
threads = 10
latitude = 52.xxxxx
longitude = 5.xxxxx
elevation = 9
time_zone = Europe/Amsterdam
# Apps
[Switch Reset]
module = switch_reset
class = SwitchReset
file = /home/hass/.homeassistant/switches
delay = 10
log = 1
;notify = 1

[Occupancy Simulator]
module = occusim
class = OccuSim

log = 1
notify = 1
enable = input_boolean.vacation,on
test = 1
dump_times = 1
reset_time = 02:00:00

step_morning_name = Morning
step_morning_start = 06:30:00
step_morning_end = 07:30:00
step_morning_on_1 = switch.badkamer_licht
step_morning_on_2 = light.bank_tolomeo
step_morning_on_3 = light.qubino_zmnhdd1_flush_dimmer_level_11

step_day_name = Day
step_day_start = sunrise + 00:45:00
step_day_off_1 = switch.badkamer_licht
step_day_off_2 = light.bank_tolomeo
step_day_off_3 = light.qubino_zmnhdd1_flush_dimmer_level_11

step_evening_name = Evening
step_evening_start = sunset - 00:45:00
step_evening_on_1 = light.bank_tolomeo

step_night_name = Night
step_night_start = 22:30:00 
step_night_end = 23:30:00
step_night_on_1 = scene.evening_off
step_night_on_2 = light.gang_boven
step_night_on_3 = switch.badkamer_licht
step_night_on_4 = light.slaapkamer_ouders

step_upstairs_hall_off_name = Upstairs Hall Off
step_upstairs_hall_off_relative = Night
step_upstairs_hall_off_start_offset = 00:01:00
step_upstairs_hall_off_end_offset = 00:10:00
step_upstairs_hall_off_1 = light.gang_boven
step_upstairs_hall_off_2 = switch.badkamer_licht

step_lightsout_name = Lights Out
step_lightsout_relative = Night
step_lightsout_start_offset = 00:01:00
step_lightsout_end_offset = 00:20:00
step_lightsout_off_1 = light.slaapkamer_ouders

random_toilet_name = Evening toilet
random_toilet_start = Evening
random_toilet_end = Night
random_toilet_minduration = 00:03:00
random_toilet_maxduration = 00:05:00
random_toilet_number = 3
random_toilet_on_1 = light.licht_toilet
random_toilet_off_1 = light.licht_toilet

random_kitchen_name = Evening Office
random_kitchen_start = Evening
random_kitchen_end = Night
random_kitchen_minduration = 00:02:00
random_kitchen_maxduration = 00:10:00
random_kitchen_number = 5
random_kitchen_on_1 = light.qubino_zmnhdd1_flush_dimmer_level_11
random_kitchen_off_1 = light.qubino_zmnhdd1_flush_dimmer_level_11

Interesting - have you tried restarting AppDaemon?

This is so weird. First tested only restarting Appdeamon, then a full reboot. Result the same. No errors in error.log but look at below logfile & compare with .cnf. Still reporting office instead of kitchen. How weird is that?

This is probably the issue - a type in the name which is what is used in the logfile.

Well spotted! Thanks!

Few extra Q’s to be sure:

  • I have an input boolean that is called vacation. I’m assuming that the setting in the cnf file (enable = input_boolean.vacation,on) means the App runs actively if the input Boolean is switched to ‘on’?
  • What happens if I switch this input Boolean ‘off’; Does the app stop immediately or does it finisch it’s schedule (asking this because I see the ‘planned’ activities in the log)
  • I’m now only simulating (test=1 in the cnf). I’m assuming that if I set this to 0 it goes ‘live’. Correct?

The input boolean just prevents the callbacks from actually doing anything, the scheduling all occurs as usual so you can see the times dumped in the log, but if it is disabled test mode won’t show you anything. For testing I recommend the following:

  1. Set test = 1
  2. Comment out or remove the enable parameter.

Ok, now I’m a bit more confused.

What does the parameter ‘off’ do in your example config file: "enable = input_boolean.vacation,off "

That tells you the setting, “on” or “off” for which the simulator is active. In this case I was testing so rather than have the vacation boolean on, I wanted the simulator to be active when the boolean was off.