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

MQTT active HASS not starting #47

Open
Webserve opened this issue Oct 20, 2018 · 7 comments
Open

MQTT active HASS not starting #47

Webserve opened this issue Oct 20, 2018 · 7 comments

Comments

@Webserve
Copy link

Hi,

Last week i upgraded to the newest hass version 0.80.2
Now when starting hass the frontpage isnt loading anymore. In the log i cant find any error.

The solution for now is:

  1. use the old bwalarm.py (arm and disarm isn't working)
  2. Disable mqtt

so the problem is mqtt when i set "mqtt: false" everything working fine. (except mqtt)

in 0.80 there are some changes with mqtt and alarm_panel

Remove discovered MQTT alarm_control_panel device when discovery topic is cleared (@emontnemery - #16825) (alarm_control_panel.mqtt docs)
Remove discovered MQTT light device when discovery topic is cleared (@emontnemery - #16824) (light.mqtt docs)

Can you help me to solve this problem.

@emontnemery
Copy link

I also had issues with the frontpage recently, have you tried in incognito mode to make sure it's not just stale files in the browser cache?

@Webserve
Copy link
Author

I had the same feeling so i deleted the cache and tried another browser. The online solution is disable mqtt

@djmcp
Copy link

djmcp commented Oct 20, 2018

I too am having issues arming/disarming via MQTT on HASS 0.80.2. It simply doesn't arm or disarm. I've taken the latest version of bwalarm. I am trying to arm/disarm via MQTT and the Android MQTT Alarm Panel app. Have tested with a manual mqtt publish to the alarm/set topic. I see this error in HASS:

Error doing job: Exception in callback <bound method MQTT._mqtt_handle_message of <homeassistant.components.mqtt.MQTT object at 0x7ff30c2b1390>>
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 66, in uvloop.loop.Handle._run
  File "/usr/src/app/homeassistant/components/mqtt/__init__.py", line 749, in _mqtt_handle_message
    subscription.callback, msg.topic, payload, msg.qos)
  File "/usr/src/app/homeassistant/core.py", line 327, in async_run_job
    target(*args)
  File "/config/custom_components/alarm_control_panel/bwalarm.py", line 662, in message_received
    self.alarm_disarm(self._code)
  File "/config/custom_components/alarm_control_panel/bwalarm.py", line 472, in alarm_disarm
    self.process_event(Events.Disarm)
  File "/config/custom_components/alarm_control_panel/bwalarm.py", line 597, in process_event
    self._hass.services.call("switch", "turn_off", {self._warning})
  File "/usr/src/app/homeassistant/core.py", line 1070, in call
    self._hass.loop
  File "/usr/src/app/homeassistant/util/async_.py", line 138, in run_coroutine_threadsafe
    raise RuntimeError('Cannot be called from within the event loop')
RuntimeError: Cannot be called from within the event loop

However, when arming/disarming the alarm via the by bwalarm front-end - i.e. the Alarm page - everything works and it does publish MQTT to the alarm topic - e.g. 'Pending', 'Armed_Home', etc.

@Webserve
Copy link
Author

Webserve commented Oct 27, 2018

elif new_state == STATE_ALARM_PENDING: _LOGGER.debug("[ALARM] Pending user leaving house") #self._hass.services.call("switch", "turn_on", {self._warning}) self._timeoutat = now() + datetime.timedelta(seconds=self._pending_time_by_state[self._armstate]) #self._returnto = STATE_ALARM_ARMED_AWAY

Disabled the self._hass.services.call("switch", "turn_on", {self._warning})

Everything is working now.

@e2m32
Copy link

e2m32 commented Nov 2, 2018

elif new_state == STATE_ALARM_PENDING

Thanks @Webserve! Not sure what that line of code was for, but commenting it out seems to have worked for me. I just tested it and I didn't notice anything broken. Alarm warning still works when triggered from an Armed state. Arming and Disarming is working from the custom Alarm Panel, from HA, and from my MQTT alarm panel.

For those trying to do this, you can search for @Webserve's code in the bwalarm.py file (custom_components\alarm_control_panel) and comment out the line, or if your in bwalarm.py version 1.0.4 (current version at time of post) and you haven't modified anything, its line# 577:

if old_state != new_state: 
    _LOGGER.debug("[ALARM] Alarm changing from {} to {}".format(old_state, new_state))
    # Things to do on entering state
    if new_state == STATE_ALARM_WARNING:
        _LOGGER.debug("[ALARM] Turning on warning")
        self._hass.services.call("switch", "turn_on", {self._warning})
        self._timeoutat = now() +  datetime.timedelta(seconds=self._pending_time_by_state[self._armstate])
    elif new_state == STATE_ALARM_TRIGGERED:
        _LOGGER.debug("[ALARM] Turning on alarm")
        self._hass.services.call("switch", "turn_on", {self._alarm})
        self._timeoutat = now() + datetime.timedelta(seconds=self._trigger_time_by_state[self._armstate])
    elif new_state == STATE_ALARM_PENDING:
        _LOGGER.debug("[ALARM] Pending user leaving house")
577>    #self._hass.services.call("switch", "turn_on", {self._warning})  **#comment this line out - line 577**

@adipose
Copy link

adipose commented Nov 14, 2018

See #52

This fixed the issues for me, including MQTT not working, and HA not starting up (which was due to getting stuck on an existing MQTT message).

@e2m32
Copy link

e2m32 commented Nov 19, 2018

See #52

This fixed the issues for me, including MQTT not working, and HA not starting up (which was due to getting stuck on an existing MQTT message).

thank you adipose. I've implemented your fix and it's been running well for 4 days on HA v 0.82.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants