Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

force refresh after excecute chore service #41

Merged
merged 2 commits into from
Jan 8, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
force refresh after excecute chore service
  • Loading branch information
BlueBlueBlob committed Jan 8, 2020
commit e9c90065d20b39569f3ddf0650684b176c25e59b
9 changes: 6 additions & 3 deletions custom_components/grocy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
import logging
import os
from datetime import timedelta
import asyncio
SebRut marked this conversation as resolved.
Show resolved Hide resolved

import homeassistant.helpers.config_validation as cv
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.const import (CONF_API_KEY, CONF_PORT, CONF_URL,
CONF_VERIFY_SSL)
from homeassistant.core import callback
from homeassistant.helpers import discovery
from homeassistant.helpers import discovery, entity_component
from homeassistant.util import Throttle
from integrationhelper.const import CC_STARTUP_VERSION

Expand Down Expand Up @@ -153,6 +154,8 @@ def handle_execute_chore(call):
if tracked_time_str is not None:
tracked_time = iso8601.parse_date(tracked_time_str)
grocy.execute_chore(chore_id, done_by, tracked_time)
asyncio.run_coroutine_threadsafe(entity_component.async_update_entity(hass, 'sensor.grocy_chores'),
hass.loop)

hass.services.async_register(DOMAIN, "execute_chore", handle_execute_chore)

Expand Down Expand Up @@ -197,14 +200,14 @@ async def async_update_stock(self):
self.hass.data[DOMAIN_DATA][STOCK_NAME] = (
await self.hass.async_add_executor_job(self.client.stock, [True]))

@Throttle(MIN_TIME_BETWEEN_UPDATES)

SebRut marked this conversation as resolved.
Show resolved Hide resolved
async def async_update_chores(self):
"""Update data."""
# This is where the main logic to update platform data goes.
self.hass.data[DOMAIN_DATA][CHORES_NAME] = (
await self.hass.async_add_executor_job(self.client.chores, [True]))

@Throttle(MIN_TIME_BETWEEN_UPDATES)

SebRut marked this conversation as resolved.
Show resolved Hide resolved
async def async_update_shopping_list(self):
"""Update data."""
# This is where the main logic to update platform data goes.
Expand Down