custom-components / grocy

Custom Grocy integration for Home Assistant
Apache License 2.0
156 stars 47 forks source link

Chores with 'manual' PeriodType cause the chores sensor to become 'unknown' #219

Closed szerencl closed 2 years ago

szerencl commented 2 years ago

Describe the bug Adding a manual, adaptive, or hourly chore, causes the chores sensor to become unknown. After removing said chore, or changing it to daily ... yearly the sensor recovers.

With manual chore added:

--> GET /chores
2022-05-28 13:28:36 DEBUG (SyncWorker_7) [pygrocy.grocy_api_client] <-- 200 for /chores
2022-05-28 13:08:23 DEBUG (SyncWorker_7) [pygrocy.grocy_api_client] b'[{"id":"1","chore_id":"1","chore_name":"chore1","last_tracked_time":"2022-05-23 00:00:00","next_estimated_execution_time":"2022-05-28 23:59:59","track_date_only":"1","next_execution_assigned_to_user_id":"1","is_rescheduled":"0","is_reassigned":"0","next_execution_assigned_user":{"id":"1","username":"username","first_name":"","last_name":"","row_created_timestamp":"2022-05-07 17:25:42","display_name":"username","picture_file_name":null}},{"id":"2","chore_id":"2","chore_name":"chore2","last_tracked_time":"2022-05-08 00:00:00","next_estimated_execution_time":"2022-06-03 23:59:59","track_date_only":"1","next_execution_assigned_to_user_id":"1","is_rescheduled":"0","is_reassigned":"0","next_execution_assigned_user":{"id":"1","username":"username","first_name":"","last_name":"","row_created_timestamp":"2022-05-07 17:25:42","display_name":"username","picture_file_name":null}},{"id":"3","chore_id":"3","chore_name":"chore3","last_tracked_time":"2022-05-23 00:00:00","next_estimated_execution_time":"2022-06-04 23:59:59","track_date_only":"1","next_execution_assigned_to_user_id":"1","is_rescheduled":"0","is_reassigned":"0","next_execution_assigned_user":{"id":"1","username":"username","first_name":"","last_name":"","row_created_timestamp":"2022-05-07 17:25:42","display_name":"username","picture_file_name":null}},{"id":"4","chore_id":"4","chore_name":"chore4","last_tracked_time":null,"next_estimated_execution_time":"2022-06-05 23:59:59","track_date_only":"1","next_execution_assigned_to_user_id":"1","is_rescheduled":"0","is_reassigned":"0","next_execution_assigned_user":{"id":"1","username":"username","first_name":"","last_name":"","row_created_timestamp":"2022-05-07 17:25:42","display_name":"username","picture_file_name":null}},{"id":"8","chore_id":"8","chore_name":"chore8","last_tracked_time":"2022-05-16 00:00:00","next_estimated_execution_time":"2022-05-28 23:59:59","track_date_only":"1","next_execution_assigned_to_user_id":"1","is_rescheduled":"0","is_reassigned":"0","next_execution_assigned_user":{"id":"1","username":"username","first_name":"","last_name":"","row_created_timestamp":"2022-05-07 17:25:42","display_name":"username","picture_file_name":null}},{"id":"9","chore_id":"9","chore_name":"chore9","last_tracked_time":null,"next_estimated_execution_time":null,"track_date_only":"1","next_execution_assigned_to_user_id":"2","is_rescheduled":"0","is_reassigned":"0","next_execution_assigned_user":{"id":"2","username":"user","first_name":"","last_name":"","row_created_timestamp":"2022-05-14 15:46:23","display_name":"username","picture_file_name":null}}]'

2022-05-28 13:58:15 ERROR (MainThread) [custom_components.grocy] Update of Chores failed with 1 validation error for CurrentChoreResponse
next_estimated_execution_time
none is not an allowed value (type=type_error.none.not_allowed)

kép

Setting manual chore to yearly:

