Giter VIP home page Giter VIP logo

lovelace-grocy-chores-card's Introduction

hacs_badge

grocy-chores-card

A Lovelace custom card for custom component Grocy in Home Assistant.

Grocy Chores Card

This card reqires card tools.

Easiest installation via HACS.

For manual installation see this guide.

Example configuration

title: My awesome Lovelace config
resources:
  - url: /local/grocy-chores-card.js
    type: js
views:
  title: My view
  cards:
    - type: custom:grocy-chores-card
      entity:
        - sensor.grocy_chores
        - sensor.grocy_tasks

Options

Name Type Optional Default Description
type string Required custom:grocy-chores-card
entity string/list Required The entity id(s) of your Grocy chores and/or tasks sensor(s).
title string Optional "Todo" The title of the card.
show_quantity number Optional The number of items you want to show in the card. The rest are either hidden or show in the overflow.
show_days number/range Optional E.g. 0 to only show items that are due today, overdue or have no due date. If a range is specified show only tasks with a due date in that range; e.g. 1..10 would show tasks due in the next 10 days, but not overdue tasks, or tasks due today. If not specified, shows all items.
show_chores_without_due bool Optional true Show chores that do not have a due date.
show_tasks_without_due bool Optional true Show tasks that do not have a due date.
user_id number/map Optional 1 Id of the Grocy user performing the items. Default if not specified is 1. A map may also be specified, see here
custom_translation string-list Optional List of translations of string values used in the card (see below).
filter string/list Optional Only show items that contains this filter in the name. When filter is a list, filters are applied as OR.
remove_filter bool Optional Use together with filter to remove the filter from the name when showing in card. Chore name "Yard work: Clean rain gutters" with filter "Yard work: " will then only display "Clean rain gutters".
filter_user number Optional Only show items assigned to the user with this user_id. Ex: 1. If a user_id map is defined, current may be used instead of a number, in which case only items assigned to the current home-assistant user are shown.
filter_task_category number/list Optional Only show tasks with select category_ids. When filter is a list, filters are applied as OR. Ex: 1
show_assigned bool Optional true Show who's assigned to the item (does not work on tasks).
show_last_tracked bool Optional true Show when someone last tracked this chore (does not work on tasks).
show_last_tracked_by bool Optional true Show who last tracked this chore (show_last_tracked must be true to show this) (does not work on tasks).
show_track_button bool Optional true Show track (complete) button
show_empty bool Optional true Set to false to hide card when no items
show_create_task bool Optional false Set to true to show ability to add a task in Grocy directly from the card. Due date must be in format yyyy-mm-dd, e.g. 2022-01-31. When due date is empty, task has no due date.
browser_mod bool Optional false Set to true if you have installed browser_mod v2 and want feedback when tracking or adding a task, in the form of a native toast bar.
show_overflow bool Optional false When true, replaces the 'Look in Grocy for X more items' text with a 'Show X more' button that toggles an overflow area.
show_divider bool Optional false When true, shows a divider between each task. Uses the CSS variable entities-divider-color and falls back on divider-color from your theme.
use_icons bool Optional When null, uses icons for chores/tasks only when chore_icon or task_icon is set. When true, forces defaults if chore_icon/task_icon is not set. When false, overrides chore_icon/task_icon and always uses text buttons.
task_icon string Optional Sets the icon used on Tasks. Replaces the text. Set use_icons to true and don't use this parameter to use default icon.
task_icon_size number Optional 24 Sets the size of the icon for Tasks. Default is 24 because default is an empty checkbox. Only applies when use_icon or task_icon is set.
chore_icon string Optional Sets the icon used on Chores. Replaces the text. Set use_icons to true and don't use this parameter to use default icon.
chore_icon_size number Optional 32 Sets the size of the icon for Chores. Default is 32. Only applies when use_icon or chore_icon is set.
expand_icon_size number Optional 30 Sets the size of the expand/collapse button on the Overflow area. Default is 30. Only applies when show_overflow is set.
use_long_date bool Optional false Sets if the Due/Completed dates are formatted in long format (i.e. December 31, 2022) or short format (i.e. 12/31/2022). Uses localization settings for token order.
due_in_days_threshold number Optional 0 Due dates are reported as 'Overdue', 'Today', 'Tomorrow', 'In X Days', and finally using the actual date. This sets how many days use the 'In X Days' format, before it switches to using date notation.
last_tracked_days_threshold number Optional 0 Last tracked dates are reported as 'Today', 'Yesterday', 'x days ago' and finally the actual track date. This sets how many days use the 'x days ago' format, before it switches to using date notation.
use_24_hours bool Optional true Sets if the times are shown in 12 hour or 24 hour formats.
hide_text_with_no_data bool Optional false When true, if a property for an item is not set, it hides the text. For example, if a chore has never been completed, instead of showing 'Last tracked: -', it will hide the 'Last tracked' row entirely.
haptic string Optional selection Can be set to light, success, or anything listed here.
show_description bool Optional false When true, show the chore/task descriptions under the name.
description_max_length number Optional When set and show_description is set, truncate shown descriptions to the number of characters specified.
fixed_tiling_size number Optional When set, provides a fixed value to the masonry tiling algorithm for card size, where 1 unit equals 50 pixels. When unset, calculate the size dynamically from the number of items in the todo list. Setting the value will give a more consistent layout of masonry elements, though they may not be well balanced. When unset, the cards will be more compactly tiled for layout, but may move around on page refresh as list length changes.
custom_sort string/map Optional Modifies the sort order. See here for details.

