petrleocompel / hikaxpro_hacs

HACS repository of Hikvision Ax Pro integration for home assistant
MIT License
40 stars 4 forks source link

Subsystem - Main system reflect any subsystem #74

Closed strakadavid closed 10 months ago

strakadavid commented 10 months ago

*Environment**:

Issue Description: There are two defined areas within the AX PRO setup - one for the house and another for the garage. Each area is represented by its own entity in Home Assistant (alarm_control_panel.garage for the garage and alarm_control_panel.ax_pro for the house). However, when changing the state of one entity (e.g., to 'Away', 'Home', or 'Disabled'), both entities appear to be simultaneously controlled and thus reflect the same state.

Steps to Reproduce:

  1. Define two areas in the AX PRO setup
  2. In Home Assistant, observe the entities alarm_control_panel.second and alarm_control_panel.ax_pro.
  3. Set the alarm_control_panel.second entity to 'Away'.
  4. Notice that the alarm_control_panel.ax_pro entity also shows 'Away', despite not being manually changed.

Expected Behavior: When an area's state is changed, it should not affect the state of another unrelated area. Each entity should maintain its state independently unless explicitly altered.

Actual Behavior: Changing the state of one entity (either alarm_control_panel.garage or alarm_control_panel.ax_pro) causes both entities to display the same state in Home Assistant, even if only one area is set to that state.

Additional Information:

Please investigate this issue as it prevents correct status reporting and manipulation of the individual areas within the Home Assistant environment.

Thank you for your assistance.

petrleocompel commented 10 months ago

What are your settings of the integration? Are you using multiple instances of this integration?

strakadavid commented 10 months ago

What are your settings of the integration? Are you using multiple instances of this integration?

I am using only one instance of this integration.

petrleocompel commented 10 months ago

What are your settings of the integration?

strakadavid commented 10 months ago

What are your settings of the integration?

axpro_config

petrleocompel commented 10 months ago

@strakadavid Ok it is not so easy.

This beahaviour is caused by ISAPI inconsistency a little bit.

        try:
            subsys_resp = SubSystemResponse.from_dict(status_json)
            subsys_arr: list[SubSys] = []
            if subsys_resp is not None and subsys_resp.sub_sys_list is not None:
                subsys_arr = []
                for sublist in subsys_resp.sub_sys_list:
                    subsys_arr.append(sublist.sub_sys)
            func: Callable[[SubSys], bool] = lambda n: n.enabled
            subsys_arr = list(filter(func, subsys_arr))
            self.sub_systems = {}
            for subsys in subsys_arr:
                self.sub_systems[subsys.id] = subsys
                if subsys.alarm:
                    status = STATE_ALARM_TRIGGERED
                elif subsys.arming == Arming.AWAY:
                    status = STATE_ALARM_ARMED_AWAY
                elif subsys.arming == Arming.STAY:
                    status = STATE_ALARM_ARMED_HOME
                elif subsys.arming == Arming.VACATION:
                    status = STATE_ALARM_ARMED_VACATION
            _LOGGER.debug("SubSystem status: %s", subsys_resp)
        except:
            _LOGGER.warning("Error getting status: %s", status_json)
        _LOGGER.debug("Axpro status: %s", status)
        self.state = status

Problem is "ISAPI" does not have "main" system. It is just system ID 1... And nowhere is said it will be like it for ever.

Basically "main" system reflect all other sub systems. And if you do not use "sub-systems" and you accidentally activate one of subsystem (via app for example) it is not visible then.

So only solution is "if subsystems are allowed" it will not be visible in "main" system.

petrleocompel commented 10 months ago

Closed in V2.1.0-beta10