Skip to content

Commit

Permalink
Removed not working magic
Browse files Browse the repository at this point in the history
  • Loading branch information
kukulich committed Feb 19, 2021
1 parent 264ad58 commit 7a97142
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
27 changes: 2 additions & 25 deletions custom_components/jablotron100/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from homeassistant.helpers.typing import StateType
from typing import Optional
from .const import DATA_JABLOTRON, DOMAIN
from .jablotron import JablotronEntity, JablotronAlarmControlPanel, Jablotron
from .jablotron import JablotronEntity, JablotronAlarmControlPanel


async def async_setup_entry(hass: core.HomeAssistant, config_entry: config_entries.ConfigEntry, async_add_entities) -> None:
Expand All @@ -25,15 +25,7 @@ async def async_setup_entry(hass: core.HomeAssistant, config_entry: config_entri


class JablotronAlarmControlPanelEntity(JablotronEntity, AlarmControlPanelEntity):

def __init__(
self,
jablotron: Jablotron,
control: JablotronAlarmControlPanel,
) -> None:
super().__init__(jablotron, control)

self._state_before_arming: Optional[str] = None
_control: JablotronAlarmControlPanel

@property
def state(self) -> StateType:
Expand All @@ -55,16 +47,6 @@ def code_format(self) -> Optional[str]:
def supported_features(self) -> int:
return SUPPORT_ALARM_ARM_AWAY | SUPPORT_ALARM_ARM_NIGHT

def update_state(self, state: str) -> None:
state_before_arming = self._state_before_arming
self._state_before_arming = None

if self._state == STATE_ALARM_ARMING and state_before_arming == state:
# Ignore first update because it's probably outdated
return

super().update_state(state)

async def async_alarm_disarm(self, code: Optional[str] = None) -> None:
if self._state == STATE_ALARM_DISARMED:
return
Expand All @@ -74,7 +56,6 @@ async def async_alarm_disarm(self, code: Optional[str] = None) -> None:
if code is None and self._jablotron.is_code_required_for_disarm():
return

self._state_before_arming = None
self._jablotron.modify_alarm_control_panel_section_state(self._control.section, STATE_ALARM_DISARMED, code)
self.update_state(STATE_ALARM_DISARMED)

Expand All @@ -87,9 +68,7 @@ async def async_alarm_arm_away(self, code: Optional[str] = None) -> None:
if code is None and self._jablotron.is_code_required_for_arm():
return

state_before_arming = self._state
self.update_state(STATE_ALARM_ARMING)
self._state_before_arming = state_before_arming
self._jablotron.modify_alarm_control_panel_section_state(self._control.section, STATE_ALARM_ARMED_AWAY, code)

async def async_alarm_arm_night(self, code: Optional[str] = None) -> None:
Expand All @@ -101,9 +80,7 @@ async def async_alarm_arm_night(self, code: Optional[str] = None) -> None:
if code is None and self._jablotron.is_code_required_for_arm():
return

state_before_arming = self._state
self.update_state(STATE_ALARM_ARMING)
self._state_before_arming = state_before_arming
self._jablotron.modify_alarm_control_panel_section_state(self._control.section, STATE_ALARM_ARMED_NIGHT, code)

@staticmethod
Expand Down
6 changes: 3 additions & 3 deletions custom_components/jablotron100/jablotron.py
Original file line number Diff line number Diff line change
Expand Up @@ -1734,9 +1734,9 @@ def create_packets_keepalive(code: str) -> List[bytes]:
class JablotronEntity(Entity):

def __init__(
self,
jablotron: Jablotron,
control: JablotronControl,
self,
jablotron: Jablotron,
control: JablotronControl,
) -> None:
self._jablotron: Jablotron = jablotron
self._control: JablotronControl = control
Expand Down

0 comments on commit 7a97142

Please sign in to comment.