Advanced options

It is possible to translate the following English strings in the card to whatever you like.

custom_translation:
  Overdue: "Försenad"
  Today: "Idag"
  Due: "Dags"
  'Assigned to': "Tilldelad"
  'Last tracked': "Senast"
  by: "av"
  Track: "Gör nu"
  'No todos': "Tomt"
  'Look in Grocy for {number} more items': "Det finns {number} fler göromål i Grocy"
  'Add task': "Lägg till"
  'Optional due date/time': "Valfritt datum/tid"
  "'Name' can't be empty": "Fyll i namn"
  Tracked: "Färdigställt"

Multi-User Support

If your Home Assistant/Grocy installation supports multiple users, this card can handle multiple users. To enable this, specify a map in the configuration, mapping the names of each home assistant user to their grocy user-id, e.g.:

user_id:
  bob: 1
  alice: 2
  default: 1

In this example, home-assistant user "bob" has a grocy userid of 1, and home-assistant user "alice" has a grocy userid of 2. Then when Bob is logged into home assistant, chores/tasks will be tracked as userid 1, and when Alice is logged in, they will be tracked as userid 2.

Note that this name on the left hand side is the user's home assistant display name, not the login/userid.

A default value may also be specified, specifying the userid to use for any Home Assistant user not otherwise specified.

This also affects the behavior of filter_user. Specifying filter_user: current in the config will only show chores/tasks for the currently logged in user.

Custom Sorting

By default, the card sorts items with the soonest due chores/tasks first. This can be modified by adding a custom_sort key to the configuration. The card can sort on any property available in the individual items, and it can sort on multiple indices, in ascending (default) or descending order.

Sort Examples

The current sort algorithm, sorting by due_date, ascending. custom_sort: __due_date

Sort alphabetically by name: custom_sort: name

Sort by user_id, then sort by due_date

custom_sort:
  - user_id
  - __due_date

Sort by category_id (descending), then by user_id, then by due date (descending)

custom_sort:
  - field: category_id
    direction: descending
  - user_id
  - field: __due_date
    direction: descending

The exact fields available for sort are tied into the card implementation and may change in the future without notice. To see the full list of fields that are available, review the source code or use the browser debugger to inspect what keys of the item object are available for sorting. Note tasks and chores may support different keys, so they may not sort as expected if you show both and use a sort key that is not available for both.

Using the Collapsible Overflow

Instead of the “Look in Grocy for X more items” text from older versions, this version can show all additional items in a collapsible overflow panel.

Usage

  1. Add the show_quantity parameter and set it to the number of items that should be shown in the main area.
  2. Add the show_overflow parameter and set it to true.
  3. To override the default size of the expand button icon, set expand_icon_size to an integer value.

Once you refresh, you should see a new button with an expand button at the bottom of the card if you have additional items. Click this to expand the card and show all items.

