Closed felipecrs closed 1 year ago
Hmm. Weird. It is directly the state Asterisk gives.
So maybe this is an issue in the library the integration uses. I'll follow up.
Oh no. You are right. Most likely this is an issue in Asterisk itself. Sad.
Well... Reporting bugs in Asterisk is really complicated. It would be nice if we could do something like:
asterisk_state = event.get_header("State")
# Workaround for https://github.com/TECH7Fox/asterisk-hass-integration/issues/68
# Until the issue gets fixed upstream.
if asterisk_state == "NOT IN USE":
self._state = "NOT_INUSE"
else:
self._state = asterisk_state
I tried it but it doesn't seem to work. Anyway, if you think it's not a good idea, feel free to close this issue.
NOT IN USE
only appears when the integration is first loaded/reload. Could this be because of this?
Yeah, this is actually how the issue is fixed for me:
def __init__(self, hass, status, extension, tech, entry):
"""Setting up extension."""
self._hass = hass
self._astmanager = hass.data[DOMAIN][entry.entry_id]["manager"]
self._extension = extension
self._state = "NOT_INUSE" if status == "NOT IN USE" else status
self._tech = tech
self._entry = entry
self._unique_id = f"{entry.entry_id}_{extension}_state"
self._astmanager.register_event("DeviceStateChange", self.handle_asterisk_event)
The question is, where do this "status" comes from?
Asterisk gives the state in a different format in some events then others, which is kinda weird but I've mapped them to be consistant now. Please reopen if you still get unexpected states.
Thanks a ton!