Giter Club home page Giter Club logo

replaylightshistory's Introduction

ReplayLightsHistory hacs_badge

This is an AppDaemon App for Home Assistant that is designed to replay your lights behavior when no one is home. There are multiple other approaches out there that try to simulate behavior, which is hard. This approach simply uses your smart devices previous behavior to control their pending behavior. As the code exist today it has been tested with lights and smart switches. The smart switches include TP Link smart switches and plugs, as they are both labeled switch entities in Home Assistant. It has also been used with shelly 2 switches. It currently can only be configured to control one category of entities, which is specified in the configuration information.

Manually installing this AppDaemon App is relatively simply. The replay_lights.py file needs to be placed in the appdaemon/apps/ directory on your Home assistant install. Then you need to added lines to the appdaemon/apps/apps.yaml file to enable this application. At a minimum you would add these lines to the file apps/yaml file:

replay_lights: module: replay_lights class: ReplayLights

A maximum configuration can include the following lines, modified for your install:

replay_lights:
  hassDir: '/home/jondoe/.homeassistant'
  databaseType: sqlite3
  databaseHost: "localhost"
  databaseUser: "homeassistant"
  databasePassword: "PASSWORD"
  databaseSchema: "homeassistant"
  module: replay_lights
  class: ReplayLights
  numberOfDaysBack: 7
  deviceType: "light"
  enableTag: "alarm_control.home_alarm"
  enableVal: "armed_away"
  smartControlledByDumb: "switch.master_bed,switch.living_room_lamp"
  excludeList: "switch.garage,switch.garagecam"
  log_level: INFO

example_apps.yaml in the repo includes similar records

All of the parameters are optional. Their use follows:

  • hassDir - Home Assistant config directory (assumed to have home-assistant_v2.db in there). Defaults /config.

  • databaseType - Defines database type either sqlite3 which is default or MariaDB

  • databaseHost - Hostname or IP address of host where MariaDB is installed (optional, default localhost)

  • databaseUser - User for MariaDB defaults to homeassistant

  • databasePassword - Password for MariaDB

  • databaseSchema - Name of DB schema akka database name. This is normally same as user name. (optional, default homeassistant)

  • numberOfDaysBack – this value that indicates how many days back in time the application should look for behavior that is to be replayed. This value can also be provided as a Home Assistant input number entity named input_number.replay_days_back. The advantage of specifying the value as an input number is that you can then change the value via the Home Assistant Lovelace interface. From a precedent perspective the application first looks for the input number entity, it looks for numberOfDaysBack from the apps.yaml file and finally if neither of these value is defined it uses the default of 7 days back.

  • deviceType – this has been tested with “switch” and “light”. It’s possible that it could work with other entity types. If not specified in the configuration, the default is “switch”. You can determine this value by looking at the entities off the configuration panel in your Home Assistant user interface. All of the devices you want to control will start with this label.

  • enableTag – This value, along with enableVal, determine if automated control of the lights is enabled. This is the name of the Home Assistant entity that the app looks at to determine if it should actually turn something off or on. The example_groups.yaml file shows how you might set up a Home Assistant group of persons entities to control this app’s behavior. The value for this field would be set to “group.persons”. You could then set the enableVal to “away”, and if all persons in this group are away the app will control the devices. The default value is a Home Assistant input boolean, "input_boolean.light_replay_enabled", that you need to create in your Home Assistant configuration.yaml file if you aren’t using some other entity, like the group.persons entity mentioned above, or the alarm control panel entity shown in the example configuration file above.

  • enableVal – This is the “state” value the “enableTag” must have in order for the app to actually turn something on or off. For the default enableTag, "input_boolean.light_replay_enabled", a state value of “on” would indicate that the app should controls the smart devices. As mentioned above if you created a group of persons and you wanted control to happen when they were all away from home then this parameter would be set to “away”. The default for this field is “on”

  • smartControlledByDumb – If you have smart light bulbs or smart plugs there is a possibility that a dumb switch could be inline. If used the dumb switch would could remove power from the device. If someone turns the dumb switch off then the device will be assigned a status of “unavailable” in Home Assistant instead of off. This parameter tells the application which devices can be disabled by dumb switches. This is a comma separated list. In the example configuration above it shows two smart plugs that could also be powered off via a dumb switch. If you have no devices in this situation then this parameter isn’t required.

  • excludeList - This is a comma separated list of switches you don't want included in the replay action, such as a switch on your garage or maybe a basement light you don't want to have turned on while you're out.

  • log_level - This is the log level for the application. It overrides the AppDaemon log level and set a custom log level only for this application. Supported log levels: INFO, WARNING, ERROR, CRITICAL, DEBUG, NOTSET.