Icon Buttons

This version adds the ability to use icons instead of the “TRACK” text buttons on each item. Tasks and Chores can have different icons and sizes.

Usage

  • use_icons parameter
    • When not used or null, icons are controlled by the other parameters.
    • When true, both Tasks and Chores will use an icon. If the associated parameters are not set, it will use the default icons.
    • When false, all other icon options are ignored and text-based buttons are used.
  • task_icon/chore_icon parameters
    • When set to a valid icon (i.e. mdi:check), items of that type will use the specified icon instead of text as long as use_icons is not false.
    • When use_icons is true, you only need to use these parameters to override the default icons.
  • task_icon_size/chore_icon_size parameters
    • When icons are used, specifies the height and width of the icon for that item type.
    • Default for chores is 32 (as it’s a button) and tasks is 24 (because it is a checkbox).

Date Formatting

This version also introduces better date formatting. Each date is formatted based on the current user’s localization settings so that the order of tokens (day/month/year vs month/day/year) is correct. It also allows 12 or 24 hour times and long date formats (i.e. December 31, 2022).

Usage

  • use_long_date – When true, uses the long date format (i.e. December 31, 2022). When false, uses the short format (i.e. 12/31/2022). Default is false.
  • use_24_hours – When true, the time is shown in 24 hour format (i.e. 17:59). When false, it uses 12 hour format (i.e. 5:59 pm). Default is to use 24 hour format (true).
  • due_in_days_threshold – When set to a value grater than 1, specifies how many days from today will be shown as “Due: In X Days”. Default is 0, which means unused. For example, if it is set to 3, your tasks should have the following due dates:
    • Due: Overdue
    • Due: Today
    • Due: Tomorrow
    • Due: In 2 Days
    • Due: In 3 Days
    • Due: August 9, 2022
    • Etc.

Miscellaneous Style Options

  • show_divider – When true, adds a divider between each task or chore. The color is specified in your theme using the entities-divider-color variable (with fallback to divider-color).
  • hide_text_with_no_data – When true, when an item’s property is blank, that property is hidden regardless of other settings. For example, if you have show_last_tracked set to true, but a chore has never been completed, instead of showing “Last tracked: -”, the “Last tracked” line simply does not appear on that item (see Clean out the Fridge in the screenshot vs Sweep the Stairs).
  • Some of the colors can now be specified in your theme using CSS variables.
    • --red: sets the color of Overdue due date.
    • --orange: sets the color of Today due date.
    • --green: sets the mouse-over color on icon buttons.
    • --paper_font_subhead_-_font_size: sets the size of the task title test.
    • --paper_font_body1_-_font_size: sets the size of the task’s other information text.
    • --primary-text-color: sets the title text, icon color, and item title text color.
    • --secondary-text-color: sets the color of other text.
    • --accent-color: sets the hover color of the Show More button and icon.

Other changes in this version

In general, this update aims to not change any default setups so that anyone using this card won’t notice any change unless they change it themselves. However, some small changes have been made:

  1. Date is always formatted using user’s localization settings rather than always appearing YYYY/MM//DD.
  2. Due Date will be shown as “Tomorrow” when it is due in 1 day.
  3. Task title line will now always use the following CSS variables:
    • --paper_font_subhead_-_font_size for the size.
    • --primary-text-color for the color.
  4. Other task lines will now always use the following CSS variables:
    • --paper_font_body1_-_font_size for the size.
    • --secondary-text-color for the color.

Known Issues

  1. Due/Completed dates with the time values 23:59:59 or 00:00:00 will not show the times. This is because those are the default values populated when no time is set.

Development Instructions

To do development work on this card (either for your personal use, or to contribute via pull requests), follow these steps:

  1. Create a fork of this repository on GitHub
  2. Download and setup the repository on your local machine, by running:
git clone https://github.com/YOUR_USERNAME/lovelace-grocy-chores-card
cd lovelace-grocy-chores-card
git remote add upstream https://github.com/isabellaalstrom/lovelace-grocy-chores-card
  1. Once the repository is setup, install the npm dependencies with npm install
  2. Make local edits as needed to the grocy chores card.
  3. To test changes, run npm run build. This will create a compiled version of the card in output/grocy-chores-card.js.
  4. Copy the compiled card in the output/ folder to your Home Assistant installation and update the dashboard resources to point to it. Make sure the cache is cleared each time you try updating with new changes.
  5. Push the changes back to your GitHub origin, and open a pull request if you want to contribute them to the main repository.

