bob1de / hass-apps

Some useful apps and snippets to empower Home Assistant and AppDaemon even more.
Apache License 2.0
86 stars 23 forks source link

[schedy] AttributeError: 'str' object has no attribute 'copy' #77

Closed buhralex closed 2 years ago

buhralex commented 2 years ago

Hi there,

I tried to configure Schedy and ran into an issue I'm not able to fix.

ErrorLog:

2022-09-20 08:31:18.015770 INFO AppDaemon: Initializing app schedy_heating using class SchedyApp from module hass_apps_loader
2022-09-20 08:31:18.024084 INFO schedy_heating: *** Welcome to schedy 0.8.3, running on AppDaemon 4.2.1.
2022-09-20 08:31:18.025158 INFO schedy_heating: *** 
2022-09-20 08:31:18.026166 INFO schedy_heating: *** This is an app from the hass-apps package.
2022-09-20 08:31:18.027167 INFO schedy_heating: ***   DOCS: https://hass-apps.readthedocs.io/en/stable/
2022-09-20 08:31:18.028162 INFO schedy_heating: *** 
2022-09-20 08:31:18.029178 INFO schedy_heating: *** You like this app, want to honor the effort put into
2022-09-20 08:31:18.030163 INFO schedy_heating: *** it, ensure continuous development and support?
2022-09-20 08:31:18.031186 INFO schedy_heating: *** Then please consider making a donation.
2022-09-20 08:31:18.032217 INFO schedy_heating: ***   DONATE: https://hass-apps.readthedocs.io/en/stable/#donations
2022-09-20 08:31:18.033159 INFO schedy_heating: *** Thank you very much and enjoy schedy!
2022-09-20 08:31:18.034113 INFO schedy_heating: *** 
2022-09-20 08:31:18.035059 INFO schedy_heating: --- Validating the app's configuration.
2022-09-20 08:31:18.042860 WARNING schedy_heating: ------------------------------------------------------------
2022-09-20 08:31:18.043076 WARNING schedy_heating: Unexpected error running initialize() for schedy_heating
2022-09-20 08:31:18.043207 WARNING schedy_heating: ------------------------------------------------------------
2022-09-20 08:31:18.043718 WARNING schedy_heating: 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 "/usr/lib/python3.10/site-packages/hass_apps/common.py", line 96, in initialize
    self.cfg = self.Meta.config_schema(cfg)  # pylint: disable=not-callable
  File "/usr/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/lib/python3.10/site-packages/voluptuous/validators.py", line 215, in _run
    return self._exec(self._compiled, value, path)
  File "/usr/lib/python3.10/site-packages/voluptuous/validators.py", line 339, in _exec
    v = func(path, v)
  File "/usr/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
    return schema(data)
  File "/usr/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 386, in validate_mapping
    cval = cvalue(key_path, value)
  File "/usr/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
    return schema(data)
  File "/usr/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/lib/python3.10/site-packages/voluptuous/validators.py", line 215, in _run
    return self._exec(self._compiled, value, path)
  File "/usr/lib/python3.10/site-packages/voluptuous/validators.py", line 339, in _exec
    v = func(path, v)
  File "/usr/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 386, in validate_mapping
    cval = cvalue(key_path, value)
  File "/usr/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
    return schema(data)
  File "/usr/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/lib/python3.10/site-packages/voluptuous/validators.py", line 215, in _run
    return self._exec(self._compiled, value, path)
  File "/usr/lib/python3.10/site-packages/voluptuous/validators.py", line 339, in _exec
    v = func(path, v)
  File "/usr/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 635, in validate_sequence
    cval = validate(index_path, value)
  File "/usr/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
    return schema(data)
  File "/usr/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/lib/python3.10/site-packages/voluptuous/validators.py", line 215, in _run
    return self._exec(self._compiled, value, path)
  File "/usr/lib/python3.10/site-packages/voluptuous/validators.py", line 339, in _exec
    v = func(path, v)
  File "/usr/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
    return schema(data)
  File "/usr/lib/python3.10/site-packages/hass_apps/schedy/config.py", line 159, in schedule_rule_pre_hook
    rule = rule.copy()