NOTE: A recent update added the ability to use MariaDB as an alternative to sqlite3. This change requires the python package to be included in your appdaemon docker container. You include PyMySQL by adding it to the addons.json file found in the home assistant base directory. The easist way to make this modification is directly from the Home Assistant GUI. From Supervisor -> AppDaemon -> Configuration you can update the configuration to look like this:

system_packages: []
python_packages:
  - PyMySQL
init_commands: []

For the change to take effect you need to restart AppDaemon, which can be done from the AppDaemon Info tab.

replaylightshistory's People

Contributors

0n3man avatar mohlsson avatar nickneos avatar nimikko avatar samnewman86 avatar slesinger avatar xkill avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

replaylightshistory's Issues

Question not an issue.

Could you please explain to me what would happen if I triggered the routine by armed away, set it for 7 days back and left fir two weeks?
Would the routine repeat every day I am gone for the same day (7 days ago)? Would it only do one day and stop? Can I set a randomized day pattern? Basically how does the routine handle an extended absence?

Does this still work?

Does this module still even work? I installed and have set up everything, but none of my lights seem to turn on, while they were on during the same times for the last 7 days. Installed through HACS, this is my config:

replay_lights:
  hassDir: '/config'
  databaseType: sqlite3
  databaseHost: "localhost"
  databaseSchema: "homeassistant"
  module: replay_lights
  class: ReplayLights
  numberOfDaysBack: 7
  deviceType: "light"
  enableTag: "input_boolean.scene_vakantie"
  enableVal: "on"
  excludeList: "light.woonkamer_z_lampen,light.z_lampen_kamers,light.wc_z_lampen,light.gang_boven_z_lampen,light.woonkamer_z_disco"  

Unexpected error in worker for App replay_lights

Dear all,

with the latest version I am unfortunately getting this error:
2020-09-14 12:10:15.026563 INFO replay_lights: Scheduling Replaying 7 day[s] back
2020-09-14 12:10:15.030449 WARNING replay_lights: ------------------------------------------------------------
2020-09-14 12:10:15.031344 WARNING replay_lights: Unexpected error in worker for App replay_lights:
2020-09-14 12:10:15.032160 WARNING replay_lights: Worker Ags: {'id': '33e8f7c6936f4f48a46e2eb390a02978', 'name': 'replay_lights', 'objectid': 'c4afaed880854d3e814f46db3bd56172', 'type': 'scheduler', 'function': <bound method ReplayLights.scheduleNextEventBatch of <replay_lights.ReplayLights object at 0xb57e3dc0>>, 'pin_app': True, 'pin_thread': 1, 'kwargs': {'interval': 3600, '__thread_id': 'thread-1'}}
2020-09-14 12:10:15.033184 WARNING replay_lights: ------------------------------------------------------------
2020-09-14 12:10:15.034627 WARNING replay_lights: Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/pymysql/connections.py", line 569, in connect
sock = socket.create_connection(
File "/usr/lib/python3.8/socket.py", line 808, in create_connection
raise err
File "/usr/lib/python3.8/socket.py", line 796, in create_connection
sock.connect(sa)
OSError: [Errno 99] Address not available
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 887, in worker
funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"]))
File "/config/appdaemon/apps/ReplayLightsHistory/replay_lights.py", line 99, in scheduleNextEventBatch
conn = pymysql.connect(host=self.databaseHost, user=self.databaseUser, password=self.databasePassword, db=self.databaseSchema, charset='utf8')
File "/usr/lib/python3.8/site-packages/pymysql/init.py", line 94, in Connect
return Connection(*args, **kwargs)
File "/usr/lib/python3.8/site-packages/pymysql/connections.py", line 327, in init
self.connect()
File "/usr/lib/python3.8/site-packages/pymysql/connections.py", line 619, in connect
raise exc
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 99] Address not available)")
2020-09-14 12:10:15.038063 WARNING replay_lights: ------------------------------------------------------------