Like my work and want to say thanks? Do it here:

Buy Me A Coffee

lovelace-grocy-chores-card's People

Contributors

andersstorhaug avatar blueblueblob avatar cdrfun avatar ceiku avatar clarinetjwd avatar dependabot[bot] avatar dgrnbrg avatar eracknaphobia avatar fheilmann avatar glenngoddard avatar isabellaalstrom avatar jlsjonas avatar karwosts avatar marcelvriend avatar mateszddd avatar nickm-27 avatar olavbolav avatar tim3trick avatar zigurana avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

lovelace-grocy-chores-card's Issues

Date and time formatting

Would it be possible to have the date and time customizable to format it according my preference?

For instance today the date shows as 2020-02-17, while I would prefer 17-02-2020, or to make it even more interesting a chore due in two days show it as 'due: in two days'.

Probably best to have the date fields be able to handle templating?

Cannot see any card

I have configure the Grocy intergration and can see 3 chores from Grocy in sensor.grocy_chores.

I have installed card-tools (v2.3) and Lovelace Grocy Chores Card (v0.1.3)

In my ui-lovelace.yaml:

resources:
  - url: /community_plugin/lovelace-grocy-chores-card/grocy-chores-card.js
    type: js
  - url: /community_plugin/lovelace-card-tools/card-tools.js
    type: module

views:
  - title: Chores
    cards:
      - type: custom:grocy-chores-card
        entity: sensor.grocy_chores

Nothing shows up with this config.

Am I doing something wrong?

Good job :)

We made some changes in Grocy custom component, like json removed.

I'm interesting in custom card, did you use the boiler-card template ?
I will learn a lot with your cards.

Thanks 👍

select a user per card

The chore card does not show who the chore is attached too which makes it harder to determine who's day / job it is to do it. It would be nice to either show the user it's assigned to or select a user per card so I can have a different card for each person doing chores.

one Home Assistant, multiple grocy Users?

Hi everybody,

I just installed the grocy addon and this chores card. It works great, but there is one thing I couldn't figure out (or is it not implemented?): multiple people use Home Assistant, but when either of those click track on the card, it always gets marked as done by me.

Each person has their own Home Assistant account, but the integration itself has been created by me (and is using that API key). Is there a way to pass on which user has actually completed a chore via this card, so that grocy will be able to mark the correct person?

Thank you in advance for your help :)

Card reports no chores even though sensor contains data

First of all: Thanks a lot for the great card and integration!

However, the card stopped working for me (without an update).
I am using the default user, which has some chores. Some are due and some not.

The sensor from the integration contains data, thus the integration seems to be working fine.
I tried debugging the card shortly and it seems that this method https://github.com/isabellaalstrom/lovelace-grocy-chores-card/blob/master/grocy-chores-card.js#L222 is not being called or hass seems to be undefined.
Unfortunately, I have no further knowledge of the Home Assistant framework and internals, therefore I can't tell what might be causing that.

Do you have any idea, what to test or what could be causing that?
This is probably not directly related to the card and more related to some custom integration(?)

Thanks a lot in advance!

Grocy Error after pushing Track...

Get this issues after pushing track.

Use Home Assistant Core 2021.4.4
Grocy custom component 3.0.5
Grocy Docker Version 3.0.1
Lovelace Grocy Chores Card 2.1.0

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 143, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1480, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1515, in _execute_service
    await handler.job.target(service_call)
  File "/config/custom_components/grocy/services.py", line 105, in async_call_grocy_service
    await async_execute_chore_service(hass, coordinator, service_data)
  File "/config/custom_components/grocy/services.py", line 207, in async_execute_chore_service
    await 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/services.py", line 205, in wrapper
    coordinator.api.execute_chore(chore_id, done_by, tracked_time)
  File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy.py", line 107, in execute_chore
    return self._api_client.execute_chore(chore_id, done_by, tracked_time)
  File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy_api_client.py", line 633, in execute_chore
    return self._do_post_request(f"chores/{chore_id}/execute", data)
  File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy_api_client.py", line 565, in _do_post_request
    raise GrocyError(resp)