AttributeError: 'str' object has no attribute 'copy'
2022-09-20 08:31:18.043933 WARNING schedy_heating: ------------------------------------------------------------

Here is my Schedy Configuration:

schedy_heating:  # This is our app instance name.
  module: hass_apps_loader
  class: SchedyApp

  # Enable debugging output
  debug: true

  reset_at_startup: true

  actor_type: thermostat
  actor_templates:
    default:
        supports_hvac_modes: true
        hvac_mode_on: 'auto'
        hvac_mode_off: 'off'

  rescheduling_delay: 10

  expression_environment: |
    def heating_mode():
        return state("input_select.heating_mode")
    def heizung_wartung():
        return state("input_boolean.heizung_wartung")

  watched_entities:
  - input_select.heating_mode

  schedule_prepend:
  - x: "IncludeSchedule(schedule_snippets['snippet_wartung']) if heizung_wartung() == 'on' else Next()"
  - x: "IncludeSchedule(schedule_snippets['snippet_aus']) if float(state('sensor.openweathermap_temperature') or 0) > 23 else Next()"
  - x: "Mark(OFF, Mark.OVERLAY) if not (is_empty(filter_entities('binary_sensor', state='on', window_room=room_name))) else Next()"
  - x: "Mark(OFF, Mark.OVERLAY) if not (is_empty(filter_entities('binary_sensor', state='on', window_room2=room_name))) else Next()"
  - x: "IncludeSchedule(schedule_snippets['snippet_abwesend']) if heating_mode() == 'abwesend/zeitgesteuert' else Next()"
  - x: "IncludeSchedule(schedule_snippets['snippet_aus']) if heating_mode() == 'aus' else Next()"

  schedule_snippets:

    snippet_aus:
    - value: 5

    snippet_durchgehend_wohnen:
    - value: 21

    snippet_wartung:
    - v: 20
      weeks: "*/2"
      rules:
        - weekdays: 4
          rules:
          - { start: "10:29", end: "10:30", v: 35 }
          - { start: "10:30", end: "10:31", v: 5 }
          - { start: "0:00", end: "0:00+1d" }

    snippet_schlafen:
    ## Winter ##
    - v: 18
      months: "!5-8"
      rules:
      - { start: "06:00", end: "06:15", v: 19 }
      - { start: "06:15", end: "07:00", v: 20 }
      - { start: "07:00", end: "20:00", v: 18.5 }
      - { start: "20:00", end: "21:29", v: 19 }
      - { start: "21:29", end: "21:30", v: 17 }
      - { start: "0:00", end: "0:00+1d" }
    ## Sommer ##
    - v: 5
      months: 5-8
      rules:
      - { start: "08:00", end: "20:00", v: 17 }
      - { start: "0:00", end: "0:00+1d" }

    snippet_wc:
    ## Winter ##
    - v: 17
      months: "!5-8"
      rules:
      - { start: "07:00", end: "19:00", v: 20 }
      - { start: "0:00", end: "0:00+1d" }
    ## Sommer ##
    - v: 5
      months: 5-8
      rules:
      - { start: "07:00", end: "19:00", v: 18 }
      - { start: "0:00", end: "0:00+1d" }

    snippet_abwesend:
    ## Winter ##
    - v: 16
      months: "!5-8"
      rules:
      - { start: "10:00", end: "20:00", v: 18 }
      - { start: "0:00", end: "0:00+1d" }
    ## Sommer ##
    - v: 5
      months: 5-8

    snippet_standard:
    ## Winter ##
    - v: 17
      months: "!5-8"
      rules:
      - { start: "06:15", end: "23:00", weekdays: "1-5", v: 20 }
      - { start: "07:30", end: "23:30", weekdays: "!1-5", v: 20 }
      - { start: "0:00", end: "0:00+1d" }
    ## Sommer ##
    - v: 5
      months: 5-8
      rules:
      - { start: "07:00", end: "22:00", v: 20 }
      - { start: "0:00", end: "0:00+1d" }

    snippet_standard_2:
    ## Winter ##
    - v: 17
      months: "!5-8"
      rules:
      - { start: "07:00", end: "21:00", weekdays: "1-5", v: 20 }
      - { start: "07:30", end: "22:00", weekdays: "!1-5", v: 20 }
      - { start: "0:00", end: "0:00+1d" }
    ## Sommer ##
    - v: 5
      months: 5-8
      rules:
      - { start: "07:00", end: "22:00", v: 20 }
      - { start: "0:00", end: "0:00+1d" }

    snippet_gast:
    ## Winter ##
    - v: 17
      months: "!5-8"
      rules:
      - { start: "07:00", end: "21:00", weekdays: "1-5", v: 20 }
      - { start: "07:30", end: "22:00", weekdays: "!1-5", v: 20 }
      - { start: "0:00", end: "0:00+1d" }
    ## Sommer ##
    - v: 5
      months: 5-8
      rules:
      - { start: "07:00", end: "20:00", v: 20 }
      - { start: "0:00", end: "0:00+1d" }

    watched_entities:
    - input_select.heating_mode
    - sensor.openweathermap_temperature
    - input_boolean.heizung_wartung