ReplayLightsHistory worked nicely before. My config is as follows:

replay_lights:
databaseType: MariaDB
databaseUser: "homeassistant"
databasePassword: ****
module: replay_lights
class: ReplayLights
numberOfDaysBack: 7
deviceType: "light"
enableTag: "input_boolean.light_replay_enabled"
enableVal: "on"
smartControlledByDumb: "light.bad_spot_1_2,light.bad_spot_2_2,light.bad_spot_3_2,light.buro_spot_1_2,light.buro_spot_2_2,light.buro_spot_3_2,light.buro_spot_4_2,light.elternlicht_2,light.esstischlampe_2,light.flur_spot_1_2,light.flur_spot_2_2,light.flur_spot_3_2,light.flur_spot_4_2,light.flur_spot_5_2,light.hue_ambiance_panel_1_2,light.hue_lightstrip_outdoor_1_2,light.hue_outdoor_spot_1_2,light.hue_outdoor_spot_2_2,light.insel_spot_1_2,light.insel_spot_2_2,light.kinderzimmerlampe_2,light.kinderzimmerlicht,light.kuchen_spot_1_2,light.kuchen_spot_2_2,light.kuchen_spot_3_2,light.kuchen_spot_4_2,light.kuchen_spot_5_2,light.stehlampe_2,light.treppenlicht_2,light.vorplatzlicht_1_2,light.vorplatzlicht_2_2,light.vorplatzlicht_3_2,light.wohnzimmerlampe_2"
excludeList: "light.aussen,light.badezimmer,light.buero,light.carport,light.dachgeschoss,light.deck,light.elternschlafzimmer,light.entree,light.entree_spot_1_2,light.entree_spot_2_2,light.erdgeschoss,light.esszimmer,light.haus,light.kellerflur,light.kellertreppe,light.kinderschlafzimmer,light.kuche"

Error

Somebody can help me please? I am getting the below error when i start the AppDeamon:

2023-01-05 14:49:48.246531 INFO replay_lights: started
2023-01-05 14:49:48.247819 INFO replay_lights: Defaulting Home Assistant config directory to /config
2023-01-05 14:49:48.250710 INFO AppDaemon: App initialization complete
2023-01-05 14:49:53.004592 INFO replay_lights: Scheduling Replaying 7 day[s] back
2023-01-05 14:49:53.004849 WARNING replay_lights: ------------------------------------------------------------
2023-01-05 14:49:53.005069 WARNING replay_lights: Unexpected error in worker for App replay_lights:
2023-01-05 14:49:53.005288 WARNING replay_lights: Worker Ags: {'id': '48ab0c12ac2b4fa194a248c1c9b4f5bc', 'name': 'replay_lights', 'objectid': '002323eb3a384000ac83a6d57d6750dd', 'type': 'scheduler', 'function': <bound method ReplayLights.scheduleNextEventBatch of <replay_lights.ReplayLights object at 0x7f777cfcf610>>, 'pin_app': True, 'pin_thread': 5, 'kwargs': {'interval': 3600, '__thread_id': 'thread-5'}}
2023-01-05 14:49:53.005537 WARNING replay_lights: ------------------------------------------------------------
2023-01-05 14:49:53.006016 WARNING replay_lights: Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/appdaemon/threading.py", line 904, in worker
funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"]))
File "/config/appdaemon/apps/ReplayLightsHistory/replay_lights.py", line 108, in scheduleNextEventBatch
for entity_id, event_new_state, c_date in result:
UnboundLocalError: local variable 'result' referenced before assignment
2023-01-05 14:49:53.006220 WARNING replay_lights: ------------------------------------------------------------

