Open ramrom opened 1 year ago
same here : hass-cli version: 0.9.6 hass core version: 2023.03.04 python 3.10.6 & 3.9.2
same issue here too
hass-cli -x state history --since 50m binary_sensor.fp1_home_office_occupancy
bad escape \d at position 7
Traceback (most recent call last):
File "/opt/homebrew/Cellar/homeassistant-cli/0.9.6/libexec/lib/python3.11/site-packages/homeassistant_cli/cli.py", line 40, in run
result = cli.main(standalone_mode=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/homeassistant-cli/0.9.6/libexec/lib/python3.11/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/homeassistant-cli/0.9.6/libexec/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/homeassistant-cli/0.9.6/libexec/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/homeassistant-cli/0.9.6/libexec/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/homeassistant-cli/0.9.6/libexec/lib/python3.11/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/homeassistant-cli/0.9.6/libexec/lib/python3.11/site-packages/click/decorators.py", line 84, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/homeassistant-cli/0.9.6/libexec/lib/python3.11/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/homeassistant-cli/0.9.6/libexec/lib/python3.11/site-packages/homeassistant_cli/plugins/state.py", line 288, in history
start_time = dateparser.parse(since, settings=settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/homeassistant-cli/0.9.6/libexec/lib/python3.11/site-packages/dateparser/conf.py", line 85, in wrapper
return f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/homeassistant-cli/0.9.6/libexec/lib/python3.11/site-packages/dateparser/__init__.py", line 53, in parse
data = parser.get_date_data(date_string, date_formats)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/homeassistant-cli/0.9.6/libexec/lib/python3.11/site-packages/dateparser/date.py", line 417, in get_date_data
parsed_date = _DateLocaleParser.parse(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/homeassistant-cli/0.9.6/libexec/lib/python3.11/site-packages/dateparser/date.py", line 194, in parse
return instance._parse()
^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/homeassistant-cli/0.9.6/libexec/lib/python3.11/site-packages/dateparser/date.py", line 198, in _parse
date_obj = self._parsers[parser_name]()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/homeassistant-cli/0.9.6/libexec/lib/python3.11/site-packages/dateparser/date.py", line 212, in _try_freshness_parser
return freshness_date_parser.get_date_data(self._get_translated_date(), self._settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/homeassistant-cli/0.9.6/libexec/lib/python3.11/site-packages/dateparser/date.py", line 261, in _get_translated_date
self._translated_date = self.locale.translate(
^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/homeassistant-cli/0.9.6/libexec/lib/python3.11/site-packages/dateparser/languages/locale.py", line 135, in translate
relative_translations = self._get_relative_translations(settings=settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/homeassistant-cli/0.9.6/libexec/lib/python3.11/site-packages/dateparser/languages/locale.py", line 164, in _get_relative_translations
self._generate_relative_translations(normalize=True))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/homeassistant-cli/0.9.6/libexec/lib/python3.11/site-packages/dateparser/languages/locale.py", line 178, in _generate_relative_translations
pattern = DIGIT_GROUP_PATTERN.sub(r'?P<n>\d+', pattern)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/homeassistant-cli/0.9.6/libexec/lib/python3.11/site-packages/regex/regex.py", line 710, in _compile_replacement_helper
is_group, items = _compile_replacement(source, pattern, is_unicode)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/homeassistant-cli/0.9.6/libexec/lib/python3.11/site-packages/regex/_regex_core.py", line 1737, in _compile_replacement
raise error("bad escape \\%s" % ch, source.string, source.pos)
regex._regex_core.error: bad escape \d at position 7
If you installed with homebrew: The following worked for me, for now...
pip install --upgrade --target /opt/homebrew/lib/python3.11/site-packages/ dateparser
Has someone found out more on this ?
Still same error on hass-cli version: 0.9.7 when invoked like
hass-cli state history --since 360m sensor.esphome_web_d43035_gasverbrauch
or any other way of hass-cli state history ENTITY
ok, so I figured it out ... the websocket response to to large for the default max of the library... I've put together a PR here but I am having trouble getting the tests to pass... If you want to install my branch you will just need to add an env var to increase the max websocket response. The default seems to be 4mb and I got it working when I went to 5mb
$ hass-cli state history sun.sun error: error: bad escape \d at position 7
This is because of some regex behavior change introduced in regex 2022.3.15, which breaks dateparser: https://github.com/scrapinghub/dateparser/issues/1045
dateparser >= 1.1.4 should be fixed but unfortunately homeassistant-cli locks dateparser at (>=0.7.1,<0.8): https://github.com/home-assistant-ecosystem/home-assistant-cli/blob/0.9.6/setup.py#L85
The dev-Branch lifts that restriction but unfortunately there is no released version yet.
@leo-b odd... I'm curious how my max payload size fix for websockets was able to get around this issue then? I ask because I've been using my fork for a while now with zero reocurance of the issue since my "fix" .... Possible we might have been having similar but different issues?
On macOS, if you install via pipx (pipx install homeassistant-cli
), you can inject a new version of dateparser with pipx inject homeassistant-cli dateparser==1.2.0
.
Just ran into the same issue. homeassistant-cli
seems to have an incorrect requirement on the dateparser
version be dateparser<0.8,>=0.7.1
. But forcibly using a newer version of dateparser
works fine. I fixed it by doing this:
$ pip3 uninstall dateparser -y
$ pip install "dateparser>=1.2.0"
Edit: it seems that this https://github.com/home-assistant-ecosystem/home-assistant-cli/commit/d4e23121016786a88992ffeabda2de6c5df1f29f commit fixed the incorrect dateparser
version requirement. However, there hasn't been a release of homeassistant-cli
since that commit. So just installing the HEAD version will probably fix it. (probably time to do another release)
Running a
hass-cli state history ENTITY
command for any entity fails:I ran it with the
-x
option as suggested:I've had no issues running basically any other command (the tool is great!).
hass-cli version: 0.9.4 hass core version: 2022.12.1