robbinjanssen / python-ojmicroline-thermostat Goto Github PK
View Code? Open in Web Editor NEWAsynchronous Python client controlling an OJ Electronics/Microline OWD5 Thermostat
License: MIT License
Asynchronous Python client controlling an OJ Electronics/Microline OWD5 Thermostat
License: MIT License
We would like to be able to get energy usage from each thermostat from the OJMicroline API.
So we can create cool sensors in for example the home assistant integration
We need to create new requests and perhaps models to get the information from the endpoints. See https://community.home-assistant.io/t/mwd5-wifi-thermostat-oj-electronics-microtemp/445601 for more information
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.
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.
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?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))
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates are awaiting their schedule. Click on a checkbox to get an update now.
.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
pyproject.toml
poetry-core >=1.0.0
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.