Date field from database didn't parse correctly after uodate to version f7fa646

Sorry to bother you again but unfortunately after updating to version f7fa646 I get the following error message for all my lights: 2020-07-31 07:05:37.411600 INFO replay_lights: First seen light.elternzimmer, adding to state table with state off
2020-07-31 07:05:37.413724 INFO replay_lights: Date field from database didn't parse correctly so skipping record

The previous version of ReplayLightsHIstory was working well for em after installing the PyMySQL package
I am using MariaDB and this is my config.
replay_lights:
databaseType: MariaDB
databaseUser: "****"
databasePassword: "*****"
module: replay_lights
class: ReplayLights
numberOfDaysBack: 7
deviceType: "light"
enableTag: "input_boolean.light_replay_enabled"
enableVal: "on"
smartControlledByDumb: "light.bad_spot_1_2,light.bad_spot_2_2,light.bad_spot_3_2,light.buro_spot_1_2,light.buro_spot_2_2,light.buro_spot_3_2,light.buro_spot_4_2,light.elternlicht_2,light.esstischlampe_2,light.flur_spot_1_2,light.flur_spot_2_2,light.flur_spot_3_2,light.flur_spot_4_2,light.flur_spot_5_2,light.hue_ambiance_panel_1_2,light.hue_lightstrip_outdoor_1_2,light.hue_outdoor_spot_1_2,light.hue_outdoor_spot_2_2,light.insel_spot_1_2,light.insel_spot_2_2,light.kinderzimmerlampe_2,light.kinderzimmerlicht,light.kuchen_spot_1_2,light.kuchen_spot_2_2,light.kuchen_spot_3_2,light.kuchen_spot_4_2,light.kuchen_spot_5_2,light.stehlampe_2,light.treppenlicht_2,light.vorplatzlicht_1_2,light.vorplatzlicht_2_2,light.vorplatzlicht_3_2,light.wohnzimmerlampe_2"
excludeList: "light.aussen,light.badezimmer,light.buero,light.carport,light.dachgeschoss,light.deck,light.elternschlafzimmer,light.entree,light.entree_spot_1_2,light.entree_spot_2_2,light.erdgeschoss,light.esszimmer,light.haus,light.kellerflur,light.kellertreppe,light.kinderschlafzimmer,light.kuche"

Unable to start the app

Hi,

The app seems to be unable to start in AppDaemon. I get the following error message but don't really know how to make sense of it. Do you need any other data to debug?

