Skip to content

Commit

Permalink
update event name again (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
raman325 authored Feb 26, 2024
1 parent 3ea160f commit 29cddd2
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion custom_components/lock_code_manager/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
COORDINATORS = "coordinators"

# Events
EVENT_LOCK_USERCODE_USED = f"{DOMAIN}_usercode_used"
EVENT_LOCK_STATE_CHANGED = f"{DOMAIN}_lock_state_changed"

# Event data constants
ATTR_ACTION_TEXT = "action_text"
Expand Down
4 changes: 2 additions & 2 deletions custom_components/lock_code_manager/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .const import DOMAIN, EVENT_LOCK_USERCODE_USED, EVENT_PIN_USED
from .const import DOMAIN, EVENT_LOCK_STATE_CHANGED, EVENT_PIN_USED
from .entity import BaseLockCodeManagerEntity

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -77,7 +77,7 @@ async def async_added_to_hass(self) -> None:
await BaseLockCodeManagerEntity.async_added_to_hass(self)
self.async_on_remove(
self.hass.bus.async_listen(
EVENT_LOCK_USERCODE_USED,
EVENT_LOCK_STATE_CHANGED,
self._handle_event,
self._event_filter,
)
Expand Down
4 changes: 2 additions & 2 deletions custom_components/lock_code_manager/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .const import CONF_NUMBER_OF_USES, CONF_SLOTS, DOMAIN, EVENT_LOCK_USERCODE_USED
from .const import CONF_NUMBER_OF_USES, CONF_SLOTS, DOMAIN, EVENT_LOCK_STATE_CHANGED
from .entity import BaseLockCodeManagerEntity

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -76,7 +76,7 @@ async def async_added_to_hass(self) -> None:
await BaseLockCodeManagerEntity.async_added_to_hass(self)
self.async_on_remove(
self.hass.bus.async_listen(
EVENT_LOCK_USERCODE_USED,
EVENT_LOCK_STATE_CHANGED,
self._handle_lock_state_changed,
self._event_filter,
)
Expand Down
4 changes: 2 additions & 2 deletions custom_components/lock_code_manager/providers/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
CONF_LOCKS,
CONF_SLOTS,
DOMAIN,
EVENT_LOCK_USERCODE_USED,
EVENT_LOCK_STATE_CHANGED,
)
from .const import LOGGER
from .helpers import get_entry_data
Expand Down Expand Up @@ -283,7 +283,7 @@ def fire_code_slot_event(
extra_data = source_data

self.hass.bus.async_fire(
EVENT_LOCK_USERCODE_USED,
EVENT_LOCK_STATE_CHANGED,
event_data={
ATTR_NOTIFICATION_SOURCE: notification_source,
ATTR_ENTITY_ID: lock_entity_id,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
ATTR_FROM,
ATTR_NOTIFICATION_SOURCE,
ATTR_TO,
EVENT_LOCK_USERCODE_USED,
EVENT_LOCK_STATE_CHANGED,
)

from .common import LOCK_1_ENTITY_ID
Expand Down Expand Up @@ -47,7 +47,7 @@ async def test_event_entity(
ATTR_TO: STATE_UNLOCKED,
}

hass.bus.async_fire(EVENT_LOCK_USERCODE_USED, event_data)
hass.bus.async_fire(EVENT_LOCK_STATE_CHANGED, event_data)

await hass.async_block_till_done()

Expand Down
4 changes: 2 additions & 2 deletions tests/test_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
ATTR_FROM,
ATTR_NOTIFICATION_SOURCE,
ATTR_TO,
EVENT_LOCK_USERCODE_USED,
EVENT_LOCK_STATE_CHANGED,
)

from .common import LOCK_1_ENTITY_ID
Expand All @@ -31,7 +31,7 @@ async def test_number_entity(
assert state.state == "5"

hass.bus.async_fire(
EVENT_LOCK_USERCODE_USED,
EVENT_LOCK_STATE_CHANGED,
{
ATTR_NOTIFICATION_SOURCE: "event",
ATTR_ENTITY_ID: LOCK_1_ENTITY_ID,
Expand Down

0 comments on commit 29cddd2

Please sign in to comment.