pygrocy.errors.grocy_error.GrocyError: <Response [500]>

unable to track from card

custom component: v1.1.1
chores card: v1.1.0

when i click on track in the chores card this is the error that pops up on screen.

Grocy track error

from logs:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 125, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1308, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1345, in _execute_service
handler.func(service_call)
File "/config/custom_components/grocy/init.py", line 166, in handle_execute_chore
grocy.execute_chore(chore_id, done_by, tracked_time)
File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy.py", line 515, in execute_chore
return self._api_client.execute_chore(chore_id, done_by, tracked_time)
File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy_api_client.py", line 546, in execute_chore
localized_tracked_time = local_tz.localize(tracked_time)
File "/usr/local/lib/python3.8/site-packages/pytz/tzinfo.py", line 318, in localize
raise ValueError('Not naive datetime (tzinfo is already set)')
ValueError: Not naive datetime (tzinfo is already set)

Feature Request: Option to disable TRACK

It would be useful to have the option to disable TRACK so the card could be used to display the status of chores only.

This could be used for users that just need access to see chores and not mark as complete and also for displays for information use only and prevent inadvertent execution.

crashes on chores without due date

I have some chores without a due date and the plugin crashes. The entire lovelace UI gets blank.

TypeError: a._next_estimated_execution_time is null grocy-chores-card.js:167:28
    set hass/< grocy-chores-card.js:167
    comparefn self-hosted:212
    InsertionSort self-hosted:3508
    MergeSort self-hosted:3564
    sort self-hosted:215
    set hass grocy-chores-card.js:166
    value hui-view.ts:61
    value hui-view.ts:336
    value hui-view.ts:68
    r fire_event.ts:76
    va create-card-element.ts:111

Error when tracking Chore "object has no attribute 'localize'"

Howdy, I am getting an error when clicking the "Track" button on the chore card.

  • The issue started this week, I believe shortly after I upgraded from core-2021.8.2 to core-2021.8.7.
  • Issue persisted when upgrading to core-2021.8.8
  • Issue no longer exists when restoring a snapshot to core-2021.8.2

Please let me know if there is anything else you need from me to help investigate the issue.

"Failed to call service grocy/execute_chore. 'zoneinfo.ZoneInfo' object has no attribute 'localize'"
image

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/grocy/services.py:205
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 5:19:37 PM (3 occurrences)
Last logged: 5:20:38 PM

[548255661744] 'zoneinfo.ZoneInfo' object has no attribute 'localize'
[548195155776] 'zoneinfo.ZoneInfo' object has no attribute 'localize'
[547967789232] 'zoneinfo.ZoneInfo' object has no attribute 'localize'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1491, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1526, in _execute_service
await handler.job.target(service_call)
File "/config/custom_components/grocy/services.py", line 105, in async_call_grocy_service
await async_execute_chore_service(hass, coordinator, service_data)
File "/config/custom_components/grocy/services.py", line 207, in async_execute_chore_service
await hass.async_add_executor_job(wrapper)
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/grocy/services.py", line 205, in wrapper
coordinator.api.execute_chore(chore_id, done_by, tracked_time)
File "/usr/local/lib/python3.9/site-packages/pygrocy/grocy.py", line 107, in execute_chore
return self._api_client.execute_chore(chore_id, done_by, tracked_time)
File "/usr/local/lib/python3.9/site-packages/pygrocy/grocy_api_client.py", line 626, in execute_chore
localized_tracked_time = localize_datetime(tracked_time)
File "/usr/local/lib/python3.9/site-packages/pygrocy/utils.py", line 47, in localize_datetime
return local_tz.localize(timestamp).astimezone(pytz.utc)
AttributeError: 'zoneinfo.ZoneInfo' object has no attribute 'localize'

Failed to call service grocy/execute_chore. <Response [500]>