[22:18:14] INFO: Starting AppDaemon...
2020-08-16 22:18:16.255588 INFO AppDaemon: AppDaemon Version 4.0.3 starting
2020-08-16 22:18:16.257261 INFO AppDaemon: Python version is 3.8.2
2020-08-16 22:18:16.258157 INFO AppDaemon: Configuration read from: /config/appdaemon/appdaemon.yaml
2020-08-16 22:18:16.258918 INFO AppDaemon: Added log: AppDaemon
2020-08-16 22:18:16.259974 INFO AppDaemon: Added log: Error
2020-08-16 22:18:16.260823 INFO AppDaemon: Added log: Access
2020-08-16 22:18:16.261597 INFO AppDaemon: Added log: Diag
2020-08-16 22:18:16.310031 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2020-08-16 22:18:16.358293 INFO HASS: HASS Plugin Initializing
2020-08-16 22:18:16.359421 INFO HASS: HASS Plugin initialization complete
2020-08-16 22:18:16.361227 INFO AppDaemon: HTTP is disabled
2020-08-16 22:18:16.484223 INFO HASS: Connected to Home Assistant 0.114.0
2020-08-16 22:18:16.573139 INFO AppDaemon: App 'replay_lights' added
2020-08-16 22:18:16.575248 INFO AppDaemon: Found 1 total apps
2020-08-16 22:18:16.576543 INFO AppDaemon: Starting Apps with 1 workers and 1 pins
2020-08-16 22:18:16.694509 INFO HASS: Evaluating startup conditions
2020-08-16 22:18:16.814865 INFO AppDaemon: Got initial state from namespace default
2020-08-16 22:18:18.583307 INFO AppDaemon: Scheduler running in realtime
2020-08-16 22:18:18.589276 INFO AppDaemon: Adding /config/appdaemon/apps to module import path
2020-08-16 22:18:18.590977 INFO AppDaemon: Adding /config/appdaemon/apps/ReplayLightsHistory to module import path
2020-08-16 22:18:18.596445 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/ReplayLightsHistory/replay_lights.py
2020-08-16 22:18:18.728178 INFO AppDaemon: Initializing app replay_lights using class ReplayLights from module replay_lights
2020-08-16 22:18:18.730747 WARNING replay_lights: ------------------------------------------------------------
2020-08-16 22:18:18.732785 WARNING replay_lights: Unexpected error initializing app: replay_lights:
2020-08-16 22:18:18.733720 WARNING replay_lights: ------------------------------------------------------------
2020-08-16 22:18:18.737206 WARNING replay_lights: Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/appdaemon/app_management.py", line 820, in check_app_updates
    await self.init_object(app)
  File "/usr/lib/python3.8/site-packages/appdaemon/app_management.py", line 279, in init_object
    "object": app_class(
  File "/usr/lib/python3.8/site-packages/appdaemon/plugins/hass/hassapi.py", line 46, in __init__
    adbase.ADBase.__init__(self, ad, name, logging, args, config, app_config, global_vars)
  File "/usr/lib/python3.8/site-packages/appdaemon/adbase.py", line 75, in __init__
    self.dashboard_dir = self.AD.http.dashboard_dir
AttributeError: 'NoneType' object has no attribute 'dashboard_dir'
2020-08-16 22:18:18.738229 WARNING replay_lights: ------------------------------------------------------------
2020-08-16 22:18:18.739627 WARNING AppDaemon: Unable to find module replay_lights - initialize() skipped
2020-08-16 22:18:18.741381 INFO AppDaemon: App initialization complete

Stopped working some time in the past 4 months

Previously I had this working fine for the past few years, but recently I was away and it was not turning on/off any of the lights in the house. When checking the appdaemon logs it would say "replaying history" over and over but never list anything it was doing or any exclusions. I haven't changed anything with the configuration so not really sure what's up. I can provide any logs or screenshots anyone needs to help me troubleshoot.

Error in appdeamon ligs

Getting the following errors
2020-02-02 08:40:35.285584 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/replay_lights.py 2020-02-02 08:40:35.289347 WARNING Error: ------------------------------------------------------------ 2020-02-02 08:40:35.290279 WARNING Error: Unexpected error loading module: /config/appdaemon/apps/replay_lights.py: 2020-02-02 08:40:35.291258 WARNING Error: ------------------------------------------------------------ 2020-02-02 08:40:35.295300 WARNING Error: Traceback (most recent call last): File "/usr/lib/python3.8/site-packages/appdaemon/app_management.py", line 788, in check_app_updates await utils.run_in_executor(self, self.read_app, mod["name"], mod["reload"]) 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 "/usr/lib/python3.8/site-packages/appdaemon/app_management.py", line 580, in read_app self.modules[module_name] = importlib.import_module(module_name) File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 779, in exec_module File "<frozen importlib._bootstrap_external>", line 916, in get_code File "<frozen importlib._bootstrap_external>", line 846, in source_to_code File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/config/appdaemon/apps/replay_lights.py", line 26 for row in c.execute(f'SELECT event_data FROM events WHERE time_fired > datetime("now","localtime","-{self.numberOfDaysBack} days","+1 minutes") AND time_fired < datetime("now","localtime","-{self.numberOfDaysBack} days","+61 minut$ try:

in appdeamon it shows the app has terminated.

DB changes kill this code

I did an update to the lastest HA version yesterday and noticed that nothing was being schedule any longer. Turns out the data this tool uses from the HA database was being replicated in two locations, the events and states tables. At some recent version the HA team decided to remove the redundant data. They removed the information from the events table, which is the table ReplayLightsHistory was using. The data now needs to be pulled from the states table. I've modified the code to address this and will submit a pull request shortly.

error: Unknown column 'created' in 'field list

Error with MariaDB:
Using latest stable version of Home Assistant

File "/usr/lib/python3.11/site-packages/pymysql/connections.py", line 772, in _read_packet
    packet.raise_for_error()
  File "/usr/lib/python3.11/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "/usr/lib/python3.11/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1054, "Unknown column 'created' in 'field list'")

