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

Optional TemperatureClient to redirect temperature readings another HA entity #22

Closed
wants to merge 57 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
0217ebd
Refactor to extract web client
matthewturner Dec 14, 2023
b529409
Add mock web client
matthewturner Dec 14, 2023
8fe06a8
Fix import order
matthewturner Dec 15, 2023
f9f21f4
Fix min/max temp
matthewturner Dec 15, 2023
36cf9df
Create HA connection
matthewturner Dec 15, 2023
8acac28
Add config values
matthewturner Dec 15, 2023
7cba435
Improved handling when starting up
matthewturner Dec 15, 2023
2efb2fb
Improve readme
matthewturner Dec 15, 2023
868de9c
Reuse cached token for 10 mins
matthewturner Dec 16, 2023
d89d1ef
Improve output of install script
matthewturner Dec 16, 2023
96e4964
Add unit tests (#1)
matthewturner Dec 16, 2023
f431633
Add thermostat entity unit tests (#2)
matthewturner Dec 17, 2023
abb9b1b
Verify salus only called once (#3)
matthewturner Dec 17, 2023
c9d1e32
Update from source (#4)
matthewturner Feb 16, 2024
1551167
Create wrapper client (#5)
matthewturner Feb 16, 2024
fc9837c
Refactor to extract web client
matthewturner Dec 14, 2023
acc4a12
Add mock web client
matthewturner Dec 14, 2023
3eedc19
Fix import order
matthewturner Dec 15, 2023
5daf74e
Fix min/max temp
matthewturner Dec 15, 2023
8324fe2
Create HA connection
matthewturner Dec 15, 2023
552cff5
Add config values
matthewturner Dec 15, 2023
0ae985a
Improved handling when starting up
matthewturner Dec 15, 2023
e50bdbb
Improve readme
matthewturner Dec 15, 2023
43f36d2
Reuse cached token for 10 mins
matthewturner Dec 16, 2023
23f0ef6
Improve output of install script
matthewturner Dec 16, 2023
ada46e7
Add unit tests (#1)
matthewturner Dec 16, 2023
796b12d
Add thermostat entity unit tests (#2)
matthewturner Dec 17, 2023
3f2deae
Verify salus only called once (#3)
matthewturner Dec 17, 2023
d0c1415
Update from source (#4)
matthewturner Feb 16, 2024
20f2389
Create wrapper client (#5)
matthewturner Feb 16, 2024
29c56da
Merge branch 'main' into rebase-on-source
matthewturner Feb 16, 2024
b3941de
Merge pull request #6 from matthewturner/rebase-on-source
matthewturner Feb 16, 2024
476776c
Add devcontainer (#7)
matthewturner Feb 17, 2024
651030e
Fix line endings
matthewturner Feb 17, 2024
1caff2c
Remove socket blocking (#8)
matthewturner Feb 17, 2024
593cebd
Remove socket blocking (#9)
matthewturner Feb 17, 2024
d7ddc1b
Fix line endings
matthewturner Feb 17, 2024
dbe21e1
Switch to async (#10)
matthewturner Feb 25, 2024
19a3150
Switch to aiohttp (#11)
matthewturner Feb 25, 2024
43d7c2f
Switch to aiohttp (#12)
matthewturner Feb 25, 2024
c0518e5
Fix startup (#13)
matthewturner Feb 25, 2024
8c57a85
Ensure async methods are called (#14)
matthewturner Feb 25, 2024
18aff23
Suppress warnings (#15)
matthewturner Feb 25, 2024
bb7e0a4
Remove HEAT custom constant (#16)
matthewturner Feb 26, 2024
838cfea
Switch to hvac action (#17)
matthewturner Feb 26, 2024
732d3d3
Update readme (#18)
matthewturner Feb 26, 2024
9dfbea0
Make temperature client config values optional (#19)
matthewturner Feb 27, 2024
03d6bd8
Assume hvac action based on current/target temp (#21)
matthewturner Feb 27, 2024
c6ec2cd
Add type annotations (#22)
matthewturner Mar 1, 2024
5fb9041
Fix preset_modes type annotation (#23)
matthewturner Mar 1, 2024
205a5da
Fix linting errors (#24)
matthewturner Mar 1, 2024
f38066f
Add format command (#25)
matthewturner Mar 1, 2024
6ccd7df
Fix more linting errors (#26)
matthewturner Mar 1, 2024
36337a5
Change state to dataclass (#27)
matthewturner Mar 1, 2024
86df172
Report auto status accurately (#28)
matthewturner Mar 1, 2024
fcdb1bc
Fix linting errors (#29)
matthewturner Mar 1, 2024
2070cc8
Fix linting errors (#30)
matthewturner Mar 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ,gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
17 changes: 17 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye",
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pip3 install --user -r requirements.txt -r requirements.test.txt"
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements.ci.txt ]; then pip install -r requirements.ci.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
config.py
*.pyc
__pycache__
.pytest_cache/
6 changes: 6 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[MAIN]
ignore-paths=
config.py

disable=
missing-module-docstring
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"python.testing.pytestArgs": [
"."
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
132 changes: 89 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,89 @@
# Home-Assistant Custom Components
Custom Components for Home-Assistant (http://www.home-assistant.io)

# Salus Thermostat Climate Component
My device is RT301i, it is working with it500 thermostat, the ideea is simple if you have a Salus Thermostat and you are able to login to salus-it500.com and controll it from this page, this custom component should work.
Component to interface with the salus-it500.com.
It reads the Current Temperature, Set Temperature, Current HVAC Mode, Current Relay Mode.

Keep in mind this is my first custom component and this is also the first version of this Salusfy so it can have bugs. Sorry for that.

**** This is not an official integration.
### Installation
* If not exist, in config/custom_components/ create a directory called salusfy
* Copy all files in salusfy to your config/custom_components/salusfy/ directory.
* Configure with config below.
* Restart Home-Assistant.

### Usage
To use this component in your installation, add the following to your configuration.yaml file:

### Example configuration.yaml entry

```
climate:
- platform: salusfy
username: "EMAIL"
password: "PASSWORD"
id: "DEVICEID"
```
![image](https://user-images.githubusercontent.com/33951255/140300295-4915a18f-f5d4-4957-b513-59d7736cc52a.png)
![image](https://user-images.githubusercontent.com/33951255/140303472-fd38b9e4-5c33-408f-afef-25547c39551c.png)


### Getting the DEVICEID
1. Loggin to https://salus-it500.com with email and password used in the mobile app(in my case RT301i)
2. Click on the device
3. In the next page you will be able to see the device ID in the page URL
4. Copy the device ID from the URL
![image](https://user-images.githubusercontent.com/33951255/140301260-151b6af9-dbc4-4e90-a14e-29018fe2e482.png)


### Known issues
salus-it500.com server is bloking the IP of the host, in our case the HA external IP. This can be fixed with router restart in case of PPOE connection or you can try to send a mail to salus support...
# Home-Assistant Custom Components

[![CI](https://github.com/matthewturner/salusfy/actions/workflows/ci.yml/badge.svg)](https://github.com/matthewturner/salusfy/actions/workflows/ci.yml)

Custom Components for Home-Assistant (http://www.home-assistant.io)

# Salus Thermostat Climate Component
My device is RT301i, it is working with it500 thermostat, the idea is simple if you have a Salus Thermostat and you are able to login to salus-it500.com and control it from this page, this custom component should work.

## Component to interface with the salus-it500.com.
It reads the Current Temperature, Set Temperature, Current HVAC Mode, Current Relay Mode.

Keep in mind this is my first custom component and this is also the first version of this Salusfy so it can have bugs. Sorry for that.

**** This is not an official integration.

### Installation
1. Clone the repo into the `home_assistant` directory
1. Change directory into the `salusfy` directory
1. Run install.sh (you may need to fix the line endings)
1. Configure with config below
1. Restart Home Assistant

### Usage
To use this component in your installation, add the following to your configuration.yaml file:

#### Example configuration.yaml entry

```
climate:
- platform: salusfy
username: "EMAIL"
password: "PASSWORD"
id: "DEVICE_ID"
```
![image](https://user-images.githubusercontent.com/33951255/140300295-4915a18f-f5d4-4957-b513-59d7736cc52a.png)
![image](https://user-images.githubusercontent.com/33951255/140303472-fd38b9e4-5c33-408f-afef-25547c39551c.png)


### Getting the DEVICE_ID
1. Loggin to https://salus-it500.com with email and password used in the mobile app (in my case RT301i)
2. Click on the device
3. In the next page you will be able to see the device ID in the page URL
4. Copy the device ID from the URL
![image](https://user-images.githubusercontent.com/33951255/140301260-151b6af9-dbc4-4e90-a14e-29018fe2e482.png)


### Separate Temperature Client
Due to how chatty Home Assistant integrations are, the salus-it500.com server may start blocking your public IP address. This will prevent the gateway and mobile client from connecting. To resolve this, you can use the `TemperatureClient` which:

* suppresses requests to Salus for reading the current temperature
* queries another Home Assistant entity for current temperature via the HA API

The effect of this is that the target temperature/mode values may be out of date **if they have been updated outside of HA**, but the main control features (target temperature, set mode etc) will still work.

To enable the `TemperatureClient`, set the following settings in `climate.yaml`:

```
climate:
- platform: salusfy
username: "EMAIL"
password: "PASSWORD"
id: "DEVICE_ID"
enable_temperature_client: True
host: "your-home-assistant-ip-address"
entity_id: "sensor.your-temperature-sensor"
access_token: "your-HA-access-token"
```

### Running Locally

You can exercise the integration locally using the `run.py` which calls the code on your local machine as if it was being run within Home Assistant. This can help debug any issues you may be having without waiting for multiple Home Assistant restarts.

To get going:

1. Copy `config.sample.py` to `config.py`
1. Replace the config (below) with the appropriate values for your installation
1. Run `python ./run.py`

Feel free to change the code to exercise different methods and configuration.

#### Example config.py

```
ENABLE_TEMPERATURE_CLIENT = True
HOST = "your-home-assistant-ip-address"
ENTITY_ID = "sensor.your-temperature-sensor"
ACCESS_TOKEN = "your-HA-access-token"
```
14 changes: 14 additions & 0 deletions config.sample.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# this file is used by the run.py test script
# it is not required by the custom component

# copy this file to config.py and replace the values

USERNAME = "replace"
PASSWORD = "replace"
DEVICE_ID = "replace"

SIMULATOR = False
ENABLE_TEMPERATURE_CLIENT = False
HOST = "your-home-assistant-ip-address"
ENTITY_ID = "sensor.your-temperature-sensor"
ACCESS_TOKEN = "your-HA-access-token"
1 change: 0 additions & 1 deletion custom_components/salusfy/__init__.py

This file was deleted.

Loading