When trying to mark chore as tracked using this card I'm getting a response 500 error. I'm guessing it's my own fault but I'm not sure why.

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/grocy/services.py:205
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: June 2, 2021, 7:44:43 PM (14 occurrences)
Last logged: 5:16:07 PM

[140046089280624] <Response [500]>
[140046424331744] <Response [500]>
[140046033914848] <Response [500]>
[140046041939488] <Response [500]>
[140046034013488] <Response [500]>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 167, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1481, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1516, in _execute_service
await handler.job.target(service_call)
File "/config/custom_components/grocy/services.py", line 105, in async_call_grocy_service
await async_execute_chore_service(hass, coordinator, service_data)
File "/config/custom_components/grocy/services.py", line 207, in async_execute_chore_service
await 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/services.py", line 205, in wrapper
coordinator.api.execute_chore(chore_id, done_by, tracked_time)
File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy.py", line 107, in execute_chore
return self._api_client.execute_chore(chore_id, done_by, tracked_time)
File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy_api_client.py", line 633, in execute_chore
return self._do_post_request(f"chores/{chore_id}/execute", data)
File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy_api_client.py", line 565, in _do_post_request
raise GrocyError(resp)
pygrocy.errors.grocy_error.GrocyError: <Response [500]>

Error "TypeError: Cannot read property 'length' of undefined"

EDIT (SOLVED?): hmm... ok lol.. i should install "lovelace-grocy-tasks-card" for this :p but it doesnt should fail if there are no chores right?

Hi, i'm triing to integrate lovelace-grocy-chores-card in my HA.

type: 'custom:grocy-chores-card'
entity: sensor.grocy_tasks

Its showing this error when i inspect with developer tools of chrome:

CARD-TOOLS 2.1.2 IS INSTALLED  DeviceID: ecf67d67
grocy-chores-card.js:111 Uncaught (in promise) TypeError: Cannot read property 'length' of undefined
    at HTMLElement.render (grocy-chores-card.js:111)
    at HTMLElement.update (app.c5d13434.js:10291)
    at HTMLElement.performUpdate (app.c5d13434.js:10291)
    at HTMLElement._enqueueUpdate (app.c5d13434.js:10291)

and if i click on the first line (line 111) it shows this:

              )}` : cardTools.LitHtml`<div class="info flex">${this.translate("No chores")}!</div>`}
            </div>
            ${this.notShowing.length > 0 ? cardTools.LitHtml
              `
              <div class="secondary">
                  ${this.translate("Look in Grocy for {number} more chores").replace("{number}", this.notShowing.length)}
              </div>

Not sure what it is... my grocy instalation is new, so there is no stock and nothing introduced, there is only one task. should i introduce more more info? what is it tring to load? chores?

Thanks in advance!

Feature request: filter the chores to display

It could be interesting to have a filter to chose what chores to be displayed.
It could be a filter on the title or other attributes in the chore JSON.
It could be a filter on the userfields value associated to chore, but I think the pyGrocy module doesn't give access to this part of the API.

0.1.3 not working (empty view)

I wasn't able to get the lovelace-grocy-chores-card to work... so I searched the code and found the problem on line 162, where the script tries to JSON parse, but the items are already parsed...

changing line 162 to the following made the card working:
ORIGINAL: var chores = JSON.parse(entity.attributes.items);
NEW: var chores = entity.attributes.items;

grocy_tasks entity doesn't pull tasks if any of the tasks are "uncategorized" in Grocy

So I was confused as to why the grocy_tasks entity didn't have any tasks in it.
After some testing I found that if any Task in grocy is "uncategorized" then the tasks fail to get pulled.
I checked the Grocy API to make sure it wasn't an issue there, the API sends the tasks with a empty category id.
null_cat_id

I believe that the integration is expecting this to be an integer, so an empty string throws an error.

Here are some screenshots:
If any task in Grocy is uncategorized
uncat_task
Then todo list is empty:
no_tasks
and the entity state is "unknown"
state_unknown

If all tasks have a category
cat_tasks
Then todo list shows the tasks:
tasks
and the entity state shows number of tasks and tasks are loaded
state_correct

Just to rule out any templating issues, here is the YAML for the card:

type: custom:grocy-chores-card
entity: sensor.grocy_tasks
title: Todo List
show_quantity: null
show_days: null
show_assigned: false
show_last_tracked: true
show_last_tracked_by: false
show_track_button: true
show_create_task: true
browser_mod: false

Adding a task fails

When trying to add a task from the card, I get the following error message:
Failed to call service grocy/add_generic. 'str' object has no attribute 'value'

Running grocy 0.15.0 and HA core-2021.7.4.

UTC Time instead of local time

I clicked track on both and it set it 5 hours in the future on the grocy side of things. Also, you can see the schedule for differs.

image
image

Tracking Chore Execution in UTC Only

When I click the "Track" button, everything works except the Grocy Journal says I executed the task at the wrong time. Specifically, for me, it says I executed the task 6 hours in the future because I live in CST which is 6 hours behind UTC.
Screenshot 2022-01-31 210642

Card does not display when used with grocy integration 2.0.0-beta

The following error appears in the JS console:

Uncaught (in promise) TypeError: Cannot read property 'length' of undefined
    at HTMLElement.render (grocy-chores-card.js:111)
    at HTMLElement.update (app.664a8247.js:1)
    at HTMLElement.performUpdate (app.664a8247.js:1)
    at HTMLElement._enqueueUpdate (app.664a8247.js:1)

Chores and Task sensors broken after update to v3.2.0

After updating to v3.2.0 yesterday my chore and task cards both say "no todos" even though there are both chores and tasks due or overdue. When I checked the sensors in dev tools they return "unknown".

Logger: homeassistant.components.binary_sensor
Source: custom_components/grocy/json_encode.py:26
Integration: Binary sensor (documentation, issues)
First occurred: 12:05:37 PM (1 occurrences)
Last logged: 12:05:37 PM