Failed to parse

Getting following in logs:

2020-02-02 20:52:35.047437 INFO replay_lights: failed to parse ('{"domain": "light", "service": "turn_off", "service_data": {"entity_id": "light.family_room_lamp"}}',) 2020-02-02 20:52:35.049822 INFO replay_lights: failed to parse ('{"domain": "light", "service": "turn_off", "service_data": {"entity_id": "light.main_bedroom_lamp_left"}}',) 2020-02-02 20:52:35.129852 INFO replay_lights: failed to parse ('{"domain": "light", "service": "turn_off", "service_data": {"entity_id": "light.main_bedroom_lamp_right"}}',)

Unexpected error loading module

Hi, I love the idea of this app. Unfortunately, I am getting the following error message:

[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing...
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] appdaemon.sh: executing...
[cont-init.d] appdaemon.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[10:48:33] INFO: Starting AppDaemon...
2020-07-22 10:48:35.196105 INFO AppDaemon: AppDaemon Version 4.0.3 starting
2020-07-22 10:48:35.196556 INFO AppDaemon: Python version is 3.8.2
2020-07-22 10:48:35.197255 INFO AppDaemon: Configuration read from: /config/appdaemon/appdaemon.yaml
2020-07-22 10:48:35.197650 INFO AppDaemon: Added log: AppDaemon
2020-07-22 10:48:35.198434 INFO AppDaemon: Added log: Error
2020-07-22 10:48:35.199002 INFO AppDaemon: Added log: Access
2020-07-22 10:48:35.199654 INFO AppDaemon: Added log: Diag
2020-07-22 10:48:35.237130 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2020-07-22 10:48:35.278888 INFO HASS: HASS Plugin Initializing
2020-07-22 10:48:35.279491 INFO HASS: HASS Plugin initialization complete
2020-07-22 10:48:35.280744 INFO AppDaemon: Initializing HTTP
2020-07-22 10:48:35.281618 INFO AppDaemon: Using 'ws' for event stream
2020-07-22 10:48:35.306501 INFO AppDaemon: Starting API
2020-07-22 10:48:35.317222 INFO AppDaemon: Starting Admin Interface
2020-07-22 10:48:35.318121 INFO AppDaemon: Starting Dashboards
2020-07-22 10:48:35.361869 INFO HASS: Connected to Home Assistant 0.111.4
2020-07-22 10:48:35.393582 INFO AppDaemon: App 'hello_world' added
2020-07-22 10:48:35.394503 INFO AppDaemon: App 'replay_lights' added
2020-07-22 10:48:35.396178 INFO AppDaemon: Found 2 total apps
2020-07-22 10:48:35.397534 INFO AppDaemon: Starting Apps with 2 workers and 2 pins
2020-07-22 10:48:35.400464 INFO AppDaemon: Running on port 5050
2020-07-22 10:48:35.484919 INFO HASS: Evaluating startup conditions
2020-07-22 10:48:35.593965 INFO AppDaemon: Got initial state from namespace default
2020-07-22 10:48:37.412483 INFO AppDaemon: Scheduler running in realtime
2020-07-22 10:48:37.422165 INFO AppDaemon: Adding /config/appdaemon/apps to module import path
2020-07-22 10:48:37.424309 INFO AppDaemon: Adding /config/appdaemon/apps/ReplayLightsHistory to module import path
2020-07-22 10:48:37.432912 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/hello.py
2020-07-22 10:48:37.445561 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/ReplayLightsHistory/replay_lights.py
2020-07-22 10:48:37.449252 WARNING Error: ------------------------------------------------------------
2020-07-22 10:48:37.450036 WARNING Error: Unexpected error loading module: /config/appdaemon/apps/ReplayLightsHistory/replay_lights.py:
2020-07-22 10:48:37.450718 WARNING Error: ------------------------------------------------------------
2020-07-22 10:48:37.454897 WARNING Error: Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/appdaemon/app_management.py", line 788, in check_app_updates
await utils.run_in_executor(self, self.read_app, mod["name"], mod["reload"])
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 "/usr/lib/python3.8/site-packages/appdaemon/app_management.py", line 580, in read_app
self.modules[module_name] = importlib.import_module(module_name)
File "/usr/lib/python3.8/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in _load_unlocked
File "", line 783, in exec_module
File "", line 219, in _call_with_frames_removed
File "/config/appdaemon/apps/ReplayLightsHistory/replay_lights.py", line 2, in
import pymysql.cursors
ModuleNotFoundError: No module named 'pymysql'
2020-07-22 10:48:37.455653 WARNING Error: ------------------------------------------------------------
2020-07-22 10:48:37.456434 WARNING AppDaemon: Removing associated apps:
2020-07-22 10:48:37.457236 WARNING AppDaemon: replay_lights
2020-07-22 10:48:37.459037 INFO AppDaemon: Initializing app hello_world using class HelloWorld from module hello
2020-07-22 10:48:37.665768 INFO hello_world: Hello from AppDaemon
2020-07-22 10:48:37.668199 INFO hello_world: You are now ready to run Apps!
2020-07-22 10:48:37.671634 INFO AppDaemon: App initialization complete