2022-05-28 13:35:30 DEBUG (SyncWorker_16) [pygrocy.grocy_api_client] --> GET /chores
2022-05-28 13:35:30 DEBUG (SyncWorker_16) [pygrocy.grocy_api_client] <-- 200 for /chores
2022-05-28 13:35:30 DEBUG (SyncWorker_16) [pygrocy.grocy_api_client] b'[{"id":"1","chore_id":"1","chore_name":"chore1","last_tracked_time":"2022-05-23 00:00:00","next_estimated_execution_time":"2022-05-28 23:59:59","track_date_only":"1","next_execution_assigned_to_user_id":"1","is_rescheduled":"0","is_reassigned":"0","next_execution_assigned_user":{"id":"1","username":"username","first_name":"","last_name":"","row_created_timestamp":"2022-05-07 17:25:42","display_name":"username","picture_file_name":null}},{"id":"2","chore_id":"2","chore_name":"chore2","last_tracked_time":"2022-05-08 00:00:00","next_estimated_execution_time":"2022-06-03 23:59:59","track_date_only":"1","next_execution_assigned_to_user_id":"1","is_rescheduled":"0","is_reassigned":"0","next_execution_assigned_user":{"id":"1","username":"username","first_name":"","last_name":"","row_created_timestamp":"2022-05-07 17:25:42","display_name":"username","picture_file_name":null}},{"id":"3","chore_id":"3","chore_name":"chore3","last_tracked_time":"2022-05-23 00:00:00","next_estimated_execution_time":"2022-06-04 23:59:59","track_date_only":"1","next_execution_assigned_to_user_id":"1","is_rescheduled":"0","is_reassigned":"0","next_execution_assigned_user":{"id":"1","username":"username","first_name":"","last_name":"","row_created_timestamp":"2022-05-07 17:25:42","display_name":"username","picture_file_name":null}},{"id":"4","chore_id":"4","chore_name":"chore4","last_tracked_time":null,"next_estimated_execution_time":"2022-06-05 23:59:59","track_date_only":"1","next_execution_assigned_to_user_id":"1","is_rescheduled":"0","is_reassigned":"0","next_execution_assigned_user":{"id":"1","username":"username","first_name":"","last_name":"","row_created_timestamp":"2022-05-07 17:25:42","display_name":"username","picture_file_name":null}},{"id":"8","chore_id":"8","chore_name":"chore8","last_tracked_time":"2022-05-16 00:00:00","next_estimated_execution_time":"2022-05-28 23:59:59","track_date_only":"1","next_execution_assigned_to_user_id":"1","is_rescheduled":"0","is_reassigned":"0","next_execution_assigned_user":{"id":"1","username":"username","first_name":"","last_name":"","row_created_timestamp":"2022-05-07 17:25:42","display_name":"username","picture_file_name":null}},{"id":"9","chore_id":"9","chore_name":"chore9","last_tracked_time":null,"next_estimated_execution_time":"2023-05-31 12:53:29","track_date_only":"0","next_execution_assigned_to_user_id":"2","is_rescheduled":"0","is_reassigned":"0","next_execution_assigned_user":{"id":"2","username":"username","first_name":"","last_name":"","row_created_timestamp":"2022-05-14 15:46:23","display_name":"username","picture_file_name":null}}]'
2022-05-28 13:35:30 DEBUG (SyncWorker_16) [pygrocy.grocy_api_client] --> GET /chores/1
2022-05-28 13:35:30 DEBUG (SyncWorker_16) [pygrocy.grocy_api_client] <-- 200 for /chores/1
2022-05-28 13:35:30 DEBUG (SyncWorker_16) [pygrocy.grocy_api_client] b'{"chore":{"id":"1","name":"chore1","description":"","period_type":"weekly","period_days":"0","row_created_timestamp":"2022-05-08 11:46:10","period_config":"saturday","track_date_only":"1","rollover":"0","assignment_type":"in-alphabetical-order","assignment_config":"1","next_execution_assigned_to_user_id":"1","consume_product_on_execution":"0","product_id":"","product_amount":null,"period_interval":"1","active":"1","start_date":"2022-05-08 13:45:22","rescheduled_date":null,"rescheduled_next_execution_assigned_to_user_id":null},"last_tracked":"2022-05-23 00:00:00","tracked_count":3,"last_done_by":{"id":"1","username":"username","first_name":"","last_name":"","row_created_timestamp":"2022-05-07 17:25:42","display_name":"username","picture_file_name":null},"next_estimated_execution_time":"2022-05-28 23:59:59","next_execution_assigned_user":{"id":"1","username":"username","first_name":"","last_name":"","row_created_timestamp":"2022-05-07 17:25:42","display_name":"username","picture_file_name":null},"average_execution_frequency_hours":"172.5"}'
2022-05-28 13:35:30 DEBUG (SyncWorker_16) [pygrocy.grocy_api_client] --> GET /chores/2
2022-05-28 13:35:30 DEBUG (SyncWorker_16) [pygrocy.grocy_api_client] <-- 200 for /chores/2
2022-05-28 13:35:30 DEBUG (SyncWorker_16) [pygrocy.grocy_api_client] b'{"chore":{"id":"2","name":"chore2","description":"","period_type":"monthly","period_days":"3","row_created_timestamp":"2022-05-08 11:50:40","period_config":"","track_date_only":"1","rollover":"0","assignment_type":"in-alphabetical-order","assignment_config":"1","next_execution_assigned_to_user_id":"1","consume_product_on_execution":"0","product_id":"","product_amount":null,"period_interval":"1","active":"1","start_date":"2022-05-08 13:50:03","rescheduled_date":null,"rescheduled_next_execution_assigned_to_user_id":null},"last_tracked":null,"tracked_count":0,"last_done_by":null,"next_estimated_execution_time":"2022-06-03 23:59:59","next_execution_assigned_user":{"id":"1","username":"username","first_name":"","last_name":"","row_created_timestamp":"2022-05-07 17:25:42","display_name":"username","picture_file_name":null},"average_execution_frequency_hours":null}'
2022-05-28 13:35:30 DEBUG (SyncWorker_16) [pygrocy.grocy_api_client] --> GET /chores/3
2022-05-28 13:35:30 DEBUG (SyncWorker_16) [pygrocy.grocy_api_client] <-- 200 for /chores/3
2022-05-28 13:35:30 DEBUG (SyncWorker_16) [pygrocy.grocy_api_client] b'{"chore":{"id":"3","name":"chore3","description":"","period_type":"weekly","period_days":"0","row_created_timestamp":"2022-05-08 12:44:37","period_config":"saturday","track_date_only":"1","rollover":"0","assignment_type":"in-alphabetical-order","assignment_config":"1","next_execution_assigned_to_user_id":"1","consume_product_on_execution":"0","product_id":"","product_amount":null,"period_interval":"2","active":"1","start_date":"2022-05-08 14:44:08","rescheduled_date":null,"rescheduled_next_execution_assigned_to_user_id":null},"last_tracked":"2022-05-23 00:00:00","tracked_count":2,"last_done_by":{"id":"1","username":"username","first_name":"","last_name":"","row_created_timestamp":"2022-05-07 17:25:42","display_name":"username","picture_file_name":null},"next_estimated_execution_time":"2022-06-04 23:59:59","next_execution_assigned_user":{"id":"1","username":"username","first_name":"","last_name":"","row_created_timestamp":"2022-05-07 17:25:42","display_name":"username","picture_file_name":null},"average_execution_frequency_hours":"345.0"}'
2022-05-28 13:35:30 DEBUG (SyncWorker_16) [pygrocy.grocy_api_client] --> GET /chores/4
2022-05-28 13:35:30 DEBUG (SyncWorker_16) [pygrocy.grocy_api_client] <-- 200 for /chores/4
2022-05-28 13:35:30 DEBUG (SyncWorker_16) [pygrocy.grocy_api_client] b'{"chore":{"id":"4","name":"chore4","description":"","period_type":"daily","period_days":"0","row_created_timestamp":"2022-05-08 12:46:20","period_config":"","track_date_only":"1","rollover":"1","assignment_type":"in-alphabetical-order","assignment_config":"1","next_execution_assigned_to_user_id":"1","consume_product_on_execution":"0","product_id":"","product_amount":null,"period_interval":"30","active":"1","start_date":"2022-06-05 10:00:00","rescheduled_date":null,"rescheduled_next_execution_assigned_to_user_id":null},"last_tracked":null,"tracked_count":0,"last_done_by":null,"next_estimated_execution_time":"2022-06-05 23:59:59","next_execution_assigned_user":{"id":"1","username":"username","first_name":"","last_name":"","row_created_timestamp":"2022-05-07 17:25:42","display_name":"username","picture_file_name":null},"average_execution_frequency_hours":null}'
2022-05-28 13:35:30 DEBUG (SyncWorker_16) [pygrocy.grocy_api_client] --> GET /chores/8
2022-05-28 13:35:30 DEBUG (SyncWorker_16) [pygrocy.grocy_api_client] <-- 200 for /chores/8
2022-05-28 13:35:30 DEBUG (SyncWorker_16) [pygrocy.grocy_api_client] b'{"chore":{"id":"8","name":"chore8","description":"","period_type":"weekly","period_days":"0","row_created_timestamp":"2022-05-14 15:53:26","period_config":"saturday","track_date_only":"1","rollover":"0","assignment_type":"in-alphabetical-order","assignment_config":"1","next_execution_assigned_to_user_id":"1","consume_product_on_execution":"0","product_id":"","product_amount":null,"period_interval":"2","active":"1","start_date":"2022-05-15 17:52:35","rescheduled_date":null,"rescheduled_next_execution_assigned_to_user_id":null},"last_tracked":"2022-05-16 00:00:00","tracked_count":1,"last_done_by":{"id":"1","username":"username","first_name":"","last_name":"","row_created_timestamp":"2022-05-07 17:25:42","display_name":"username","picture_file_name":null},"next_estimated_execution_time":"2022-05-28 23:59:59","next_execution_assigned_user":{"id":"1","username":"username","first_name":"","last_name":"","row_created_timestamp":"2022-05-07 17:25:42","display_name":"username","picture_file_name":null},"average_execution_frequency_hours":null}'
2022-05-28 13:35:30 DEBUG (SyncWorker_16) [pygrocy.grocy_api_client] --> GET /chores/9
2022-05-28 13:35:30 DEBUG (SyncWorker_16) [pygrocy.grocy_api_client] <-- 200 for /chores/9
2022-05-28 13:35:30 DEBUG (SyncWorker_16) [pygrocy.grocy_api_client] b'{"chore":{"id":"9","name":"chore9","description":"","period_type":"yearly","period_days":"0","row_created_timestamp":"2022-05-28 10:34:44","period_config":"","track_date_only":"0","rollover":"0","assignment_type":"in-alphabetical-order","assignment_config":"1,2","next_execution_assigned_to_user_id":"2","consume_product_on_execution":"1","product_id":"52","product_amount":"1.0","period_interval":"1","active":"1","start_date":"2023-05-31 12:53:29","rescheduled_date":null,"rescheduled_next_execution_assigned_to_user_id":null},"last_tracked":null,"tracked_count":0,"last_done_by":null,"next_estimated_execution_time":"2023-05-31 12:53:29","next_execution_assigned_user":{"id":"2","username":"username","first_name":"","last_name":"","row_created_timestamp":"2022-05-14 15:46:23","display_name":"username","picture_file_name":null},"average_execution_frequency_hours":null}'

kép

Expected behavior Manual, adaptive, hourly chores are showing up with to daily ... yearly chores, in the chores sensor.

To Reproduce Steps to reproduce the behavior:

  1. Add chore in grocy with manual scheduling
  2. Activate chores entities
  3. Wait 1 minute
  4. Go to developer tools in HA and check sensor.grocy_chores
  5. Entity is in unknown state

General information to help debugging:

What sensors do you have enabled? Are they working and/or what state are they in? Do you have the corresponding functions enabled in Grocy?

What is your installed versions of Home Assistant, Grocy and this integration? Grocy: 3.3.0 Home Assistant Core: 2022.5.0 Grocy inegration: v4.2.2b

How do you have Grocy installed? Add-on or external? External via docker

Have you added debugging to the log, and what does the log say? Log was enabled:

logger:
  default: critical
  logs:
    pygrocy.grocy_api_client: debug
    custom_components.grocy: debug

Full log can be seen above in the bug description.

next_estimated_execution_time
none is not an allowed value (type=type_error.none.not_allowed)

JSON service data (if related to using a service) N/A

Additional context N/A

marcelvriend commented 2 years ago

Should be fixed with latest beta v4.3.1b.