Skip to content

Commit

Permalink
Merge pull request #149 from xNUTx/updatefix
Browse files Browse the repository at this point in the history
Fix: Unexpected string in integer variable due to mqtt not being ready at startup.
  • Loading branch information
fvanroie authored Sep 6, 2024
2 parents 906749d + d2c9afd commit 48a2671
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion custom_components/openhasp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import re

from homeassistant.components.mqtt import async_subscribe, async_publish
import homeassistant.components.mqtt as mqtt
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN
from homeassistant.components.light import DOMAIN as LIGHT_DOMAIN
Expand Down Expand Up @@ -164,6 +165,9 @@ def hasp_object(value):


async def async_setup(hass, config):
"""Wait for MQTT to become available before starting."""
await mqtt.async_wait_for_mqtt_client(hass)

"""Set up the MQTT async example component."""
conf = config.get(DOMAIN)

Expand Down Expand Up @@ -556,7 +560,7 @@ async def async_change_page(self, page):
if self._statusupdate:
num_pages = self._statusupdate[HASP_NUM_PAGES]

if isinstance(page, int) and (page <= 0 or page > num_pages):
if isinstance(page, int) and isinstance(num_pages, int) and (page <= 0 or page > num_pages):
_LOGGER.error(
"Can't change to %s, available pages are 1 to %s", page, num_pages
)
Expand Down

0 comments on commit 48a2671

Please sign in to comment.