My config is as follows:
replay_lights:
databaseType: MariaDB
databaseUser: "homeassistant"
databasePassword: "C4=yntAx"
module: replay_lights
class: ReplayLights
numberOfDaysBack: 7
deviceType: "light"
enableTag: "input_boolean.light_replay_enabled"
enableVal: "on"
smartControlledByDumb: "light.bad_spot_1_2,light.bad_spot_2_2,light.bad_spot_3_2,light.buro_spot_1_2,light.buro_spot_2_2,light.buro_spot_3_2,light.buro_spot_4_2,light.elternlicht_2,light.esstischlampe_2,light.flur_spot_1_2,light.flur_spot_2_2,light.flur_spot_3_2,light.flur_spot_4_2,light.flur_spot_5_2,light.hue_ambiance_panel_1_2,light.hue_lightstrip_outdoor_1_2,light.hue_outdoor_spot_1_2,light.hue_outdoor_spot_2_2,light.insel_spot_1_2,light.insel_spot_2_2,light.kinderzimmerlampe_2,light.kinderzimmerlicht,light.kuchen_spot_1_2,light.kuchen_spot_2_2,light.kuchen_spot_3_2,light.kuchen_spot_4_2,light.kuchen_spot_5_2,light.stehlampe_2,light.treppenlicht_2,light.vorplatzlicht_1_2,light.vorplatzlicht_2_2,light.vorplatzlicht_3_2,light.wohnzimmerlampe_2"
excludeList: "light.aussen,light.badezimmer,light.buero,light.carport,light.dachgeschoss,light.deck,light.elternschlafzimmer,light.entree,light.entree_spot_1_2,light.entree_spot_2_2,light.erdgeschoss,light.esszimmer,light.haus,light.kellerflur,light.kellertreppe,light.kinderschlafzimmer,light.kuche"

Pulling sensors and automations

How would you prevent it from pulling sensors and automations with the word light in ?

