Skip to content

Commit

Permalink
Remove matplotlib from dependencys.
Browse files Browse the repository at this point in the history
Make image generation optional.
  • Loading branch information
MadOne committed Jan 20, 2025
1 parent 0b4ce14 commit f20536d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
16 changes: 12 additions & 4 deletions custom_components/weishaupt_modbus/kennfeld.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import numpy as np
from numpy.polynomial import Chebyshev

import matplotlib.pyplot as plt

from .configentry import MyConfigEntry

Expand All @@ -25,12 +24,20 @@
)
SPLINE_AVAILABLE = False


if SPLINE_AVAILABLE is True:
log.info(
"Scipy available, use precise cubic spline interpolation for heating power"
)
from scipy.interpolate import CubicSpline # pylint: disable=E0401

MATPLOTLIB_AVAILABLE = True
try:
import matplotlib.pyplot as plt
except ModuleNotFoundError:
log.warning("Matplotlib not available. Can't create power map image file")
SPLINE_AVAILABLE = False


class PowerMap:
"""Power map class."""
Expand Down Expand Up @@ -172,9 +179,10 @@ async def initialize(self):
self._max_power.append(f(self._all_t))

try:
await self._config_entry.runtime_data.hass.async_add_executor_job(
self.plot_kennfeld_to_file
)
if MATPLOTLIB_AVAILABLE:
await self._config_entry.runtime_data.hass.async_add_executor_job(
self.plot_kennfeld_to_file
)
except RuntimeError:
log.warning("Reconfigure powermap")

Expand Down
17 changes: 12 additions & 5 deletions custom_components/weishaupt_modbus/manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
{
"domain": "weishaupt_modbus",
"name": "Weishaupt WBB",
"codeowners": ["@OStrama"],
"codeowners": [
"@OStrama"
],
"config_flow": true,
"documentation": "https://github.com/OStrama/weishaupt_modbus/",
"iot_class": "local_polling",
"issue_tracker": "https://github.com/OStrama/weishaupt_modbus/issues",
"loggers": ["weishaupt_modbus"],
"requirements": ["pymodbus>=3.6.8", "aiofiles>=24.1.0", "beautifulsoup4>=4.12.3", "matplotlib>=3.9.2"],
"loggers": [
"weishaupt_modbus"
],
"requirements": [
"pymodbus>=3.6.8",
"aiofiles>=24.1.0",
"beautifulsoup4>=4.12.3"
],
"version": "1.0.6"
}

}

0 comments on commit f20536d

Please sign in to comment.