[solved] Why does YAML not interpret 12:00:00 as string?

Writing times without quotes in appdaemon.yaml gives me a TypeError like the following:

my_app:
    constrain_start_time: 20:00:00

The traceback:

2017-07-19 22:03:58.495332 WARNING Traceback (most recent call last):
  File "/srv/hass_0_48/lib/python3.4/site-packages/appdaemon/appdaemon.py", line 775, in process_message
    process_state_change(data)
  File "/srv/hass_0_48/lib/python3.4/site-packages/appdaemon/appdaemon.py", line 726, in process_state_change
    callback["kwargs"]
  File "/srv/hass_0_48/lib/python3.4/site-packages/appdaemon/appdaemon.py", line 664, in check_and_disapatch
    "kwargs": kwargs
  File "/srv/hass_0_48/lib/python3.4/site-packages/appdaemon/appdaemon.py", line 258, in dispatch_worker
    if not check_time_constraint(config[name], name):
  File "/srv/hass_0_48/lib/python3.4/site-packages/appdaemon/appdaemon.py", line 244, in check_time_constraint
    if not ha.now_is_between(start_time, end_time, name):
  File "/srv/hass_0_48/lib/python3.4/site-packages/appdaemon/homeassistant.py", line 132, in now_is_between
    start_time = parse_time(start_time_str, name)
  File "/srv/hass_0_48/lib/python3.4/site-packages/appdaemon/homeassistant.py", line 80, in parse_time
    parts = re.search('^(\d+):(\d+):(\d+)', time_str)
  File "/srv/hass_0_48/lib/python3.4/re.py", line 166, in search
    return _compile(pattern, flags).search(string)
TypeError: expected string or buffer

Changing to include quotes in the YAML file:

my_app:
    constrain_start_time: "20:00:00"

and it works. I thought that values in YAML that contained non-number characters (i.e. the colon) would be interpreted as strings. All appdaemon examples have the time strings without quotes… Anyone have any ideas?

I’m using Home Assistant v0.49.0 (despite the path name :wink: and appdaemon 2.0.4b2 on Raspbian jessie (8.0) with Python 3.4.2 and PyYAML v3.12

Edit: Can’t find the checkmark to mark the thread solved so I edited the title instead…

i guess yaml sees it as a time instead of a string
i think the examples are still partly untested with yaml?
@aimc

Correct - I haven’t tried every combination with YAML yet, and YAML is a funny animal at times :slight_smile:

2 Likes

he, i didnt change AD to YAML :stuck_out_tongue:

Ok, thanks, then I’m fine.

Just for learning, I tried to do my first ever pull request :slight_smile:

1 Like

I have it - thanks! I’ll merge it in for the next release.