`2020-02-02 20:29:17.100828 INFO AppDaemon: App initialization complete
2020-02-02 20:29:22.063329 INFO replay_lights: scheduling
2020-02-02 20:29:22.185856 INFO replay_lights: scheduling sensor.family_bathroom_light_uptime to 51296 at 2020-02-02 20:30:43.689013
2020-02-02 20:29:22.218896 INFO replay_lights: scheduling sensor.family_bathroom_light_uptime to 51356 at 2020-02-02 20:31:43.682265
2020-02-02 20:29:22.226049 INFO replay_lights: scheduling light.main_bedroom_led to on at 2020-02-02 20:32:34.216056
2020-02-02 20:29:22.246465 INFO replay_lights: scheduling sensor.family_bathroom_light_uptime to 51416 at 2020-02-02 20:32:43.689536
2020-02-02 20:29:22.263121 INFO replay_lights: scheduling light.main_bedroom_led to off at 2020-02-02 20:33:19.831963
2020-02-02 20:29:22.268674 INFO replay_lights: scheduling sensor.family_bathroom_light_wifi_signal to -71 at 2020-02-02 20:33:34.609945
2020-02-02 20:29:22.281471 INFO replay_lights: scheduling sensor.family_bathroom_light_uptime to 51476 at 2020-02-02 20:33:43.690223
2020-02-02 20:29:22.286729 INFO replay_lights: failed to parse ('{"name": "Main bedroom lights off", "entity_id": "automation.main_bedroom_lights_off"}',)
2020-02-02 20:29:22.288823 INFO replay_lights: failed to parse ('{"domain": "light", "service": "turn_off", "service_data": {"entity_id": "light.main_bedroom_lamp_left"}}',)
2020-02-02 20:29:22.291368 INFO replay_lights: failed to parse ('{"domain": "light", "service": "turn_off", "service_data": {"entity_id": "light.main_bedroom_lamp_right"}}',)
2020-02-02 20:29:22.297558 INFO replay_lights: scheduling automation.main_bedroom_lights_off to on at 2020-02-02 20:22:22.547041
2020-02-02 20:29:22.301428 WARNING replay_lights: ------------------------------------------------------------
2020-02-02 20:29:22.302931 WARNING replay_lights: Unexpected error in worker for App replay_lights:
2020-02-02 20:29:22.303518 WARNING replay_lights: Worker Ags: {'id': 'a6aec789b58942c896e7d9970c7b45a7', 'name': 'replay_lights', 'objectid': 'ee9f8c889c544da8b3ac4f62b9d23e30', 'type': 'scheduler', 'function': <bound method ReplayLights.scheduleNextEventBatch of <replay_lights.ReplayLights object at 0x7f700a00ea60>>, 'pin_app': True, 'pin_thread': 1, 'kwargs': {'interval': 3600, '__thread_id': 'thread-1'}}
2020-02-02 20:29:22.303978 WARNING replay_lights: ------------------------------------------------------------
2020-02-02 20:29:22.306630 WARNING replay_lights: Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 766, in worker
funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"]))
File "/config/appdaemon/apps/replay_lights.py", line 32, in scheduleNextEventBatch
self.run_at(self.executeEvent, event_trig_at, entity_id = entity_id, event_new_state = event_new_state)
File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 191, in inner_sync_wrapper
f = run_coroutine_threadsafe(self, coro(self, *args, **kwargs))
File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 285, in run_coroutine_threadsafe
result = future.result(self.AD.internal_function_timeout)
File "/usr/lib/python3.8/concurrent/futures/_base.py", line 432, in result
return self.__get_result()
File "/usr/lib/python3.8/concurrent/futures/_base.py", line 388, in __get_result
raise self._exception
File "/usr/lib/python3.8/site-packages/appdaemon/adapi.py", line 2248, in run_at
raise ValueError(
ValueError: replay_lights: run_at() Start time must be in the future

2020-02-02 20:29:22.307277 WARNING replay_lights: ------------------------------------------------------------
2020-02-02 20:30:44.009750 WARNING AppDaemon: Unknown service (default/light/turn_51296) in call_service from replay_lights
2020-02-02 20:30:44.013352 INFO replay_lights: turned sensor.family_bathroom_light_uptime 51296
2020-02-02 20:30:48.065302 INFO AppDaemon: New client Admin Browser connected
2020-02-02 20:31:44.014324 WARNING AppDaemon: Unknown service (default/light/turn_51356) in call_service from replay_lights
2020-02-02 20:31:44.018421 INFO replay_lights: turned sensor.family_bathroom_light_uptime 51356`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.