acockburn / occusim Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Hi there,
got an KeyError when i try to use random tasks:
2017-04-13 19:04:51.038146 WARNING ------------------------------------------------------------
2017-04-13 19:04:51.039209 WARNING Logged an error to /home/osmc/.homeassistant/home-assistant-appdaemon.log
2017-04-13 19:04:59.008986 INFO /home/osmc/.homeassistant/appdaemon.cfg modified
2017-04-13 19:04:59.024273 INFO App 'Occupancy Simulator' changed - reloading
2017-04-13 19:04:59.026313 INFO Loading Object Occupancy Simulator using class OccuSim from module occusim
2017-04-13 19:04:59.031195 WARNING ------------------------------------------------------------
2017-04-13 19:04:59.032585 WARNING Unexpected error:
2017-04-13 19:04:59.033617 WARNING ------------------------------------------------------------
2017-04-13 19:04:59.035363 WARNING Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/appdaemon/appdaemon.py", line 913, in check_config
new_config[name]["module"], new_config[name]
File "/usr/local/lib/python3.4/dist-packages/appdaemon/appdaemon.py", line 690, in init_object
conf.objects[name]["object"].initialize()
File "/home/osmc/.homeassistant/apps/occusim.py", line 31, in initialize
self.create_events({})
File "/home/osmc/.homeassistant/apps/occusim.py", line 157, in create_events
starttime = events[startstep]["event"]
KeyError: '05:30:00'
My config, just out of your example:
[Occupancy Simulator]
module = occusim
class = OccuSim
log = 1
notify = 0
enable = input_boolean.vacation,off
test = 1
random_morning_name = Morning
random_morning_days = mon,tue,wed,thu,fri
random_morning_start = 05:30:00
random_morning_end = 06:00:00
random_morning_on_1 = event.MODE_CHANGE,mode
Sequenced tasks seem to work fine. Tried sunset, sunrise, morning, eventing, ... Error still just occour on randoms.
Hi
I think it would be useful to log/notify the HA event that is executing (rather than the occusim name).
At the moment my logs show eg
`2018-01-09 11:55:12.130688 INFO Occupancy Simulator: Evening - Ian's Study random lights_on_0: @ 2018-01-09 16:07:08
2018-01-09 11:55:12.134749 INFO Occupancy Simulator: Evening - Ian's Study random lights_off_0: @ 2018-01-09 16:14:23
2018-01-09 11:55:12.139146 INFO Occupancy Simulator: Evening - Red Bedroom random lights_on_1: @ 2018-01-09 16:25:43
2018-01-09 11:55:12.143311 INFO Occupancy Simulator: Evening - Red Bedroom random lights_off_1: @ 2018-01-09 16:53:21
`
and the same event ("Ian's Study random lights_on_0" etc) shows in the notifications. This is not user friendly. It would be better to show "scene.wendys_lamp: on" or something similar (especially for notifications, possibly both in log).
Two other points:
EDIT: for some reason it seems that my logs now also show the entity events (which they were not previously - no idea why!) But my comments re notifications remain.
Doc says: "If a scene is used here, OccuSim is smart enough to turn it on rather than off."
Would it make sense for this also to apply "if a script is used here"? Invoking 'turn_off' on a script seems to have no effect.
For some reason, the moment I set the start or end time to be 10:00:00 or higher, an error occurs. For example, the following works ok:
step_evening_study_off_name: Evening Lights Off
step_evening_study_off_start: 09:00:00
step_evening_study_off_end: 09:40:00
step_evening_study_off_off_1: light.ensuite
As soon as I save the file with the following increase in hours to double digits, the error below occurs:
step_evening_study_off_name: Evening Lights Off
step_evening_study_off_start: 09:00:00
step_evening_study_off_end: 10:40:00
step_evening_study_off_off_1: light.ensuite
Error:
2018-03-30 11:54:25.267428 WARNING AppDaemon: ------------------------------------------------------------
2018-03-30 11:54:25.268396 WARNING AppDaemon: Unexpected error running initialize() for Occupancy Simulator
2018-03-30 11:54:25.269287 WARNING AppDaemon: ------------------------------------------------------------
2018-03-30 11:54:25.271477 WARNING AppDaemon: Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/appdaemon/appdaemon.py", line 1513, in init_object
init()
File "/home/homeassistant/conf/apps/occusim.py", line 32, in initialize
self.create_events({})
File "/home/homeassistant/conf/apps/occusim.py", line 68, in create_events
end = self.parse_time(end_p)
File "/usr/local/lib/python3.5/dist-packages/appdaemon/appapi.py", line 277, in parse_time
return self.AD.parse_time(time_str, name)
File "/usr/local/lib/python3.5/dist-packages/appdaemon/appdaemon.py", line 1015, in parse_time
parts = re.search('^(\d+):(\d+):(\d+)', time_str)
File "/usr/lib/python3.5/re.py", line 173, in search
return _compile(pattern, flags).search(string)
TypeError: expected string or bytes-like object
2018-03-30 11:54:25.272501 WARNING AppDaemon: ------------------------------------------------------------
I'm running Home Assistant on Hassbian with the following versions:
HA: 0.65.5
AppDaemon: 3.0.0
Occusim: 1.1.5
appdaemon.yaml:
log:
# accessfile: /export/hass/appdaemon_test/logs/access.log
errorfile: /home/homeassistant/conf/log/occusim_err.log
logfile: /home/homeassistant/conf/log/occusim.log
log_generations: 3
log_size: 1000000
appdaemon:
threads: 10
# time_zone: <time zone>
api_port: 5000
plugins:
HASS:
type: hass
ha_url: http://localhost:8123
ha_key: !secret home_assistant_pass
apps.yaml - as you can see most steps work ok because their times are below 10:00:00, yet any that are 10 or above cause the error.
Occupancy Simulator:
class: OccuSim
module: occusim
log: '1'
notify: '1'
# enable: input_boolean.wearehome,off
# test: '0'
dump_times: '1'
reset_time: 02:00:00
step_morning_ensuite_on_name: Morning En-Suite On
step_morning_ensuite_on_days: mon,tue,wed,thu,fri
step_morning_ensuite_on_start: 06:00:00
step_morning_ensuite_on_end: 06:15:00
step_morning_ensuite_on_on_1: light.ensuite
step_morning_ensuite_off_name: Morning En-Suite Off
step_morning_ensuite_off_days: mon,tue,wed,thu,fri
step_morning_ensuite_off_start: 06:30:00
step_morning_ensuite_off_end: 07:00:00
step_morning_ensuite_off_off_1: light.ensuite
step_evening_ensuite_on_name: Evening En-Suite On
step_evening_ensuite_on_relative: Evening Study Off
step_evening_ensuite_on_start_offset: 00:05:00
step_evening_ensuite_on_end_offset: 00:10:00
step_evening_ensuite_on_on_1: light.ensuite
step_evening_ensuite_off_name: Evening En-Suite Off
step_evening_ensuite_off_relative: Evening En-Suite On
step_evening_ensuite_off_start: 00:05:00
step_evening_ensuite_off_end: 00:10:00
step_evening_ensuite_off_off_1: light.ensuite
# step_evening_study_on_name: Evening Study On
# step_evening_study_on_start: sunset - 00:30:00
# step_evening_study_on_end: sunset
# step_evening_study_on_on_1: group.study_lamps
step_evening_study_off_name: Evening Lights Off
step_evening_study_off_start: 09:00:00
step_evening_study_off_end: 10:40:00
step_evening_study_off_off_1: light.ensuite
# step_evening_study_off_off_1: group.study_lamps
step_evening_hall_name: EveningHall
step_evening_hall_start: sunset - 00:45:00
step_evening_hall_end: sunset - 00:30:00
step_evening_hall_on_1: group.hall_lights
#
# step_night_hall_name: NightHall
# step_night_hall_start: 22:00:00
# step_night_hall_end: 22:20:00
# step_night_hall_off_1: group.hall_lights
The example yaml configuration file uses 'log: 1' but this should be 'log_msg: 1'.
Hello,
with the current version of, no function is possible under Appdeamon 4.2.4:
2020-04-17 10:10:03.772983 INFO AppDaemon: Initializing app Occupancy Simulator using class OccuSim from module occusim
2020-04-17 10:10:03.994784 WARNING Occupancy Simulator: ------------------------------------------------------------
2020-04-17 10:10:03.995543 WARNING Occupancy Simulator: Unexpected error running initialize() for Occupancy Simulator
2020-04-17 10:10:03.996154 WARNING Occupancy Simulator: ------------------------------------------------------------
2020-04-17 10:10:04.002284 WARNING Occupancy Simulator: Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/appdaemon/app_management.py", line 145, in initialize_app
await utils.run_in_executor(self, init)
File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 276, in run_in_executor
response = future.result()
File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, 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 178, in create_events
end = start + datetime.timedelta(seconds=random.randrange(dspan)) + datetime.timedelta(seconds=mindtsdur)
File "/usr/lib/python3.8/random.py", line 216, in randrange
raise ValueError("empty range for randrange()")
ValueError: empty range for randrange()
2020-04-17 10:10:04.003023 WARNING Occupancy Simulator: ------------------------------------------------------------
2020-04-17 10:10:04.009287 INFO AppDaemon: App initialization complete
Best wishes
Michael
Hi
Please forgive if this is naive/wrong - I am new to Python and Appdaemon
I have looked at the code and - as far as I understand it - events are scheduled at (default) 3am for the coming day if "enable" is true at that time. They are then carried out as scheduled, regardless of whether "enable" is true at the time of event execution. Is this correct?
If so, this is not an especially family-friendly behaviour. My lot look askance at devices turning on/off at random times when they are around. Might it not be sensible to check the "enable" state at the time of execution?
Hi!
I'm trying to use OccuSim for the first time.
I'm running AppDaemon version 3.0.0b2 and OccuSim version 1.1.5.
It looks like I got everything configured and running properly, but when a step is fired, an error is written to the log:
2018-02-09 21:53:42.002532 WARNING AppDaemon: ------------------------------------------------------------
2018-02-09 21:53:42.002532 WARNING AppDaemon: Unexpected error in worker for App Occupancy Simulator:
2018-02-09 21:53:42.002532 WARNING AppDaemon: Worker Ags: {'id': UUID('6a85611c-1d3e-47dc-a03c-1f5781221e4d'), 'type': 'timer', 'kwargs': {'step': 'Evening Office_on_137', 'random_office_on_1': 'switch.lr_dining_table_light', 'constrain_input_boolean': 'input_boolean.not_at_home,on'}, 'name': 'Occupancy Simulator', 'function': <bound method OccuSim.execute_step of <occusim.OccuSim object at 0x0000014BE9A2C7F0>>}
2018-02-09 21:53:42.002532 WARNING AppDaemon: ------------------------------------------------------------
2018-02-09 21:53:42.002532 WARNING AppDaemon: Traceback (most recent call last):
File "c:\users\shlomi\appdata\local\programs\python\python35\lib\site-packages\appdaemon\appdaemon.py", line 506, in worker
funcref(self.sanitize_timer_kwargs(app, args["kwargs"]))
File "config\appdaemon\apps\occusim.py", line 220, in execute_step
self.activate(kwargs[arg], "on")
File "config\appdaemon\apps\occusim.py", line 238, in activate
if not self.test: self.turn_on(entity)
AttributeError: 'OccuSim' object has no attribute 'turn_on'
2018-02-09 21:53:42.002532 WARNING AppDaemon: ------------------------------------------------------------
Any ideas?
Documentation says that it can be activated on specific days. However I can’t seem to get it to work using the example config.
In theory the following code should only run on weekends. But when I check the dump_times log in the AppDeamon for Occusim, it’s showing that the rule would run today, Wednesday 19/12/18. Which isn’t what I would expect.
step_weekend_bedtime_name: Weekend Bedtime
step_weekend_bedtime_days: sat,sun
step_weekend_bedtime_start: "22:15:00"
step_weekend_bedtime_end: "23:55:00"
step_weekend_bedtime_on_1: script.bedtime_routine
Setting the "test" variable to "0" does not work as expected. Test mode is still on because in the code only the existence of the variable is tested, not the actual value.
Having this in mind, the documentation is correct ("set the variable to any value").
But it cost me 2 days of debugging ;)
So it would be great if you could elaborate it a bit or fix the variable handling.
See https://community.home-assistant.io/t/occusim-appdaemon-just-notifies-but-does-not-switch-lights/9776/4 for the thread.
Thanks for that great appDaemon thing 👍
Did I configure something wrong or are the durations in random mode calculated incorrectly?
I'm using the following configuration:
...
step_evening_name: Abend
step_evening_start: 'sunset - 00:30:00'
step_evening_end: 'sunset + 00:30:00'
step_night_name: Nacht
step_night_start: '22:30:00'
step_night_end: '23:55:00'
...
random_mobaevening_name: MoBa (Abend)
random_mobaevening_start: Abend
random_mobaevening_end: Nacht
random_mobaevening_minduration: 00:15:00
random_mobaevening_maxduration: 00:30:00
random_mobaevening_number: 1
random_mobaevening_on_1: light.4fachschalter_buro_level_6
random_mobaevening_off_1: light.4fachschalter_buro_level_6
random_wozievening_name: Wohnzimmer (Abend)
random_wozievening_start: Abend
random_wozievening_end: Nacht
random_wozievening_minduration: 00:45:00
random_wozievening_maxduration: 01:30:00
random_wozievening_number: 1
random_wozievening_on_1: light.4fachschalter_buro_level_5
random_wozievening_off_1: light.4fachschalter_buro_level_5
...
So I expect «MoBa» to be turned on once in the interval for 15 to 30 minutes and «Wohnzimmer» for 45 to 90 minutes.
The calculated times are:
...
2017-12-30 08:22:43.022458 INFO Anwesenheit Atelier: Abend: @ 2017-12-30 16:21:40
2017-12-30 08:22:43.026545 INFO Anwesenheit Atelier: MoBa (Abend)_on_0: @ 2017-12-30 17:01:31
2017-12-30 08:22:43.030856 INFO Anwesenheit Atelier: MoBa (Abend)_off_0: @ 2017-12-30 17:11:15
2017-12-30 08:22:43.035127 INFO Anwesenheit Atelier: Wohnzimmer (Abend)_on_0: @ 2017-12-30 21:44:31
2017-12-30 08:22:43.039396 INFO Anwesenheit Atelier: Wohnzimmer (Abend)_off_0: @ 2017-12-30 22:09:51
2017-12-30 08:22:43.044414 INFO Anwesenheit Atelier: Nacht: @ 2017-12-30 22:49:11
...
«MoBa»: abt. 10 minutes (instead of 15..30)
«Wohnzimmer»: abt. 26 minutes (instead of 45..90)
Did I do something wrong or did I misinterpret the documentation or is there an error in the calculation?
With my config I have the situation that some of the events do not make sense, e.g. twice the on event after each other instead of on - off - on.
Please fix the ordering of the events.
Config:
[Occupancy Simulator]
module = occusim
class = OccuSim
log = 1
notify = 1
enable = input_boolean.vacation,on
# test = 0
dump_times = 1
reset_time = 02:00:00
step_morning_name = Morning
step_morning_days = mon,tue,wed,thu,fri,sat,sun
step_morning_start = sunrise - 01:00:00
step_morning_end = sunrise
step_morning_on_1 = event.MODE_CHANGE,mode
step_day_name = Day
step_day_start = sunrise + 00:45:00
step_day_on_1 = event.MODE_CHANGE,mode
step_evening_name = Evening
step_evening_start = sunset - 00:45:00
step_evening_on_1 = event.MODE_CHANGE,mode
step_night_name = Night
step_night_start = 21:30:00
step_night_end = 23:30:00
step_night_on_1 = event.MODE_CHANGE,mode
step_upstairs_name = Upstairs activity
step_upstairs_relative = Evening
step_upstairs_start_offset = 00:00:10
step_upstairs_on_1 = scene.upstairs_on
step_upstairs_off_1 = scene.upstairs_off
step_downstairs_name = Downstairs activity
step_downstairs_relative = Evening
step_downstairs_start_offset = 00:00:10
step_downstairs_on_1 = scene.downstairs_on
step_downstairs_off_1 = scene.downstairs_off
step_bedtime_name = Bedtime
step_bedtime_start = 21:30:00
step_bedtime_end = 22:30:00
step_bedtime_on_1 = scene.bedtime
random_office_name = Evening Office
random_office_start = Evening
random_office_end = Night
random_office_minduration = 00:03:00
random_office_maxduration = 00:30:00
random_office_number = 5
random_office_on_1 = scene.studio_on
random_office_off_1 = scene.studio_off
random_fitness_name = Evening Fitnessroom
random_fitness_start = Evening
random_fitness_end = Night
random_fitness_minduration = 00:03:00
random_fitness_maxduration = 00:30:00
random_fitness_number = 5
random_fitness_on_1 = scene.sport_on
random_fitness_off_1 = scene.sport_off
Result:
Jan 19 17:50:24 homeassistant appdaemon[28688]: 2017-01-19 18:50:24.343649 INFO Occupancy Simulator: Evening Office_on_2: @ 2017-01-19 18:59:47
Jan 19 17:50:24 homeassistant appdaemon[28688]: 2017-01-19 18:50:24.345273 INFO Occupancy Simulator: Evening Office_on_1: @ 2017-01-19 19:17:59
Jan 19 17:50:24 homeassistant appdaemon[28688]: 2017-01-19 18:50:24.347008 INFO Occupancy Simulator: Evening Office_on_0: @ 2017-01-19 19:24:37
Jan 19 17:50:24 homeassistant appdaemon[28688]: 2017-01-19 18:50:24.348618 INFO Occupancy Simulator: Evening Office_off_2: @ 2017-01-19 19:24:51
Jan 19 17:50:24 homeassistant appdaemon[28688]: 2017-01-19 18:50:24.350203 INFO Occupancy Simulator: Evening Office_off_1: @ 2017-01-19 19:30:37
Jan 19 17:50:24 homeassistant appdaemon[28688]: 2017-01-19 18:50:24.351785 INFO Occupancy Simulator: Evening Office_off_0: @ 2017-01-19 19:37:52
Jan 19 17:50:24 homeassistant appdaemon[28688]: 2017-01-19 18:50:24.353472 INFO Occupancy Simulator: Evening Fitnessroom_on_0: @ 2017-01-19 19:49:48
Jan 19 17:50:24 homeassistant appdaemon[28688]: 2017-01-19 18:50:24.355151 INFO Occupancy Simulator: Evening Fitnessroom_off_0: @ 2017-01-19 20:13:35
Jan 19 17:50:24 homeassistant appdaemon[28688]: 2017-01-19 18:50:24.356803 INFO Occupancy Simulator: Evening Fitnessroom_on_4: @ 2017-01-19 20:26:19
Jan 19 17:50:24 homeassistant appdaemon[28688]: 2017-01-19 18:50:24.358446 INFO Occupancy Simulator: Evening Fitnessroom_on_2: @ 2017-01-19 20:51:49
Jan 19 17:50:24 homeassistant appdaemon[28688]: 2017-01-19 18:50:24.360100 INFO Occupancy Simulator: Evening Fitnessroom_off_4: @ 2017-01-19 20:51:53
Jan 19 17:50:24 homeassistant appdaemon[28688]: 2017-01-19 18:50:24.361722 INFO Occupancy Simulator: Evening Fitnessroom_off_2: @ 2017-01-19 21:08:18
Jan 19 17:50:24 homeassistant appdaemon[28688]: 2017-01-19 18:50:24.363429 INFO Occupancy Simulator: Evening Fitnessroom_on_1: @ 2017-01-19 22:07:04
Jan 19 17:50:24 homeassistant appdaemon[28688]: 2017-01-19 18:50:24.365086 INFO Occupancy Simulator: Evening Office_on_4: @ 2017-01-19 22:15:27
Jan 19 17:50:24 homeassistant appdaemon[28688]: 2017-01-19 18:50:24.366710 INFO Occupancy Simulator: Evening Fitnessroom_off_1: @ 2017-01-19 22:16:28
Jan 19 17:50:24 homeassistant appdaemon[28688]: 2017-01-19 18:50:24.368564 INFO Occupancy Simulator: Evening Office_off_4: @ 2017-01-19 22:17:09
Jan 19 17:50:24 homeassistant appdaemon[28688]: 2017-01-19 18
Hi,
I'm using Occusim app with AppDaemon 4.0.1 with HA 0.105.4 and when each step is executed, I get the following in the log:
2020-02-17 22:35:33.019872 WARNING Occupancy Simulator: non_existent namespace (default) specified in call to turn_off
Thanks,
Setting up the evening step as described in the README:
step_evening_name: Evening
step_evening_start: sunset - 00:45:00
step_evening_on_1: scene.downstairs_on
results in this log message:
Occupancy Simulator: Evening in the past - ignoring
Will that fix itself on reset at 2 am? Or am I missing something?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.