WorkDay Component with latest version

Is anyone using the workday component with 76.2

After upgrading I’m getting this in the logs

2018-08-21 19:34:11 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up platform workday
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 129, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/binary_sensor/workday.py", line 73, in setup_platform
    obj_holidays = getattr(holidays, country)(years=year)
AttributeError: module 'holidays' has no attribute 'US'

what’s your config look like?

 - platform: workday
   country: 'US'
   workdays: [mon, tue, wed, thu, fri]

I had it without the quotes, and then added the quotes. I reverted to the version of workday.py from 75.3 and it works. Not sure why though, it was a little beyond my skillset.

it doesn’t look like HA is the problem. The only significant lines in the file point to the resource that the workday component uses, which isn’t maintained by home assistant.

try this instead:

 - platform: workday
   country: 'UnitedStates'
   workdays: [mon, tue, wed, thu, fri]

I had used US for the past several months without issue. I’ve already changed the workday.py to the previous version from a couple weeks ago according to the check in date. That works without any change to my sensor. I will try to convert back to the updated version of the workday.py that is native to 76.x and report back.

Yeah, I understand, but for some reason the resource that is being used does not contain the US attribute. The US can be specified in 2 ways, US or UnitedStates. It could be a bug in the resource library with the US attribute.

The only changes in workday.py is the version of the holidays module went from 0.9.5 to 0.9.6, and a few more countries were allowed in the platform config (because they were added in the holidays module.) And both US and UnitedStates classes are in both 0.9.5 and 0.9.6. So, you shouldn’t be getting this error. Sounds like something messed up in your install.

I agree, I looked closely and could not find anything at all either (other than the addition of India). But… replacing 0.9.6 with .0.9.5 did β€œfix” my issue. With that said, maybe the 0.9.6 was corrupt or something during the install. I will definitely try putting it back as it was and see if I have any issues.

Updated again, and once again it stopped working, here is what I see in the logs

``
2018-09-07 21:49:46 ERROR (SyncWorker_16) [homeassistant.util.package] Unable to install package holidays==0.9.6: Exception:
Traceback (most recent call last):
File β€œ/srv/homeassistant/lib/python3.6/site-packages/pip/_internal/basecommand.py”, line 141, in main
status = self.run(options, args)
File β€œ/srv/homeassistant/lib/python3.6/site-packages/pip/_internal/commands/install.py”, line 299, in run
resolver.resolve(requirement_set)
File β€œ/srv/homeassistant/lib/python3.6/site-packages/pip/_internal/resolve.py”, line 102, in resolve
self._resolve_one(requirement_set, req)
File β€œ/srv/homeassistant/lib/python3.6/site-packages/pip/_internal/resolve.py”, line 256, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File β€œ/srv/homeassistant/lib/python3.6/site-packages/pip/_internal/resolve.py”, line 209, in _get_abstract_dist_for
self.require_hashes
File β€œ/srv/homeassistant/lib/python3.6/site-packages/pip/_internal/operations/prepare.py”, line 283, in prepare_linked_requirement
progress_bar=self.progress_bar
File β€œ/srv/homeassistant/lib/python3.6/site-packages/pip/_internal/download.py”, line 823, in unpack_url
unpack_file_url(link, location, download_dir, hashes=hashes)
File β€œ/srv/homeassistant/lib/python3.6/site-packages/pip/_internal/download.py”, line 728, in unpack_file_url
unpack_file(from_path, location, content_type, link)
File β€œ/srv/homeassistant/lib/python3.6/site-packages/pip/_internal/utils/misc.py”, line 578, in unpack_file
flatten=not filename.endswith(’.whl’)
File β€œ/srv/homeassistant/lib/python3.6/site-packages/pip/_internal/utils/misc.py”, line 463, in unzip_file
zip = zipfile.ZipFile(zipfp, allowZip64=True)
File β€œ/usr/lib/python3.6/zipfile.py”, line 1108, in init
self._RealGetContents()
File β€œ/usr/lib/python3.6/zipfile.py”, line 1175, in _RealGetContents
raise BadZipFile(β€œFile is not a zip file”)
zipfile.BadZipFile: File is not a zip file
2018-09-07 21:49:46 ERROR (MainThread) [homeassistant.requirements] Not initializing binary_sensor.workday because could not install requirement holidays==0.9.6
2018-09-07 21:49:46 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform binary_sensor.workday: Could not install all requirements.

That’s not good…

1 Like

I manually forced an install
received this

Collecting holidays==0.9.6
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Downloading https://files.pythonhosted.org/packages/f6/68/ad2c0e2dcb767b40492896dd21cad2d20b33090e86a648530813b9fc71b8/holidays-0.9.6.tar.gz (55kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 61kB 1.8MB/s
Collecting python-dateutil (from holidays==0.9.6)
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Downloading https://files.pythonhosted.org/packages/cf/f5/af2b09c957ace60dcfac112b669c45c8c97e32f94aa8b56da4c6d1682825/python_dateutil-2.7.3-py2.py3-none-any.whl (211kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 215kB 4.2MB/s
Collecting six (from holidays==0.9.6)
  Cache entry deserialization failed, entry ignored
  Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Building wheels for collected packages: holidays
  Running setup.py bdist_wheel for holidays ... done
  Stored in directory: /home/ptdalen/.cache/pip/wheels/72/ad/e3/70ef7d2d17ecee09ea2a018420f409cb82d8e19be5f1bce5df
Successfully built holidays
Installing collected packages: six, python-dateutil, holidays
Successfully installed holidays-0.9.6 python-dateutil-2.7.3 six-1.11.0

Looked like maybe it installed, but then when HA started, I got the same error. :frowning:

I’d take your issue to discord. You’re running hassbian right?

No just straight up HA on ubuntu 16.04, started after the last update to the workday component. Good advice, I’ll see what I can find, thanks

Ended up fixing this with this

pip3 install --no-cache-dir holidays==0.9.6

Aparetly my cache is corrupt, I had other issues with my upgrade related to this. Now I just need to figure out how to clear my cache.

1 Like