#################

  rooms:  

####### #########

#   Gästezimmer:
#     rescheduling_delay: 15
#     watched_entities:
#     - sensor.mobiler_sensor_temperature
#     - binary_sensor.bibliothek_sensor_dachfenster_contact
#     - binary_sensor.gastezimmer_fenster_links_contact
#     - binary_sensor.gastezimmer_fenster_links_contact
#     - binary_sensor.gastezimmer_dachfenster_gross_contact
#     - binary_sensor.gastezimmer_dachfenster_klein_contact
#     actors:
#       climate.gastezimmer_heizung:
#         min_temp: 5
#         max_temp: 35

#     schedule:
#     - x: "IncludeSchedule(schedule_snippets['snippet_aus']) if float(state('sensor.mobiler_sensor_temperature') or 0) > 22 else Next()"
#     - x: "IncludeSchedule(schedule_snippets['snippet_gast']) if heating_mode() == 'anwesend/gast' else Next()"
#     - x: "IncludeSchedule(schedule_snippets['snippet_abwesend']) if heating_mode() == 'anwesend/zeitgesteuert' else Next()"
#     - x: "IncludeSchedule(schedule_snippets['snippet_durchgehend_wohnen']) if heating_mode() == 'durchgehend aktiv' else Next()"

####### #########

  Schlafzimmer:
    rescheduling_delay: 20
    watched_entities:
    - sensor.master_bedroom_multisensor_temperature
    - binary_sensor.bedroom_window
    actors:
      climate.master_bedroom_thermostat:
        min_temp: 5
        max_temp: 35
        off_temp: 5
        supports_hvac_modes: false
    schedule:
    - x: "IncludeSchedule(schedule_snippets['snippet_aus']) if float(state('sensor.master_bedroom_multisensor_temperature') or 0) > 21 else Next()"
    - x: "IncludeSchedule(schedule_snippets['snippet_schlafen']) if heating_mode() == 'anwesend/gast' else Next()"
    - x: "IncludeSchedule(schedule_snippets['snippet_schlafen']) if heating_mode() == 'anwesend/zeitgesteuert' else Next()"
    - x: "IncludeSchedule(schedule_snippets['snippet_durchgehend_wohnen']) if heating_mode() == 'durchgehend aktiv' else Next()"

####### #########

  WC:
    rescheduling_delay: 10
    watched_entities:
    - binary_sensor.bathroom_window
    actors:
      climate.master_bathroom_thermostat:
        min_temp: 5
        max_temp: 35
    schedule:
    - x: "IncludeSchedule(schedule_snippets['snippet_aus']) if float(state('sensor.openweathermap_temperature') or 0) > 21 else Next()"
    - x: "IncludeSchedule(schedule_snippets['snippet_wc']) if heating_mode() == 'anwesend/gast' else Next()"
    - x: "IncludeSchedule(schedule_snippets['snippet_wc']) if heating_mode() == 'anwesend/zeitgesteuert' else Next()"
    - x: "IncludeSchedule(schedule_snippets['snippet_durchgehend_wohnen']) if heating_mode() == 'durchgehend aktiv' else Next()"

####### #########
buhralex commented 2 years ago

Found the problem.

indentation error

Issue can be closed