sebrut / pygrocy Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
This issue custom-components/grocy#96 seems to have it's base in this line.
If I change to json instead of data, like this, it works:
resp = requests.post( req_url, verify=self._verify_ssl, headers=self._headers, json=data )
pygrocy/pygrocy/grocy_api_client.py
Line 492 in 9514df4
First of all, very cool project, it seems to make very straight forward to integrate grocy with other systems.
I would like to add/consume products by scanning their barcodes unfortunately I haven't found a way to retrieve the product_id by giving the barcode, is it that possible?
In the grocy-pyscanner they do it by a get request, so it is possible bu I haven't found how to do it in pygrocy.
Thanks a lot!
Should be who-least-did-first
Line 185 in 066993d
Traceback (most recent call last):
File "/config/custom_components/grocy/init.py", line 227, in async_update_chores
] = await self.hass.async_add_executor_job(wrapper)
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/grocy/init.py", line 223, in wrapper
return self.client.chores(True)
File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy.py", line 461, in chores
chore.get_details(self._api_client)
File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy.py", line 243, in get_details
self._init_from_ChoreDetailsResponse(details)
File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy.py", line 221, in _init_from_ChoreDetailsResponse
self._assignment_type = Chore.AssignmentType(chore_data.assignment_type)
File "/usr/local/lib/python3.8/enum.py", line 304, in call
return cls.new(cls, value)
File "/usr/local/lib/python3.8/enum.py", line 595, in new
raise exc
File "/usr/local/lib/python3.8/enum.py", line 579, in new
result = cls.missing(value)
File "/usr/local/lib/python3.8/enum.py", line 608, in missing
raise ValueError("%r is not a valid %s" % (value, cls.name))
ValueError: 'who-least-did-first' is not a valid AssignmentType
Dependabot couldn't authenticate with https://pypi.python.org/simple/.
You can provide authentication details in your Dependabot dashboard by clicking into the account menu (in the top right) and selecting 'Config variables'.
When implementing stuff in grocy-telegram-bot using the remove_product_in_shopping_list()
and add_product()
methods of pygrocy I stumbled over the fact that the first does return the HTTP response but the latter does not. This is a problem, especially since you do not use the response.raise_for_status()
method, because errors happening on the API side will just get lost, even if the developer was cautious enough to check the method result.
I don't know if you have a plan on how to deal with this going forward, but imho pygrocy should never return any HTTP related data back to the developer using the library since that would negate the whole point of an abstraction layer.
In a different project I was involved with we always used the raise_for_status()
method. Imho a little restructuring would greatly benefit the readability and simplicity of the API call related methods. Have a look at the _do_request
method here which allowed us to turn all of the API call methods into one-liners.
PS: I know you are currently busy, so I don't expect you to do anything. A little heads up would be great though π€
Some tests missing: grocy.py
I have set up Grocy as an HA-Addon and wanted to use the lovelace-grocy-chores-card which needs the grocy_chores sensor.
I installed this integration through HACS, and I was finally able to configure the integration by using my internal HA url https://10.0.2.3:9192/grocy/public/api/ even though I use a duckdns domain through the HA NGINX proxy manager.
The issue I am getting is that the new Grocy sensors are all showing as unknown. If I check the API key it shows that the integration is connecting ok.
I checked the logs and this is what it shows:
2021-02-25 20:34:08 DEBUG (MainThread) [custom_components.grocy.config_flow] Step user
2021-02-25 20:34:08 DEBUG (MainThread) [custom_components.grocy.config_flow] Testing credentials
2021-02-25 20:34:08 DEBUG (MainThread) [custom_components.grocy.config_flow] Testing of credentials returned:
2021-02-25 20:34:08 DEBUG (MainThread) [custom_components.grocy.config_flow] True
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.setup] Setting up grocy
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.setup] Setup of domain grocy took 0.0 seconds
2021-02-25 20:34:08 INFO (MainThread) [custom_components.grocy]
-------------------------------------------------------------------
Grocy
Version: v2.2.2
This is a custom integration!
If you have any issues with this you need to open an issue here:
https://github.com/custom-components/grocy/issues
-------------------------------------------------------------------
2021-02-25 20:34:08 DEBUG (MainThread) [custom_components.grocy] Finished fetching grocy data in 0.027 seconds
2021-02-25 20:34:08 WARNING (MainThread) [homeassistant.components.binary_sensor] BinarySensorDevice is deprecated, modify GrocyBinarySensor to extend BinarySensorEntity
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.grocy
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.grocy
2021-02-25 20:34:08 DEBUG (MainThread) [custom_components.grocy.binary_sensor] Adding GrocyEntityType.EXPIRED_PRODUCTS binary sensor
2021-02-25 20:34:08 DEBUG (MainThread) [custom_components.grocy.binary_sensor] Adding GrocyEntityType.EXPIRING_PRODUCTS binary sensor
2021-02-25 20:34:08 DEBUG (MainThread) [custom_components.grocy.binary_sensor] Adding GrocyEntityType.MISSING_PRODUCTS binary sensor
2021-02-25 20:34:08 DEBUG (MainThread) [custom_components.grocy.binary_sensor] Adding GrocyEntityType.OVERDUE_CHORES binary sensor
2021-02-25 20:34:08 DEBUG (MainThread) [custom_components.grocy.binary_sensor] Adding GrocyEntityType.OVERDUE_TASKS binary sensor
2021-02-25 20:34:08 DEBUG (MainThread) [custom_components.grocy.sensor] Adding GrocyEntityType.CHORES sensor
2021-02-25 20:34:08 DEBUG (MainThread) [custom_components.grocy.sensor] Adding GrocyEntityType.MEAL_PLAN sensor
2021-02-25 20:34:08 DEBUG (MainThread) [custom_components.grocy.sensor] Adding GrocyEntityType.SHOPPING_LIST sensor
2021-02-25 20:34:08 DEBUG (MainThread) [custom_components.grocy.sensor] Adding GrocyEntityType.STOCK sensor
2021-02-25 20:34:08 DEBUG (MainThread) [custom_components.grocy.sensor] Adding GrocyEntityType.TASKS sensor
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.grocy entity: binary_sensor.grocy_expiring_products
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.components.binary_sensor] Not adding entity Grocy expiring products because it's disabled
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.grocy entity: binary_sensor.grocy_missing_products
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.components.binary_sensor] Not adding entity Grocy missing products because it's disabled
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.grocy entity: binary_sensor.grocy_overdue_chores
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.components.binary_sensor] Not adding entity Grocy overdue chores because it's disabled
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.grocy entity: binary_sensor.grocy_overdue_tasks
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.components.binary_sensor] Not adding entity Grocy overdue tasks because it's disabled
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.grocy entity: sensor.grocy_chores
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.components.sensor] Not adding entity Grocy chores because it's disabled
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.grocy entity: sensor.grocy_meal_plan
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.components.sensor] Not adding entity Grocy meal plan because it's disabled
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.grocy entity: sensor.grocy_shopping_list
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.components.sensor] Not adding entity Grocy shopping list because it's disabled
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.grocy entity: sensor.grocy_stock
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.components.sensor] Not adding entity Grocy stock because it's disabled
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.grocy entity: sensor.grocy_tasks
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.components.sensor] Not adding entity Grocy tasks because it's disabled
2021-02-25 20:34:08 ERROR (MainThread) [custom_components.grocy] Update of Expired_products failed with 404 Client Error: Not Found for url: https://10.0.2.3:9192/grocy/public/api/:9192/api/system/db-changed-time
2021-02-25 20:34:08 DEBUG (MainThread) [custom_components.grocy] Finished fetching grocy data in 0.080 seconds
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.grocy entity: binary_sensor.grocy_expired_products
2021-02-25 20:34:08 INFO (MainThread) [homeassistant.components.binary_sensor] Not adding entity Grocy expired products because it's disabled
I have manually enabled the sensors, but the sensors still show as unknown.
2021-02-25 20:41:09 INFO (MainThread) [homeassistant.config_entries] Reloading configuration entries because disabled_by changed in entity registry:
2021-02-25 20:41:09 DEBUG (MainThread) [custom_components.grocy] Unloading with state loaded
2021-02-25 20:41:09 DEBUG (MainThread) [custom_components.grocy] Unloaded? True
2021-02-25 20:41:09 INFO (MainThread) [custom_components.grocy]
-------------------------------------------------------------------
Grocy
Version: v2.2.2
This is a custom integration!
If you have any issues with this you need to open an issue here:
https://github.com/custom-components/grocy/issues
-------------------------------------------------------------------
2021-02-25 20:41:09 INFO (SyncWorker_35) [custom_components.authenticated.sensor] New successful login from known IP (172.30.33.10)
2021-02-25 20:41:10 DEBUG (MainThread) [custom_components.grocy] Finished fetching grocy data in 0.359 seconds
2021-02-25 20:41:10 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.grocy
2021-02-25 20:41:10 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.grocy
2021-02-25 20:41:10 DEBUG (MainThread) [custom_components.grocy.binary_sensor] Adding GrocyEntityType.EXPIRED_PRODUCTS binary sensor
2021-02-25 20:41:10 DEBUG (MainThread) [custom_components.grocy.binary_sensor] Adding GrocyEntityType.EXPIRING_PRODUCTS binary sensor
2021-02-25 20:41:10 DEBUG (MainThread) [custom_components.grocy.binary_sensor] Adding GrocyEntityType.MISSING_PRODUCTS binary sensor
2021-02-25 20:41:10 DEBUG (MainThread) [custom_components.grocy.binary_sensor] Adding GrocyEntityType.OVERDUE_CHORES binary sensor
2021-02-25 20:41:10 DEBUG (MainThread) [custom_components.grocy.binary_sensor] Adding GrocyEntityType.OVERDUE_TASKS binary sensor
2021-02-25 20:41:10 DEBUG (MainThread) [custom_components.grocy.sensor] Adding GrocyEntityType.CHORES sensor
2021-02-25 20:41:10 DEBUG (MainThread) [custom_components.grocy.sensor] Adding GrocyEntityType.MEAL_PLAN sensor
2021-02-25 20:41:10 DEBUG (MainThread) [custom_components.grocy.sensor] Adding GrocyEntityType.SHOPPING_LIST sensor
2021-02-25 20:41:10 DEBUG (MainThread) [custom_components.grocy.sensor] Adding GrocyEntityType.STOCK sensor
2021-02-25 20:41:10 DEBUG (MainThread) [custom_components.grocy.sensor] Adding GrocyEntityType.TASKS sensor
2021-02-25 20:41:10 ERROR (MainThread) [custom_components.grocy] Update of Expired_products failed with 404 Client Error: Not Found for url: https://10.0.2.3:9192/grocy/public/api/:9192/api/system/db-changed-time
2021-02-25 20:41:10 ERROR (MainThread) [custom_components.grocy] Update of Expiring_products failed with 404 Client Error: Not Found for url: https://10.0.2.3:9192/grocy/public/api/:9192/api/system/db-changed-time
2021-02-25 20:41:10 ERROR (MainThread) [custom_components.grocy] Update of Missing_products failed with 404 Client Error: Not Found for url: https://10.0.2.3:9192/grocy/public/api/:9192/api/system/db-changed-time
2021-02-25 20:41:10 ERROR (MainThread) [custom_components.grocy] Update of Overdue_chores failed with 404 Client Error: Not Found for url: https://10.0.2.3:9192/grocy/public/api/:9192/api/system/db-changed-time
2021-02-25 20:41:10 ERROR (MainThread) [custom_components.grocy] Update of Overdue_tasks failed with 404 Client Error: Not Found for url: https://10.0.2.3:9192/grocy/public/api/:9192/api/system/db-changed-time
2021-02-25 20:41:10 ERROR (MainThread) [custom_components.grocy] Update of Chores failed with 404 Client Error: Not Found for url: https://10.0.2.3:9192/grocy/public/api/:9192/api/system/db-changed-time
2021-02-25 20:41:10 ERROR (MainThread) [custom_components.grocy] Update of Meal_plan failed with 404 Client Error: Not Found for url: https://10.0.2.3:9192/grocy/public/api/:9192/api/system/db-changed-time
2021-02-25 20:41:10 ERROR (MainThread) [custom_components.grocy] Update of Shopping_list failed with 404 Client Error: Not Found for url: https://10.0.2.3:9192/grocy/public/api/:9192/api/system/db-changed-time
2021-02-25 20:41:10 ERROR (MainThread) [custom_components.grocy] Update of Stock failed with 404 Client Error: Not Found for url: https://10.0.2.3:9192/grocy/public/api/:9192/api/system/db-changed-time
2021-02-25 20:41:10 ERROR (MainThread) [custom_components.grocy] Update of Tasks failed with 404 Client Error: Not Found for url: https://10.0.2.3:9192/grocy/public/api/:9192/api/system/db-changed-time
2021-02-25 20:41:10 DEBUG (MainThread) [custom_components.grocy] Finished fetching grocy data in 0.637 seconds
Clearly, I have done something wrong and I really believe that the api url is not right, but it is the only one I can get the integration to configure with.
Any help to find the error would be greatly appreciated.
Thank you
Dependabot can't evaluate your Python dependency files.
As a result, Dependabot couldn't check whether any of your dependencies are out-of-date.
The error Dependabot encountered was:
InstallationError("Invalid requirement: 'requests=2.21.0'\n= is not a valid operator. Did you mean == ?",)
You can mention @dependabot in the comments below to contact the Dependabot team.
CodeFactor found multiple issues last seen at 9ba4533:
len(SEQUENCE)
to determine if a sequence is emptypygrocy\grocy_api_client.py:242
pygrocy\grocy_api_client.py:256
Some stuff missing: https://coveralls.io/builds/28232582/source?filename=pygrocy/grocy_api_client.py
Hi
Regarding this commit : grocy/grocy@61a45c0
I will do a refresh on product functions. It will clearly speed up refresh data.
Keep in touch
Describe the bug
I cannot access the UI of Home Assistant.
In the home-assistant.log I found lots of errors like this:
2021-03-08 12:21:42 ERROR (MainThread) [homeassistant.components.websocket_api.messages] Unable to serialize to JSON. Bad data found at $.event(event: state_changed).data.new_state(state: binary_sensor.grocy_missing_products).attributes.missing[0].product_barcodes[0]=<pygrocy.grocy_api_client.ProductBarcode object at 0xa7bcac40>(<class 'pygrocy.grocy_api_client.ProductBarcode'>
2021-03-08 12:21:42 WARNING (Recorder) [homeassistant.components.recorder] State is not JSON serializable: <state binary_sensor.grocy_missing_products=on; missing=[{'name': 'My product name', 'id': 5, 'product_group_id': None, 'available_amount': None, 'best_before_date': None, 'barcodes': ['20456887'], 'product_barcodes': [<pygrocy.grocy_api_client.ProductBarcode object at 0xa7bcac40>], 'amount_missing': 1.0, 'is_partly_in_stock': False}], friendly_name=Grocy missing products, icon=GrocyEntityIcon.MISSING_PRODUCTS @ 2021-03-08T12:21:42.740123+02:00>
2021-03-08 12:21:47 ERROR (MainThread) [homeassistant.components.http.view] Unable to serialize to JSON: Object of type ProductBarcode is not JSON serializable
The log file grows to 1GB and maybe more.
Expected behavior
Being able to use the lovelace UI as before.
To Reproduce
Steps to reproduce the behavior:
What is your installed versions of Home Assistant, Grocy and this integration?
Home Assistant core-2021.3.2
Grocy v3.0.1
Grocy integration v3.0.1
How do you have Grocy installed? Add-on or external?
add-on
Have you added debugging to the log, and what does the log say?
no
JSON service data (if related to using a service)
n/a
Additional context
I had to hard reboot my Raspberry Pi and then disable quickly the Grocy integration add-on.
If not doing that quickly after reboot, I have the same issue.
Hi.
What do you think about changing base url like : https://{HOST}:{PORT}
removing /api/ (I saw some confusion from users)
(Default port for Grocy is 9192, can optional)
Regards :)
There are a lot of changes in the 3.x version. Some things seems to have broken.
If grocy in not host at the root of a web server but in an other directory every request failed due to the base_url not complete.
This is done in line
pygrocy/pygrocy/grocy_api_client.py
Line 294 in 8787acc
In this case the port may be add behind a full path like http://grocy.localdomain/grocy/public/:80/api/stock
Wich can't be available.
I tried to disable some of the stock features I don't need.
# Sub feature flags
Setting('FEATURE_FLAG_STOCK_PRICE_TRACKING', false);
Setting('FEATURE_FLAG_STOCK_LOCATION_TRACKING', false);
Setting('FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING', true);
Setting('FEATURE_FLAG_STOCK_PRODUCT_OPENED_TRACKING', true);
Setting('FEATURE_FLAG_STOCK_PRODUCT_FREEZING', false);
Setting('FEATURE_FLAG_SHOPPINGLIST_MULTIPLE_LISTS', false);
Setting('FEATURE_FLAG_CHORES_ASSIGNMENTS', false);
But this leads to various exceptions when reading the expired products:
Traceback (most recent call last):
...
File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy.py", line 179, in expired_products
item.get_details(self._api_client)
File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy.py", line 24, in get_details
details = api_client.get_product(self.product_id)
File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy_api_client.py", line 322, in get_product
return ProductDetailsResponse(parsed_json)
File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy_api_client.py", line 231, in __init__
self._location = LocationData(parsed_json.get('location'))
File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy_api_client.py", line 52, in __init__
self._id = parse_int(parsed_json.get('id'))
AttributeError: 'NoneType' object has no attribute 'get'
And
Traceback (most recent call last):
...
File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy.py", line 199, in chores
raw_chores = self._api_client.get_chores()
File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy_api_client.py", line 328, in get_chores
return [CurrentChoreResponse(chore) for chore in parsed_json]
File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy_api_client.py", line 328, in <listcomp>
return [CurrentChoreResponse(chore) for chore in parsed_json]
File "/usr/local/lib/python3.7/site-packages/pygrocy/grocy_api_client.py", line 156, in __init__
self._chore_id = parse_int(parsed_json.get('chore_id'), None)
AttributeError: 'str' object has no attribute 'get'
as noted in #72 currently most assertions arent being done with the assertions of the unittest package. All assertions should get replaced by the assertions available in this package.
In ha with the component I only get these error messages, no matter what the reason for the 400 is.
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://192.168.1.78:9192/api/objects/tasks
Grocy is however also sending an error_message, like this:
"{\"error_message\":\"SQLSTATE[23000]: Integrity constraint violation: 19 UNIQUE constraint failed: tasks.name\"}"
It would be awesome to get these in the error message from the lib too.
Prepare 1.0.0 release to start following semver.
See #33
grocy.py
is getting quite large and should be split up.
We already speak about it.
I think we have to take care of Grocy version : db blueprint is changing across versions and it can break end-user usages.
Keep in touch :)
While playing with MutPy I found out that the following mutations don't lead to failing tests:
- [# 1] COI utils:
--------------------------------------------------------------------------------
1: import iso8601
2:
3:
4: def parse_date(input_value):
- 5: if input_value is None:
+ 5: if not (input_value is None):
6: return None
7: return iso8601.parse_date(input_value)
8:
9:
--------------------------------------------------------------------------------
[0.00575 s] survived
- [# 2] COI utils:
--------------------------------------------------------------------------------
7: return iso8601.parse_date(input_value)
8:
9:
10: def parse_int(input_value, default_value=None):
- 11: if input_value is None:
+ 11: if not (input_value is None):
12: return default_value
13: try:
14: return int(input_value)
15: except ValueError:
--------------------------------------------------------------------------------
[0.00661 s] survived
- [# 3] COI utils:
--------------------------------------------------------------------------------
16: return default_value
17:
18:
19: def parse_float(input_value, default_value=None):
- 20: if input_value is None:
+ 20: if not (input_value is None):
21: return default_value
22: try:
23: return float(input_value)
24: except ValueError:
--------------------------------------------------------------------------------
[0.00899 s] survived
- [# 4] EHD utils:
--------------------------------------------------------------------------------
12: return default_value
13: try:
14: return int(input_value)
15: except ValueError:
- 16: return default_value
+ 16: raise
17:
18:
19: def parse_float(input_value, default_value=None):
20: if input_value is None:
--------------------------------------------------------------------------------
[0.00770 s] survived
- [# 5] EHD utils:
--------------------------------------------------------------------------------
21: return default_value
22: try:
23: return float(input_value)
24: except ValueError:
- 25: return default_value
+ 25: raise
--------------------------------------------------------------------------------
[0.00714 s] survived
- [# 6] EXS utils:
--------------------------------------------------------------------------------
12: return default_value
13: try:
14: return int(input_value)
15: except ValueError:
- 16: return default_value
+ 16: pass
17:
18:
19: def parse_float(input_value, default_value=None):
20: if input_value is None:
--------------------------------------------------------------------------------
[0.00712 s] survived
- [# 7] EXS utils:
--------------------------------------------------------------------------------
21: return default_value
22: try:
23: return float(input_value)
24: except ValueError:
- 25: return default_value
+ 25: pass
--------------------------------------------------------------------------------
According to semver spec (https://semver.org) APIs should be in 1.0.0 when used publicly which is kinda the case with the grocy custom component.
Hi,
is there a way to modify location objects after adding with add_generic?
Best regads,
Phil
As reported in custom-components/grocy#75 not all fields of Product are initialised in every use case, which leads to an exception if a property accesses the non existant field.
A difference between doc and irl in Grocy.
Doc says it's a product schema but it's a CurrentStockReponse.
(Grocy API version : 2.4.4)
The fix is ready https://github.com/BlueBlueBlob/pygrocy/commit/2a2d04193f8447cb855a7432bd626e9fd5b5dcbe
Mock data against real server.
Something like this : https://github.com/BlueBlueBlob/pygrocydm/blob/master/test/test_battery.py
You can disable location tracking in the grocy addon with stock_location_tracking: false
.
If that is configured I noticed pygrocy will not be able to handle a shopping list call with items without location in it. Location should perhaps be optional.
GET /choresβ/{choreId}
returns more information for a single chore and should be implemented like the call for product details.
Currently, some methods in Grocy
return response objects and some methods return objects independent of the server representation. In this issue, all methods in Grocy
should be changed to return a representation of an entity which is independent of the representation on the server side. It may be needed to create additional classes to achieve this.
CodeFactor found an issue: Final newline missing
It's currently on:
test\test_grocy.py:123
Commit e2430cc
Sorry I forget to change it.
Hi
This request https://demo.grocy.info/api/objects/products is different from https://demo.grocy.info/api/stock.
It can be useful in case to update a product informations.
Great regards
Add a check for due date before parsing
Traceback (most recent call last):
File "/config/custom_components/grocy/__init__.py", line 268, in async_update_tasks
] = await self.hass.async_add_executor_job(self.client.tasks)
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy.py", line 591, in tasks
raw_tasks = self._api_client.get_tasks()
File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy_api_client.py", line 649, in get_tasks
return [TaskResponse(data) for data in parsed_json]
File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy_api_client.py", line 649, in <listcomp>
return [TaskResponse(data) for data in parsed_json]
File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy_api_client.py", line 458, in __init__
self.due_date = parse_date(parsed_json.get("due_date"))
File "/usr/local/lib/python3.8/site-packages/pygrocy/utils.py", line 10, in parse_date
return iso8601.parse_date(input_value)
File "/usr/local/lib/python3.8/site-packages/iso8601/iso8601.py", line 195, in parse_date
raise ParseError("Unable to parse date string %r" % datestring)
iso8601.iso8601.ParseError: Unable to parse date string ''
Hi!
First of all many thanks for pygrocy, I have been using it for a while and it helped me a lot!
I think I got a parse error when I try to get the missing products using grocy.missing_products()
If I check the JSON I See:
"missing_products": [
{
"id": "7",
"name": "XXXX",
"amount_missing": "1",
"is_partly_in_stock": "1"
},
{
"id": "8",
"name": "YYYY",
"amount_missing": "1",
"is_partly_in_stock": "1"
},
{
"id": "75",
"name": "ZZZZ",
"amount_missing": "1",
"is_partly_in_stock": "1"
}
]
But diving in CurrentStockResponse is expecting antother property names:
self._product_id = parse_int(parsed_json.get('product_id'))
self._amount = parse_float(parsed_json.get('amount'))
self._best_before_date = parse_date(parsed_json.get('best_before_date'))
self._amount_opened = parse_float(parsed_json.get('amount_opened'))
Do we might need a new class to represent missing products?
If so, I can try to open a PR with that change.
Currently 2 paths of methods in utils.py
aren't covered by tests. (https://coveralls.io/builds/28232582/source?filename=pygrocy/utils.py) It should be really easy to add tests for these to increase coverage to 100%.
As seen in custom-components/grocy#3 pygrocy seems to crash when the barcode field is contained in a products data but null.
Hey there, great library!
I'm using your library to build a telegram bot to interact with grocy. So far it works great! π
However, when dealing with entities of different types it is cumbersome that they all have different names for their id
property. Would it be possible to rename all those properties (product_id
, chore_id
etc.) to just id
? Is the grocy API giving the info out this way or did you choose to do this for some reason?
Thx
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.