grocy: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 431, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 646, in async_device_update
await task
File "/config/custom_components/grocy/entity.py", line 57, in async_update
await self.coordinator.async_request_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 141, in async_request_refresh
await self._debounced_refresh.async_call()
File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 78, in async_call
await task
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 165, in async_refresh
await self._async_refresh(log_failures=True)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 265, in _async_refresh
update_callback()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 464, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 505, in _async_write_ha_state
extra_state_attributes = self.device_state_attributes
File "/config/custom_components/grocy/entity.py", line 142, in device_state_attributes
return json.loads(json.dumps(data, cls=GrocyJSONEncoder))
File "/usr/local/lib/python3.9/json/init.py", line 234, in dumps
return cls(
File "/usr/local/lib/python3.9/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/local/lib/python3.9/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/config/custom_components/grocy/json_encode.py", line 26, in default
return json.JSONEncoder.default(self, o)
File "/usr/local/lib/python3.9/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.class.name} '
TypeError: Object of type ProductBarcodeData is not JSON serializable

Card does not work off-line

This card works fine if I have the HA connected to internet.

I'm assuming that may have something to do with the "LitElement" module.

Are there any dependencies I need to install to make the card work off-line?

I am running HA supervised in docker.

Thanks

Change shown date format

Hey

I'd love to have the possibility to change the date format that is shown in the card.
I know that grocy only supports the international date format yyyy mm dd, but i'm not used to it and always have to remind me of this.

Thank you for your great work!

Error after update to hassio 2021.4.0

This occurs when I press the track button

Logger: homeassistant.components.websocket_api.http.connection
Source: util/async_.py:139
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 9:39:55 PM (1 occurrences)
Last logged: 9:39:55 PM

[547781073744] I/O must be done in the executor; Use await hass.async_add_executor_job() at custom_components/grocy/services.py, line 191: coordinator.api.execute_chore(chore_id, done_by, tracked_time)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 143, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1480, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1515, in _execute_service
await handler.job.target(service_call)
File "/config/custom_components/grocy/services.py", line 99, in async_call_grocy_service
await async_execute_chore_service(hass, coordinator, service_data)
File "/config/custom_components/grocy/services.py", line 191, in async_execute_chore_service
coordinator.api.execute_chore(chore_id, done_by, tracked_time)
File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy.py", line 98, in execute_chore
return self._api_client.execute_chore(chore_id, done_by, tracked_time)
File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy_api_client.py", line 617, in execute_chore
return self._do_post_request(f"chores/{chore_id}/execute", data)
File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy_api_client.py", line 557, in _do_post_request
resp = requests.post(
File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 119, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 234, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "/usr/local/lib/python3.8/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/lib/python3.8/http/client.py", line 1266, in send_request
self.putrequest(method, url, **skips)
File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 214, in putrequest
return HTTPConnection.putrequest(self, method, url, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/util/async
.py", line 150, in protected_loop_func
check_loop()
File "/usr/src/homeassistant/homeassistant/util/async
.py", line 139, in check_loop
raise RuntimeError(
RuntimeError: I/O must be done in the executor; Use await hass.async_add_executor_job() at custom_components/grocy/services.py, line 191: coordinator.api.execute_chore(chore_id, done_by, tracked_time)

Would love to Filter on Due Status

Loving this chores card so far! I was wondering if it could be possible to add a feature to this to allow filtering on the "Due" status?

My idea is to have 2 of these chore cards on the same dashboard view. The first card would be for any chore that is overdue. The second card would be for chores that are not overdue, but due within X days.

Feature Request: Support columns

Example, instead of having a single column of 20 chores, make it user configurable. So you could specify like 5 and have 4 columns of 5 each?

Grocy sensor only showing 'unknown'

When I attempt to add the grocy card, I cannot get it to work. Either it shows up like the screen shot below, or I cannot get the manual card to accept - type: custom:grocy-chores-card either.

I'm very noobish when it comes to this, but I get no further with Google at this point.
Sorry if this is the wrong place to put this.

Screenshot_20201213-003847_Chrome

possible to show tasks and chores in the same list?

I have the card installed.

Here is my simple config for one kid in my house.

cards:
          - type: custom:grocy-chores-card
            entity:
              - sensor.grocy_chores
              - sensor.grocy_tasks
            title: Will Chores
            show_quantity: 5
            show_days: 2
            filter_user: 2
            show_track_button: true

However it only shows chores. If i remove filter user, the task now shows up as well as the chores. The chores and the tasks are both assigned to the same userid.

Is it possible to have both show up in the same list? This would make 1 off chores and recurring chores mix well on the chore lists for the kids.

Thank you!

filter_user stopped working

Example from sensor.grocy_chores

- id: 5
  name: Foo - Take out garbage
  description: ''
  period_type: daily
  period_config: ''
  period_days: 0
  track_date_only: false
  rollover: false
  assignment_type: in-alphabetical-order
  assignment_config: '4'
  next_execution_assigned_to_user_id: 4
  userfields: null
  last_tracked_time: '2022-02-04T12:50:34'
  next_estimated_execution_time: '2022-02-05T12:50:34'
  last_done_by:
    id: 2
    username: bar
    first_name: Bar
    last_name: ''
    display_name: Bar
  track_count: 0
  next_execution_assigned_user:
    id: 4
    username: foo
    first_name: Foo
    last_name: ''
    display_name: Landen

Card

 - type: custom:grocy-chores-card
   entity: sensor.grocy_chores
   title: "Foo's Chores"
   user_id: 4
   filter_user: 4
   custom_translation:
     Track: "Complete Now"

Result, no card shows up.
If I removed the filter_user it works fine.

filter: is working fine though.

Filter seems to only allow 1 String

I was attempting to update my chores card tonight to filter it based off of 2 different strings: either "Week" or "Yearly". If I use either one on its own, it works as I would expect as I only get the chores with that string in their name. When I use both string, my card shoes "No chores".

Working Filter with a single string:
Working Filter

Not Working Filter with multiple strings
Not Working Filter

Request: Wording change

Not a big thing, but maybe 'Scheduled for:' could be changed for 'Due' (So it says 'Due in 4 days' rather than 'Scheduled for: In 4 days')
Alternatively you could just remove the 'In' from 'In 4 Days' so that it says 'Scheduled for: 4 days' and it would still make sense if it were to have a date rather than a due in time.

Track chores or tasks results in error

2021-08-19 11:07:09 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Invalid data for call_service at pos 1: expected int for dictionary value @ data['task_id']
2021-08-19 11:07:09 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139642422170240] Error handling message: expected int for dictionary value @ data['task_id']. Got None

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.