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

PIN code requirement #28

Open
simie7 opened this issue Oct 15, 2023 · 0 comments
Open

PIN code requirement #28

simie7 opened this issue Oct 15, 2023 · 0 comments

Comments

@simie7
Copy link

simie7 commented Oct 15, 2023

My cloud authentication requires PIN code to enter, otherwise it doesn't work. I tested and debugged it with curl.

For this module to work, I need to modify code, examples below. CODE is 4 digit pin code that I use to switch on and off alarm from the keyboard.

Get Partitions:

    async def get_device_partitions(self, imei):
        """Gets device partitions/zones."""
        data = {
            'imei': imei,
            'pin': 'CODE'
        }
            
        url = f"{API_URL}{API_PATHS['DEVICE']}partition/list?imei={imei}"
        
        response = await self._api_call(url, "POST", data)
        result = await response.json()
        partitions = result.get("partitions", [])

        # Replace Eldes state with HA state name
        for partitionIndex, _ in enumerate(partitions):
            partitions[partitionIndex]["state"] = ALARM_STATES_MAP[partitions[partitionIndex].get("state", STATE_ALARM_DISARMED)]
                
        _LOGGER.debug(
            "get_device_partitions result: %s",
            partitions
        )
        
        return partitions

Get Outputs:

    async def get_device_outputs(self, imei):
        """Gets device outputs/automations."""
        data = {
            'imei': imei,
            'pin': 'CODE'
        }

        url = f"{API_URL}{API_PATHS['DEVICE']}list-outputs/{imei}"

        response = await self._api_call(url, "POST", data)
        result = await response.json()
        outputs = result.get("deviceOutputs", [])

        _LOGGER.debug(
            "get_device_outputs result: %s",
            outputs
        )

        return outputs

Set Alarm:

    async def set_alarm(self, mode, imei, zone_id):
        """Sets alarm to provided mode."""
        data = {
            'imei': imei,
            'pin': 'CODE',
            'partitionIndex': zone_id
        }
            
        url = f"{API_URL}{API_PATHS['DEVICE']}action/{mode}"
            
        response = await self._api_call(url, "POST", data)
        result = await response.text()
        
        _LOGGER.debug(
            "set_alarm result: %s",
            result
        )
            
        return result

Turn On Output:

    async def turn_on_output(self, imei, output_id):
        """Turns on output."""
        data = {
            'pin': 'CODE'
        }

        url = f"{API_URL}{API_PATHS['DEVICE']}control/enable/{imei}/{output_id}"

        response = await self._api_call(url, "PUT", data)

        _LOGGER.debug(
            "turn_on_output response: %s",
            response
        )

        return response

Turn Off Output:

    async def turn_off_output(self, imei, output_id):
        """Turns off output."""
        data = {
            'pin': 'CODE'
        }

        url = f"{API_URL}{API_PATHS['DEVICE']}control/disable/{imei}/{output_id}"

        response = await self._api_call(url, "PUT", data)

        _LOGGER.debug(
            "turn_off_output response: %s",
            response
        )

        return response

Get Temperatures:

    async def get_temperatures(self, imei):
        """Gets device information."""
        data = {
            'imei': imei,
            'pin': 'CODE'
        }
            
        url = f"{API_URL}{API_PATHS['DEVICE']}temperatures?imei={imei}"
            
        response = await self._api_call(url, "POST", data)
        result = await response.json()
        temperatures = result.get("temperatureDetailsList", [])

        _LOGGER.debug(
            "get_temperatures result: %s",
            temperatures
        )

        return temperatures

Get Events:

    async def get_events(self, size):
        """Gets device events."""
        data = {
            "": "",
            'pin': 'CODE',
            "size": size,
            "start": 0
        }

        url = f"{API_URL}{API_PATHS['DEVICE']}event/list"
            
        response = await self._api_call(url, "POST", data)
        result = await response.json()
        events = result.get("eventDetails", [])
        
        _LOGGER.debug(
            "get_events result: %s",
            events
        )

        return events

I understand that it is not correct problem solving, would be better to enter code on ELDES configuration and use as variable, but I don't know how to do it not breaking module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant