Grocy - Custom component and card(s)

So what you would like is basically an addition to each chore item in the sensor, like this?

chores: 
- id: 1
  name: Do laundry
  description: ''
  overdue: true
  overdue_days: 4
[...]

There is also binary sensors that indicates if there is any overdue chores or tasks and contains an item list with only overdue items.

@teachingbirds each chore for a sensor would be great if it can be done :heart:… … If not how would I use the binary sensors? To make the sensors?

I do not have the time to refactor the integration to make a sensor for each chore, but am open for prs if anyone would have a go at it.

I can try to make an example of a template sensor and post it, when I have the time for that!

1 Like

Another pre-release of the card up now, it should no longer stop working and take the whole view with it when (either of) the sensors are unknown. :grimacing:
Also I added an option for show_empty, which is true by default, but if set to false will hide the card when it’s empty.

1 Like

Just update to 3.02 still working. :slight_smile:

@teachingbirds :slight_smile: example of a template senson will be nice :slight_smile: I never know how to make them but I look at your example when you get time and I try and work out if I can make them thanks :-)…

So this is an example of a sensor for your bird room chore, with id 4.
If anyone else would like the same kind of sensor, you need to look at the chores in your sensor.grocy_chores and look for the id of the chore you want to use. Then change the 4 in the template sensor below to your id, in both the state and overdue_by_days-attributes template.

template:
  - binary_sensor:
      - name: Bird cleaning overdue
        state: "{{ state_attr('binary_sensor.grocy_overdue_chores', 'chores') | selectattr('id', 'eq', 4) |list | count != 0 }}"
        device_class: problem
        attributes:
          overdue_by_days: >
                      {% set midnight = now().replace(hour=0, minute=0, second=0, microsecond=0).timestamp() %}
                      {% set event = (state_attr('binary_sensor.grocy_overdue_chores', 'chores') | selectattr('id', 'eq', 4) |list)[0].next_estimated_execution_time | as_timestamp %}
                      {% set delta = ((event - midnight) // 86400) | int %}
                      {{ delta * -1 }}

The resulting binary sensor will give you an on-state if the chore is overdue, and the attribute overdue_by_days will show you by how much.

Not overdue:


Overdue:

2 Likes

Thanks :kissing_heart::kissing_heart:. Keep the work up…

1 Like

Pre-release v3.1.0b available now.
This contains fix for the service for add generic that stopped working a while ago, and a fix for distinguishing between an unavailable sensor and a sensor that should have state 0. Also adds ability to use gui editor for service calls.

1 Like

Yep have don your 2 updates and working :+1:

1 Like

Just released a new feature for the card!
show_create_task: true will give you this at the bottom of the card (it will be collapsed as default). It will automatically fill the date field with the current time and date. You can change to only date, another date and time, or remove it (will create a task without due date).

image

2 Likes

Nice work… Was testing it out an could not find it I was using my mobile phone with Android app… So I double checked on my computer and I do see add task… Well done @teachingbirds, :+1::+1: :stuck_out_tongue_winking_eye: hopefully easy fix for my phone…but still well done looks cool

1 Like

You should see it if you clear cache I imagine!

Yep after cleaning data it work thanks once more :+1:

1 Like

Fixed a bug with the time in add task, and also moved the add task-functionality to the top of the card instead.

I am only using Grocy for chores and tasks. I am getting the following error but don’t see a way to disable the listed entities in the config:

Logger: custom_components.grocy
Source: custom_components/grocy/init.py:108
Integration: Grocy (documentation)
First occurred: 10:52:22 AM (147 occurrences)
Last logged: 11:04:02 AM

You have enabled the entity for Grocy expiring products, but this feature is not enabled in Grocy
You have enabled the entity for Grocy missing products, but this feature is not enabled in Grocy
You have enabled the entity for Grocy meal plan, but this feature is not enabled in Grocy
You have enabled the entity for Grocy shopping list, but this feature is not enabled in Grocy
You have enabled the entity for Grocy stock, but this feature is not enabled in Grocy

Go to the integrations page, press “10 entities” on the Grocy card.
image
Select the entities you want to disable and press “disable selected”

I’m new to home assistant, so apologies if this is a stupid question. I’ve installed the custom component and now have the 5 binary sensors and 5 normal sensors (chores, meal plan, shopping list, stock and tasks) but when looking in the states section under developer tools all 5 sensors show as “unknown”? Should these not be pulling through the data from grocy?

In addition what are the binary sensors for?

You need to check your log for more information, is there an error from the integration there?

This shows in the “log” section of the Grocy integration, this is repeated loads of times with a small variation:

2021/06/04 16:21:31 [error] 861#861: *126808 FastCGI sent in stderr: "PHP message: PHP Notice:  Constant GROCY_AUTHENTICATED already defined in /var/www/grocy/controllers/ExceptionController.php on line 62PHP message: PHP Warning:  Use of undefined constant GROCY_USER_ID - assumed 'GROCY_USER_ID' (this will throw an Error in a future version of PHP) in /var/www/grocy/controllers/BaseController.php on line 162PHP message: PHP Notice:  Trying to access array offset on value of type null in /data/grocy/viewcache/ee91662b47d4b5bfed27ce28d018967d808016cb.php on line 110PHP message: PHP Notice:  Trying to access array offset on value of type null in /data/grocy/viewcache/ee91662b47d4b5bfed27ce28d018967d808016cb.php on line 110" while reading response header from upstream, client: 192.168.0.60, server: a0d7b954-grocy, request: "GET /a0d7b954_grocy:9192/api/system/db-changed-time HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "192.168.0.60:9192"
[04/Jun/2021:16:21:31 +0100] 404 -(192.168.0.60) GET /a0d7b954_grocy:9192/api/system/db-changed-time HTTP/1.1 (python-requests/2.25.1)

Go back and follow the instructions for the integration please. You have not provided a url at all.

I misread. Is that the addons log? Do Grocy actually work for you? Not the integration, the software itself.