Giter Site home page Giter Site logo

robbinjanssen / python-ojmicroline-thermostat Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 3.0 1.08 MB

Asynchronous Python client controlling an OJ Electronics/Microline OWD5 Thermostat

License: MIT License

Python 100.00%
climate oj-microline ojelectronics ojmicroline owd5 python thermostat

python-ojmicroline-thermostat's People

Contributors

adamjernst avatar dependabot[bot] avatar renovate[bot] avatar robbinjanssen avatar snoack avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

python-ojmicroline-thermostat's Issues

UWG4/AWG4 support?

Great project. I would like to know if you would accept patches to add support for UWG4/AWG4 thermostats.

There is prior art on how to do it, but that integration is much less mature than yours. It's a bit odd because OJ Microline basically operates two completely separate APIs for OWD5 vs UWG4/AWG4, so to implement the changes this library would have to attempt signing in to both APIs and see which one works… definitely odd. (Or ask the user to select up-front which model of thermostat they have, as part of the config process.)

Let me know what you think.

Add support for notification streams

Both WD5 and WD4 have support for notification streams. Basically this is a HTTP GET call that is kept-alive and keeps receiving JSON updates about thermostats.

  1. Where do we put this code, ojmicroline.py is currently responsible for data-fetching, however since both WD4 and WD5 are pretty different (1 call vs 3 calls), im not sure where to put it. @adamjernst any suggestions?
  2. Then we need to figure out what HA requires for these push updates. I think we need to implement something like registration for listeners and callbacks to those listeners?

For WD5 this is a POC:

async def get_stream_connection(
    self, 
    session_id: str,
    session: ClientSession
) -> Any:
    async with async_timeout.timeout(30):
        # Negotiate
        url = URL.build(
            scheme="https", 
            host=self.host, 
            path="/ocd5notification/negotiate",
            query={"clientProtocol": "1.3"}
        )
        
        response = await session.request(method="GET", url=url, ssl=True)
        response.raise_for_status()

        data = json.loads(await response.text());
        connectionId = data['ConnectionId']
        connectionToken = data['ConnectionToken']
    
        # Start
        url = URL.build(
            scheme="https", 
            host=self.host, 
            path="/ocd5notification/send",
            query={
                "transport": "serverSentEvents",
                "connectionToken": connectionToken,
                "connectionId": connectionId,
            },
        )

        response = await session.request(
            method="POST",
            url=url, 
            headers={"Content-Type": "application/x-www-form-urlencoded"}, 
            data=f"data={session_id}",
            ssl=True
        )
        response.raise_for_status()

        # Connect to stream
        url = URL.build(
            scheme="https", 
            host=self.host, 
            path="/ocd5notification/connect",
            query={
                "transport": "serverSentEvents",
                "connectionToken": connectionToken,
                "connectionId": connectionId,
            },
        )

        response = await session.request(method="GET", url=url, headers={"Accept":"text/event-stream"}, ssl=True)
        response.raise_for_status()

        async for line in response.content:
            data = line.decode('ascii').strip()
            if (data == ""):
                continue

            data = data[6:]
            if data != 'initialized':
                data = json.loads(data)
            
            if "M" not in data:
                continue
            
            for event in data["M"]:
                print(json.dumps(event, indent=2))

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • ⬆️ Lock file maintenance

Detected dependencies

github-actions
.github/workflows/codeql.yaml
  • actions/checkout v4.1.5
  • github/codeql-action v3.25.5
  • github/codeql-action v3.25.5
.github/workflows/draft-release.yaml
  • release-drafter/release-drafter v6.0.0
.github/workflows/issues.yaml
  • dessant/lock-threads v5.0.1
  • actions/stale v9.0.0
.github/workflows/linting.yaml
  • actions/checkout v4.1.5
  • actions/setup-python v5.1.0
  • actions/checkout v4.1.5
  • actions/setup-python v5.1.0
  • actions/checkout v4.1.5
  • actions/setup-python v5.1.0
  • actions/checkout v4.1.5
  • actions/setup-python v5.1.0
  • actions/checkout v4.1.5
  • actions/setup-python v5.1.0
.github/workflows/release.yaml
  • actions/checkout v4.1.5
  • actions/setup-python v5.1.0
.github/workflows/sync-labels.yaml
  • actions/checkout v4.1.5
  • micnncim/action-label-syncer v1.3.0
.github/workflows/tests.yaml
  • actions/checkout v4.1.5
  • actions/setup-python v5.1.0
  • actions/upload-artifact v4.3.3
  • actions/checkout v4.1.5
  • actions/download-artifact v4.1.7
  • actions/setup-python v5.1.0
  • codecov/codecov-action v4.4.0
.github/workflows/typing.yaml
  • actions/checkout v4.1.5
  • actions/setup-python v5.1.0
.github/workflows/verify-pr-labels.yaml
  • jesusvasquez333/verify-pr-label-action v1.4.0
pep621
pyproject.toml
  • poetry-core >=1.0.0
poetry
pyproject.toml
  • aiohttp >=3.0.0
  • python ^3.9
  • yarl >=1.6.0
  • aresponses 3.0.0
  • codespell 2.2.6
  • covdefaults 2.3.0
  • coverage 7.5.1
  • mypy 1.10.0
  • pre-commit 3.7.1
  • pre-commit-hooks 4.6.0
  • pylint 3.2.0
  • pytest 8.2.0
  • pytest-asyncio 0.23.6
  • pytest-cov 5.0.0
  • ruff 0.4.4
  • yamllint 1.35.1
  • pytz 2024.1
  • async-timeout 4.0.3
  • freezegun 1.5.1

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.