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

Ommision of leading zero in time value in schedule crashes the app #9

Closed mradziwo closed 6 years ago

mradziwo commented 6 years ago

Providing a time without leading zero (e.g. 6:55 instead of 06:55) crashes the app with following - a bit misleading error.

I'd suggest to add H:MM handling. heaty v0.12.1

2018-03-10 18:13:18.957945 WARNING AppDaemon: Unexpected initializing app: heaty:
2018-03-10 18:13:18.958104 WARNING AppDaemon: ------------------------------------------------------------
2018-03-10 18:13:18.958547 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1927, in check_app_updates
    self.init_object(app)
  File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1477, in init_object
    self.objects[name]["object"].initialize()
  File "/usr/local/lib/python3.6/site-packages/hass_apps/common.py", line 86, in initialize
    self.cfg = self.Meta.config_schema(cfg)  # pylint: disable=not-callable
  File "/usr/local/lib/python3.6/site-packages/voluptuous/schema_builder.py", line 267, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.6/site-packages/voluptuous/validators.py", line 204, in _run
    return self._exec(self._compiled, value, path)
  File "/usr/local/lib/python3.6/site-packages/voluptuous/validators.py", line 284, in _exec
    raise e if self.msg is None else AllInvalid(self.msg)
  File "/usr/local/lib/python3.6/site-packages/voluptuous/validators.py", line 282, in _exec
    v = func(path, v)
  File "/usr/local/lib/python3.6/site-packages/voluptuous/schema_builder.py", line 769, in validate_callable
    return schema(data)
  File "/usr/local/lib/python3.6/site-packages/voluptuous/schema_builder.py", line 267, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.6/site-packages/voluptuous/schema_builder.py", line 587, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.6/site-packages/voluptuous/schema_builder.py", line 425, in validate_mapping
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: does not match regular expression for dictionary value @ data['rooms']['living']['schedule'][0]['end']

2018-03-10 18:13:18.958854 WARNING AppDaemon: ------------------------------------------------------------
bob1de commented 6 years ago

Yes, the error messages generated by voluptuous aren't perfect. :-)

bob1de commented 6 years ago

Hi again,

Do you think allowing 7:4 instead of 7:04 makes sense as well? I've never seen such a format and would tend to not support it.

Best regards Robert

mradziwo commented 6 years ago

no, it has never occurred to me. Though H:MM:SS format is out from ISO 8601:2004 standard, it's widely used when manual typing of time is required and IEEE recommends or handling directly H:MM format or support entry manipulation to treat H:MM as 0H:MM. I could try to dig out the IEEE publication if you'd like it.

Best regards, Michał Radziwon

On 13 March 2018 at 08:03, Robert Schindler notifications@github.com wrote:

Hi again,

Do you think allowing 7:4 instead of 7:04 makes sense as well? I've never seen such a format and would tend to not support it.

Best regards Robert

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/efficiosoft/hass-apps/issues/9#issuecomment-372566609, or mute the thread https://github.com/notifications/unsubscribe-auth/AI1rE8fhZ8mFmDYKVbcPRvqO--HVs1xtks5td29FgaJpZM4Sl02W .

bob1de commented 6 years ago

No thanks, I think the behaviour is fine now.

Thank you for reporting.

Best regards Robert