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

[Bug] Setup broken #91

Open
b24home opened this issue Feb 26, 2024 · 5 comments
Open

[Bug] Setup broken #91

b24home opened this issue Feb 26, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@b24home
Copy link

b24home commented Feb 26, 2024

Describe the bug
Even after following directions to modify the config.yaml file, I cannot make this work. Installing through HACS leads to an error message that says the UI cannot be used. I’ve instead modified the configuration file, but upon restart, there are still no signs (in the devices nor the integrations section) that things have worked.

@b24home b24home added the bug Something isn't working label Feb 26, 2024
@Jbrown47
Copy link

Having kind of the same issue. But I get no error. Just doesn't show up.

@Waank1
Copy link

Waank1 commented Mar 18, 2024

Having the same problem, getting the following error:

Detected blocking call to putrequest inside the event loop by custom integration 'sengledapi' at custom_components/sengledapi/sengledapi/devices/request.py, line 40: r = requests.post(self._url, headers=self._header, data=self._payload), please report it to the author of the 'sengledapi' custom integration

@Waank1
Copy link

Waank1 commented Apr 5, 2024

Getting following error:

Logger: homeassistant.components.light
Source: components/light/init.py:1325
integration: Light (documentation, issues)
First occurred: 14:13:43 (8 occurrences)
Last logged: 14:13:43

Entity None (<class 'custom_components.sengledapi.light.SengledBulb'>) is using deprecated supported features values which will be removed in HA Core 2025.1. Instead it should use <LightEntityFeature: 1> and color modes, please report it to the author of the 'sengledapi' custom integration and reference https://developers.home-assistant.io/blog/2023/12/28/support-feature-magic-numbers-deprecation
Entity None (<class 'custom_components.sengledapi.light.SengledBulb'>) is using deprecated supported features values which will be removed in HA Core 2025.1. Instead it should use <LightEntityFeature: 19> and color modes, please report it to the author of the 'sengledapi' custom integration and reference https://developers.home-assistant.io/blog/2023/12/28/support-feature-magic-numbers-deprecation

@perezjoseph
Copy link

perezjoseph commented Apr 10, 2024

You have to modify class request on request.py

After modifying I was able to get the integration working.

class Request:
def init(self, url, payload, no_return=False):
_LOGGER.info("SengledApi: Sengled Request initializing.")
self._url = url
self._payload = json.dumps(payload)
self._no_return = no_return
self._response = None
self._jsession_id = None

    self._header = {
        "Content-Type": "application/json",
        "Host": "element.cloud.sengled.com:443",
        "Connection": "keep-alive",
    }

async def async_get_response(self, jsession_id):
    self._header = {
        "Content-Type": "application/json",
        "Cookie": f"JSESSIONID={jsession_id}",
        "Connection": "keep-alive",
    }
    
    
    sslcontext = ssl.create_default_context(cafile=certifi.where())

    # Use aiohttp's ClientSession for asynchronous HTTP requests.
    async with aiohttp.ClientSession() as session:
        async with session.post(self._url, headers=self._header, data=self._payload, ssl=sslcontext) as response:
            if response.status == 200:
                data = await response.json()
                return data
            else:
                return None

@perezjoseph
Copy link

"""Sengled Bulb Integration."""

import json
import logging
import ssl

import aiohttp
import certifi
import requests

from .exceptions import SengledApiAccessToken

_LOGGER = logging.getLogger(__name__)

_LOGGER.info("SengledApi: Initializing Request")


class Request:
    def __init__(self, url, payload, no_return=False):
        _LOGGER.info("SengledApi: Sengled Request initializing.")
        self._url = url
        self._payload = json.dumps(payload)
        self._no_return = no_return
        self._response = None
        self._jsession_id = None

        self._header = {
            "Content-Type": "application/json",
            "Host": "element.cloud.sengled.com:443",
            "Connection": "keep-alive",
        }

    async def async_get_response(self, jsession_id):
        self._header = {
            "Content-Type": "application/json",
            "Cookie": f"JSESSIONID={jsession_id}",
            "Connection": "keep-alive",
        }
        
        # It's important to create a new SSL context for secure HTTPS requests.
        sslcontext = ssl.create_default_context(cafile=certifi.where())

        # Use aiohttp's ClientSession for asynchronous HTTP requests.
        async with aiohttp.ClientSession() as session:
            async with session.post(self._url, headers=self._header, data=self._payload, ssl=sslcontext) as response:
                # Make sure to handle potential exceptions and non-JSON responses appropriately.
                if response.status == 200:
                    data = await response.json()
                    return data
                else:
                    # Log an error or handle the response appropriately if not successful.
                    return None

    ########################Login#####################################
    def get_login_response(self):
        _LOGGER.info("SengledApi: Get Login Reponse.")
        r = requests.post(self._url, headers=self._header, data=self._payload)
        data = r.json()
        _LOGGER.debug("SengledApi: Get Login Reponse %s", str(data))
        return data

    async def async_get_login_response(self):
        _LOGGER.info("SengledApi: Get Login Response async.")
        async with aiohttp.ClientSession() as session:
            sslcontext = ssl.create_default_context(cafile=certifi.where())
            async with session.post(
                self._url, headers=self._header, data=self._payload, ssl=sslcontext
            ) as resp:
                data = await resp.json()
                _LOGGER.debug("SengledApi: Get Login Response %s ", str(data))
                return data

    ######################Session Timeout#################################
    def is_session_timeout_response(self, jsession_id):
        _LOGGER.info("SengledApi: Get Session Timeout Response")
        self._header = {
            "Content-Type": "application/json",
            "Cookie": "JSESSIONID={}".format(jsession_id),
            "sid": jsession_id,
            "X-Requested-With": "com.sengled.life2",
        }

        r = requests.post(self._url, headers=self._header, data=self._payload)
        data = r.json()
        _LOGGER.debug("SengledApi: Get Session Timeout Response %s", str(data))
        return data

    async def async_is_session_timeout_response(self, jsession_id):
        _LOGGER.info("SengledApi: Get Session Timeout Response Async")
        self._header = {
            "Content-Type": "application/json",
            "Cookie": "JSESSIONID={}".format(jsession_id),
            "sid": jsession_id,
            "X-Requested-With": "com.sengled.life2",
        }
        async with aiohttp.ClientSession() as session:
            sslcontext = ssl.create_default_context(cafile=certifi.where())
            async with session.post(
                self._url, headers=self._header, data=self._payload, ssl=sslcontext
            ) as resp:
                data = await resp.json()
                _LOGGER.info(
                    "SengledApi: Get Session Timeout Response Async %s", str(data)
                )
                return data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants