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

Version 1.0 #14

Open
wants to merge 219 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
219 commits
Select commit Hold shift + click to select a range
e00e2b5
Update wp.py
OStrama Sep 15, 2024
3266664
Update README.md
OStrama Sep 15, 2024
6da4769
Update wp.py
OStrama Sep 15, 2024
082d12a
Update wp.py
OStrama Sep 15, 2024
8a156b0
Update sensor.py
OStrama Sep 15, 2024
efc46b7
Update sensor.py
OStrama Sep 15, 2024
fb95c74
Update sensor.py
OStrama Sep 15, 2024
1e197e1
Update number.py
OStrama Sep 15, 2024
dd14e9b
Update sensor.py
OStrama Sep 15, 2024
189cf42
Update select.py
OStrama Sep 15, 2024
e47874a
Update sensor.py
OStrama Sep 15, 2024
4740a88
Update wp.py
OStrama Sep 15, 2024
31e7646
Update select.py
OStrama Sep 15, 2024
eda4ad8
Update select.py
OStrama Sep 15, 2024
492331b
Update select.py
OStrama Sep 15, 2024
fd77e55
Update wp.py
OStrama Sep 15, 2024
5e04e8a
Update select.py
OStrama Sep 15, 2024
80a4de7
Update number.py
OStrama Sep 15, 2024
fcc1169
Update number.py
OStrama Sep 15, 2024
f98869a
Update number.py
OStrama Sep 15, 2024
ba8e103
Update number.py
OStrama Sep 15, 2024
70d6467
Update wp.py
OStrama Sep 15, 2024
b9715df
Update number.py
OStrama Sep 15, 2024
269d06b
Delete custom_components/weishaupt_modbus/wp.py
OStrama Sep 19, 2024
beba265
Update manifest.json
OStrama Sep 19, 2024
d888cf4
Add files via upload
OStrama Sep 19, 2024
16420dc
Update __init__.py
OStrama Sep 19, 2024
3a837b3
Update number.py
OStrama Sep 19, 2024
3ffb743
Update const.py
OStrama Sep 19, 2024
2be1096
Add files via upload
OStrama Sep 19, 2024
d3459b4
Update select.py
OStrama Sep 19, 2024
a3ad938
Update sensor.py
OStrama Sep 19, 2024
73da3d2
Update config_flow.py
OStrama Sep 19, 2024
0d22752
Update README.md
OStrama Sep 19, 2024
2d319a3
Update README.md
OStrama Sep 19, 2024
3b63d7d
Update README.md
OStrama Sep 19, 2024
07e2262
Update entities.py
OStrama Sep 19, 2024
7bb39af
Update items.py
OStrama Sep 19, 2024
4e211f1
Update modbusobject.py
OStrama Sep 19, 2024
4f7bb38
Update modbusobject.py
OStrama Sep 19, 2024
cbc6bd7
Update entities.py
OStrama Sep 19, 2024
6d7ab16
Update entities.py
OStrama Sep 19, 2024
23607e1
Update modbusobject.py
OStrama Sep 19, 2024
12119ea
Update entities.py
OStrama Sep 19, 2024
b708a5a
Update modbusobject.py
OStrama Sep 19, 2024
0c001a0
Update entities.py
OStrama Sep 19, 2024
5293e66
Update number.py
OStrama Sep 19, 2024
76e33ac
Update select.py
OStrama Sep 19, 2024
a77bdab
Update sensor.py
OStrama Sep 19, 2024
5653029
Update entities.py
OStrama Sep 19, 2024
ef1f4ff
Update modbusobject.py
OStrama Sep 19, 2024
51b439c
debugging
OStrama Sep 20, 2024
3476cf6
bugfixing
OStrama Sep 20, 2024
871ab13
bugfixing
OStrama Sep 20, 2024
7724293
Added water heater and 2 WEZ
OStrama Sep 21, 2024
3ec0bd6
bugfixing, added statistics
OStrama Sep 23, 2024
e015efa
bugfixing
OStrama Sep 23, 2024
ad5bf40
Update hpconst.py
OStrama Sep 23, 2024
2fd9a1d
Updated
OStrama Sep 24, 2024
3770f0d
Merge branch 'main' of https://github.com/OStrama/weishaupt_modbus
OStrama Sep 24, 2024
76da2dc
Update README.md
OStrama Sep 24, 2024
897c56a
Update README.md
OStrama Oct 10, 2024
07168c1
Delete custom_components/weishaupt_modbus/entities - Kopie.py
OStrama Oct 10, 2024
321c4c0
Delete custom_components/weishaupt_modbus/hpconst - Kopie.py
OStrama Oct 10, 2024
84ed863
Delete custom_components/weishaupt_modbus/items - Kopie.py
OStrama Oct 10, 2024
db926a6
Update issue templates
OStrama Oct 10, 2024
0f7ea4b
Added power map initialization test
OStrama Oct 10, 2024
cab14f1
Merge branch 'main' of https://github.com/OStrama/weishaupt_modbus
OStrama Oct 10, 2024
e158d57
power
OStrama Oct 11, 2024
4b1a6d6
debugging
OStrama Oct 11, 2024
a003ec1
debugging
OStrama Oct 11, 2024
28de563
removed scipy for testing, heat power will not be correct
OStrama Oct 11, 2024
8e8aa88
replaced cubic spline by Chebycheff polynom interpolation
OStrama Oct 11, 2024
8cc0ead
debug
OStrama Oct 11, 2024
206bd07
debug
OStrama Oct 11, 2024
a69fcae
Create dashboard.yaml
OStrama Oct 13, 2024
6382bc8
Bugfixig + Moving Kennfeld to jsom-file named weishaupt_wbb_kennfeld.…
OStrama Oct 17, 2024
0903d50
Merge branch 'main' of https://github.com/OStrama/weishaupt_modbus
OStrama Oct 17, 2024
d641f3d
Add files via upload
OStrama Oct 17, 2024
9d47f94
Update weishaupt_wbb_kennfeld.json
OStrama Oct 17, 2024
2dd8355
Update manifest.json
OStrama Oct 17, 2024
6294185
Update README.md
OStrama Oct 17, 2024
c99cb0e
bugfixing
OStrama Oct 17, 2024
8fd24f7
Merge branch 'main' of https://github.com/OStrama/weishaupt_modbus
OStrama Oct 17, 2024
1edb124
1st version in DevContainer
OStrama Oct 21, 2024
9a29e9a
better formatting
OStrama Oct 21, 2024
15a9ee9
better formatting
OStrama Oct 21, 2024
9f5d3c8
added async modbus handling according to https://github.com/MadOne/we…
OStrama Oct 21, 2024
ab0a83c
debugging async modbus
OStrama Oct 21, 2024
f7f8c18
Update manifest.json
OStrama Oct 21, 2024
ed61ce1
test with coordinated singe API poll according to https://developers.…
OStrama Oct 22, 2024
0332b89
git
OStrama Oct 22, 2024
92556c5
change domain to weishaupt_modbus,
MadOne Oct 23, 2024
f42d251
Update README.md
MadOne Oct 23, 2024
ad53a49
fix missing sensors
MadOne Oct 24, 2024
ccec94a
Fix some RUFF warnings.
MadOne Oct 24, 2024
cafc668
Fix some RUFF warnings
MadOne Oct 24, 2024
cdd6270
Fix some RUFF warnings
MadOne Oct 24, 2024
fb8962f
Fix warning.
MadOne Oct 24, 2024
e7eb5ca
some error handling
MadOne Oct 24, 2024
7c406d7
catch misterious disconnect fail.
MadOne Oct 24, 2024
3a2038b
sync
OStrama Oct 24, 2024
f49919f
merged
OStrama Oct 24, 2024
e49542a
Fix modbus_client.close() is not async
MadOne Oct 25, 2024
27f141a
Remove no unnecessary exception
MadOne Oct 25, 2024
3ac8d02
modbusclient.close() is sync
MadOne Oct 25, 2024
2f460de
enabled heating power again
OStrama Oct 25, 2024
0969f66
Update README.md
OStrama Oct 25, 2024
0bdb038
Update README.md
OStrama Oct 25, 2024
1a0df03
Fix some Modbus errors. Add modbus debuging.
MadOne Oct 25, 2024
2792000
Update entities.py
OStrama Oct 25, 2024
35e9ed2
First try on skipping invalid modbus addresses
MadOne Oct 26, 2024
0117585
Merge branch 'main' of github.com:OStrama/weishaupt_modbus
MadOne Oct 26, 2024
c018d30
Fix connection errors by removing connection close()
MadOne Oct 26, 2024
a4558b6
Fix update coordinator only update req. values
MadOne Oct 26, 2024
5f59ae1
Cleanup
MadOne Oct 26, 2024
51f7b1d
Improof error handling and warning messages
MadOne Oct 26, 2024
9188e1c
added availability check when building entity lists, based on the _is…
OStrama Oct 26, 2024
e546d90
Connection only opened once at startup
OStrama Oct 26, 2024
005f869
Connection only opened once
OStrama Oct 26, 2024
d03bb77
Connection only opened once
OStrama Oct 26, 2024
1e4053e
remove unnecessary connect
MadOne Oct 27, 2024
7bb5acf
Fix broken commit
MadOne Oct 27, 2024
9cc1870
Change WW-Push from number to select
MadOne Oct 27, 2024
7983cce
get value from modbusItem before check if valid
MadOne Oct 27, 2024
17cc3d1
bugfixing and adding HZ2
OStrama Oct 27, 2024
5700140
bugfixing
OStrama Oct 27, 2024
aa706fc
Remove not installed temp sensors
MadOne Oct 27, 2024
114d8e2
add kennfeld mapping for WSB 8
GrimmiMeloni Oct 27, 2024
4cdda90
Merge branch 'main' of github.com:OStrama/weishaupt_modbus
MadOne Oct 27, 2024
e4b8c7b
Fix removal of not installed sensors
MadOne Oct 27, 2024
aa7e62b
Merge pull request #17 from GrimmiMeloni/wsb8
MadOne Oct 27, 2024
09864f7
try to sync
OStrama Oct 27, 2024
62e23a1
sync
OStrama Oct 27, 2024
729f182
debug percentage not available
OStrama Oct 27, 2024
25bb43d
check and debugging of connection lost
OStrama Oct 27, 2024
fca0cfc
reformatting modbus items
OStrama Oct 27, 2024
323edf1
remove pylint warnings
OStrama Oct 27, 2024
9d7f79d
small script check for responding modbus addresses
MadOne Oct 28, 2024
d36745c
Merge branch 'main' of github.com:OStrama/weishaupt_modbus
MadOne Oct 28, 2024
71c983a
Added configuration entries for Prefix, Device-Postfix and Map file
OStrama Oct 28, 2024
b7c2111
Update README.md
OStrama Oct 28, 2024
7af9874
register list pulled from hp compared to doku
MadOne Oct 28, 2024
85096b0
Merge branch 'main' of github.com:OStrama/weishaupt_modbus
MadOne Oct 28, 2024
f3cfb46
Update entities.py
OStrama Oct 28, 2024
c337394
Update entities.py
OStrama Oct 28, 2024
66b6edd
debug
OStrama Oct 28, 2024
3d732d0
debug
OStrama Oct 28, 2024
5ae3ede
debugging
OStrama Oct 28, 2024
2d203fd
updated test
OStrama Oct 28, 2024
3214e61
update
OStrama Oct 28, 2024
e65e987
Update auswertung_register.csv
MadOne Oct 29, 2024
3d75358
Added migration of config entry
OStrama Oct 29, 2024
b4fd4e2
Added unknown sensor addresses in device "unknown"
OStrama Oct 29, 2024
d93c5e8
added setup options for Heizkreise + error messages + new known senso…
OStrama Oct 30, 2024
6bf5a8b
try to add caption to setup process.
MadOne Oct 30, 2024
59ddfab
Merge branch 'main' of github.com:OStrama/weishaupt_modbus
MadOne Oct 30, 2024
cf1a0a8
async file IO added
OStrama Oct 30, 2024
6cb2120
captions debugged
OStrama Oct 30, 2024
a841a6d
added German
OStrama Oct 30, 2024
f5531aa
Update strings.json (hassfest)
OStrama Oct 30, 2024
748576b
Update de.json (hassfest)
OStrama Oct 30, 2024
a8e3e77
Update en.json (hassfest)
OStrama Oct 30, 2024
889343f
Update __init__.py added default config update
OStrama Oct 30, 2024
782d32b
Update config_flow.py
OStrama Oct 30, 2024
70dff33
Update __init__.py
OStrama Oct 30, 2024
c5a72cf
Update __init__.py
OStrama Oct 30, 2024
e2a8a98
Update README.md with disclaimer
OStrama Oct 30, 2024
0227634
Update README.md added disclaimer
OStrama Oct 30, 2024
f796935
beautifying
OStrama Oct 30, 2024
7077704
cleaned up a bit..
OStrama Oct 31, 2024
4ca7066
debugging
OStrama Oct 31, 2024
600ade1
Update hpconst.py changed names to sollwert
OStrama Oct 31, 2024
a98a516
playing around with cubic splines
MadOne Oct 31, 2024
5785cf1
Merge branch 'main' of github.com:OStrama/weishaupt_modbus
MadOne Oct 31, 2024
98a44b7
Add heatpump IO
MadOne Nov 1, 2024
0908bfa
Add IO configuration, first step
MadOne Nov 1, 2024
09cc627
progress on IO
MadOne Nov 1, 2024
7619e8a
furthre progress on IO
MadOne Nov 1, 2024
24f17d8
Fix Inputs
MadOne Nov 1, 2024
190f9cb
pin requirements version
MadOne Nov 2, 2024
6f1c4b4
Add possibility to prefix entity names
MadOne Nov 3, 2024
8f0dba2
Temperature calculation updated
OStrama Nov 5, 2024
c3a4002
beautifying
OStrama Nov 6, 2024
d796bb7
requirements >=
OStrama Nov 6, 2024
7690d63
allow edit of config entry
MadOne Nov 6, 2024
08a85f0
load values when edititng config entry
MadOne Nov 6, 2024
b2d270c
test reconfigure and config entry update debugging
OStrama Nov 7, 2024
be6f692
bugfixing
OStrama Nov 7, 2024
faf36c2
Add register info according to gh discussion:
MadOne Nov 9, 2024
5134881
Merge branch 'main' of github.com:OStrama/weishaupt_modbus
MadOne Nov 9, 2024
2f86b57
Switch Sollwert Pumpe Leistung Kühlen back to RO
MadOne Nov 9, 2024
ac7e42f
Update README.md
MadOne Nov 9, 2024
74e3e55
fix misspelling
MadOne Nov 10, 2024
43c4b03
Merge branch 'main' of github.com:OStrama/weishaupt_modbus
MadOne Nov 10, 2024
0b7f029
fix: typo in warmwassertemperatur sensor
dhoeld Nov 10, 2024
29a022b
Merge pull request #27 from dhoeld/patch-1
MadOne Nov 10, 2024
dd570ea
disable sensors with 32768
OStrama Nov 11, 2024
ce5d8c7
Update README.md
OStrama Nov 11, 2024
627a4e3
Update README.md
OStrama Nov 11, 2024
c54d5af
Update README.md
OStrama Nov 11, 2024
a12091c
Update README.md
OStrama Nov 12, 2024
8b2364e
Add Kennfeld file for WSB6 model
martinth Nov 13, 2024
8db280e
Merge pull request #31 from martinth/main
OStrama Nov 13, 2024
8243a24
Create weishaupt_wbb12_kennfeld.json
OStrama Nov 13, 2024
a469ef8
Add Kennfeld for WWP LS 8
Oranskij Nov 13, 2024
e6090b4
Merge pull request #32 from Oranskij/main
OStrama Nov 14, 2024
b7b9f42
Update hpconst.py
OStrama Nov 14, 2024
89fa742
add debug logging
OStrama Nov 15, 2024
a2b8ec2
add debug logging
OStrama Nov 15, 2024
71fccfb
add debug logging
OStrama Nov 15, 2024
f5d2b83
add debug logging
OStrama Nov 15, 2024
3352ffd
Update sensor.py
OStrama Nov 15, 2024
813c020
Create weishaupt_wbb20_kennfeld.json
OStrama Nov 16, 2024
af95adc
Debugging: Luftansaugtemp not available + Whitespace in WW Push
OStrama Nov 16, 2024
6c25835
changed unit of "Steigung" to unitless
OStrama Nov 16, 2024
73f7349
hassfest complain
OStrama Nov 16, 2024
de9e2ff
debug manifest
OStrama Nov 16, 2024
b94159d
Merge branch 'main' into Version-1.0
OStrama Nov 16, 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
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 MadOne
Copyright (c) 2024 OStrama

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
75 changes: 65 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,46 @@
This is the successor of the integration from MadOne.
MadOne and OStrama are working together on this version.

