nickknissen / hass-monta

Monta Home Assistant custom component
MIT License
24 stars 1 forks source link

Add wallet transactions #85

Closed RogerSelwyn closed 4 months ago

RogerSelwyn commented 4 months ago

I had a couple of old transactions in my personal wallet, so I've added the api call and setup to create a personal wallet sensor. Currently this is set to retrieve the last 7 days, but potentially that could be configureable.

Not sure if there are other wallets it could retrieve, it certainly doesn't retrieve data from my enterprise team wallet.

I split this into two commits because my dev environment is setup using standard HA dev container which automatically does some formatting. The first commit makes no code changes, it is just formatting.

RogerSelwyn commented 4 months ago

This may answer this request - https://github.com/nickknissen/hass-monta/issues/65

nickknissen commented 4 months ago

Hi @RogerSelwyn

Thank you for your contribution! I've made some changes to how many wallet transactions are fetched. If you have transactions older than 7 days they are not fetched. So fare as i can see wallet transactions fetched by newest transactions first.

RogerSelwyn commented 4 months ago

Good for me, I only have 2 so couldn’t tell if it would bring everything or just a reasonable set

Bluhme1 commented 4 months ago

@nickknissen Thank you for the update.

A few remarks. No update in Hacs.

When I install manually I get the following error. (Everything fine with @RogerSelwyn ,s PR)

`Setup failed for custom integration 'monta': Unable to import component: cannot import name 'ATTR_CHARGEPOINTS' from 'custom_components.monta.const' (/config/custom_components/monta/const.py) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/loader.py", line 981, in async_get_component comp = await self.hass.async_add_import_executor_job( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, *self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 1041, in _get_component ComponentProtocol, importlib.import_module(self.pkg_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/util/loop.py", line 144, in protected_loop_func return func(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/importlib/init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1331, in _find_and_load_unlocked File "", line 935, in _load_unlocked File "", line 995, in exec_module File "", line 488, in _call_with_frames_removed File "/config/custom_components/monta/init.py", line 17, in from .services import async_setup_services File "/config/custom_components/monta/services.py", line 10, in from .const import ATTR_CHARGEPOINTS, DOMAIN ImportError: cannot import name 'ATTR_CHARGEPOINTS' from 'custom_components.monta.const' (/config/custom_components/monta/const.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/setup.py", line 322, in _async_setup_component component = await integration.async_get_component() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 1001, in async_get_component self._component_future.result() File "/usr/src/homeassistant/homeassistant/loader.py", line 993, in async_get_component comp = self._get_component() ^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 1041, in _get_component ComponentProtocol, importlib.import_module(self.pkg_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/util/loop.py", line 144, in protected_loop_func return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/importlib/init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1331, in _find_and_load_unlocked File "", line 935, in _load_unlocked File "", line 995, in exec_module File "", line 488, in _call_with_frames_removed File "/config/custom_components/monta/init.py", line 17, in from .services import async_setup_services File "/config/custom_components/monta/services.py", line 10, in from .const import ATTR_CHARGEPOINTS, DOMAIN ImportError: cannot import name 'ATTR_CHARGEPOINTS' from 'custom_components.monta.const' (/config/custom_components/monta/const.py) `

nickknissen commented 4 months ago

@Bluhme1 I have not had the time to test it properly after my changes. Since a new release has not been issued.

I have fixed the problem you encountered on the main branch. Will do a proper release after i have done some more testing.

Bluhme1 commented 4 months ago

@nickknissen No problem. I just want to contribute the best I can. Not being a programmer I contribute by testing. (and some feature requests) I think you and @RogerSelwyn have made a very complete and mature integration Thank you

And the latest fix works