# With version 1.0.0 we consolidate both versions.
# In this version this will have the following impact:
(For updates from 1.0.0 to newer versions, this procedure is not longer needed.)

## For users of MadOne's original weishaupt_modbus integration:
* Remove the Heatpump configuration.
* In HACS remove the integration completely
* Restart Home Assistant
* Add this Repository to HACS as descriped in Installation
* When doing nothing than simply installing the integration, the long term statistics will be split into new entities,
since the sensor domain is different.
* To avoid this, change the default prefix entry in the configuration dialog from
weishaupt_wbb
to
weishaupt_modbus


## For users of OStrama's weishaupt_wbb integration:
* Uninstall existing "weishaupt_wbb" installation, answer "integration and all entities of it will be deleted" with"yes"
* Restart home assistant
* Install new weishaupt_wbb integration
* You will get a new integration with the same name
* the sensor entities will be the same than before

All modbus parameters of this integration are concentrated in the file hpconst.py as a set of object lists.
This allows generic setup of all entities and a more easy completion of messages and entity behavior

# Weishaupt_modbus

This integration lets you monitor and controll your weishaupt heatpump through modbus.
This integration lets you monitor and control your weishaupt heatpump through modbus.
This is how it might look:
![Bildschirmfoto vom 2024-07-31 21-41-56](https://github.com/user-attachments/assets/3fde9b18-f9ea-4e75-94ee-25ef6f799dcf)
![image](https://github.com/user-attachments/assets/00e7b8fa-1779-428d-9361-7c66e228c2c6)

## Installation

### Install through HACS

- Not working yet

### HACS (manually add Repository)

Add this repository to HACS.
* In the HACS GUI, select "Custom repositories"
* Enter the following repository URL: https://github.com/MadOne/weishaupt_modbus/releases
* Enter the following repository URL: https://github.com/OStrama/weishaupt_modbus/releases
* Category: Integration
* After adding the integration, restart Home Assistant.
* Now under Configuration -> Integrations, "Weishaupt Modbus Integration" should be available.
Expand All @@ -38,11 +64,40 @@ custom_components
```
## Configuration

![Bildschirmfoto vom 2024-07-31 21-46-18](https://github.com/user-attachments/assets/45ad403e-c721-40bd-b723-95fe05fca5c5)
![image](https://github.com/user-attachments/assets/8549938f-a059-4a92-988c-ba329f3cd758)

The only mandatory parameter is the IP-Address of your heatpump. The port should be ok at default unless you changed it in the Heatpump configuration.

The "prefix" should only be changed when migrating from MadOnes original integration to this one to avoid splitting of sensor history

The "Device Postfix" has a default value of "". It can be used to add multiple heat pumps to one home assistant. For compatibility this should be left empty. If you want to add another heat pump, use a name that help to identify the devices.

### The power mapping file
The "Kennfeld-File" can be choosen to read in the right power mapping according to your type of heat pump:

The heat power "Wärmeleistung" is calculated from the "Leistungsanforderung" in dependency of outside temperature and water temperature.
This is type specific. The data stored in the integration fit to a WBB 12. If the file you've parameterized does not exist, the integration will create a file that fits for a WBB12. If you have another heat pump please update the Kennfeld-File file according to the graphs found in the documentation of your heat pump and change the name of the used file by reconfiguring the integration and change only the file name. It may be necessary to restart home assistant after changing the filename.
When no file is available, a new file with the defined name will be created that contains the parameters read out from the graphs found in the documentation of WBB 12 in a manual way. Thsi file can be used as a template for another typer of heatpump.
(Note: It would be great if you could provide files from other types of heatpumps to us, so that we can integrate them in further versions ;-))

Just enter the IP of your Weishaupt heatpump. Port should be ok at default unless you changed it in the Heatpump configuration.

You have to enable modbus in your heatpump settings.

## Setting up the HeatPump

In order to use this integration you have to enable modbus in your heatpump.
Go to:
User -> Settings (second Page) -> Modbus TCP

**Parameter: On**

**Network**: Here you have 2 options. Either you place the IP of your HomeAssistent to exclusively allow this ip to connect to the heatpump via ModBus or you place your network to allow all the IPs in that range.
For example: **192.168.178.123** (Home Assistant IP) or 192.168.178.0 for all ips between 192.168.178.1 and 192.167.178.254.
Option 1 is the savest but Option 2 enables you to connect to the heatpump from multiple devices(developing machine, or maybe my possibly upcomming dedicated android app?). I suggest to go for option 1 (HomeAssistant IP).

**Netmask**: Select the netmask of your network. This will be **255.255.255.000** for you otherwise you would know the correct one ;)

# Disclaimer
The developers of this integration are not affiliated with Weishaupt. They have created the integration as open source in their spare time on the basis of publicly accessible information.
The use of the integration is at the user's own risk and responsibility. The developers are not liable for any damages arising from the use of the integration.

ToDo: Pictures and explanation of how to enable modbus
68 changes: 62 additions & 6 deletions custom_components/weishaupt_modbus/__init__.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,95 @@
"""Weishaupt Modbus Integration."""
"""init."""

import warnings

from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.const import CONF_PREFIX

from .const import DOMAIN
from .const import (
CONST,
CONF_DEVICE_POSTFIX,
CONF_KENNFELD_FILE,
CONF_HK2,
CONF_HK3,
CONF_HK4,
CONF_HK5,
CONF_NAME_DEVICE_PREFIX,
CONF_NAME_TOPIC_PREFIX,
)
from .modbusobject import ModbusAPI

PLATFORMS: list[str] = [
"number",
"select",
"sensor",
"switch",
# "switch",
]


# Return boolean to indicate that initialization was successful.
# return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Hello World from a config entry."""
"""Set up entry."""
# Store an instance of the "connecting" class that does the work of speaking
# with your actual devices.
# hass.data.setdefault(DOMAIN, {})[entry.entry_id] = hub.Hub(hass, entry.data["host"])
mbapi = ModbusAPI(entry)
await mbapi.connect()
entry.runtime_data = mbapi

# This creates each HA object for each platform your device requires.
# It's done by calling the `async_setup_entry` function in each platform module.
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
return True


async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry):
"""Migrate old entry."""
if config_entry.version > 3:
# This means the user has downgraded from a future version
return False

# to ensure all update paths we have to check every version to not overwrite existing entries
if config_entry.version < 4:
warnings.warn("Old Version detected")
new_data = {**config_entry.data}

if config_entry.version < 2:
warnings.warn("Version <2 detected")
new_data[CONF_PREFIX] = CONST.DEF_PREFIX
new_data[CONF_DEVICE_POSTFIX] = ""
new_data[CONF_KENNFELD_FILE] = CONST.DEF_KENNFELDFILE
if config_entry.version < 3:
warnings.warn("Version <3 detected")
new_data[CONF_HK2] = False
new_data[CONF_HK3] = False
new_data[CONF_HK4] = False
new_data[CONF_HK5] = False
if config_entry.version < 4:
warnings.warn("Version <4 detected")
new_data[CONF_NAME_DEVICE_PREFIX] = False
new_data[CONF_NAME_TOPIC_PREFIX] = False

hass.config_entries.async_update_entry(
config_entry, data=new_data, minor_version=1, version=4
)
warnings.warn("Config entries updated to version 4")

return True


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
"""Unload entry."""
# This is called when an entry/configured device is to be removed. The class
# needs to unload itself, and remove callbacks. See the classes for further
# details
entry.runtime_data.close()
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unload_ok:
hass.data[DOMAIN].pop(entry.entry_id)
try:
hass.data[CONST.DOMAIN].pop(entry.entry_id)
except KeyError:
warnings.warn("KeyError: " + str(CONST.DOMAIN))

return unload_ok
Loading