akasma74 / Hass-Custom-Alarm

It is a fork of "Yet another take on a home assistant custom alarm" that will exist until its author is back to our Earth
80 stars 31 forks source link

MQTT integration failure #1

Closed LouPaloma closed 5 years ago

LouPaloma commented 5 years ago

Describe the bug Enabling MQTT causes the alarm not to load and a log entry of "Signature of MQTT msg_callback 'custom_components.bwalarm.alarm_control_panel.message_received' is deprecated"

To Reproduce Steps to reproduce the behavior:

  1. Start with working custom alarm with MQTT off
  2. Enable MQTT
  3. Restart HA
  4. See error

Expected behavior MQTT integration should work. Alarm module should work

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

Browser (please complete the following information):

Additional context Home Assistant 0.92.1

akasma74 commented 5 years ago

Could you provide your config details?

My config: Home Assistant: v0.92.1 This Panel: v1.3.6_ak74 Component (Bwalarm): v1.1.4_ak74 Python: v(3,7,3,final,0)

No issues with or without MQTT.

LouPaloma commented 5 years ago

Home Assistant: v0.92.1 This Panel: v1.3.6_ak74 Component (Bwalarm): v1.1.4_ak74 Python: v(3,5,6,final,0)

No issues without MQTT

LouPaloma commented 5 years ago

Don't think this is a configuration issue. I think HA has deprecated the MQTT message approach. Looking at the code for the standard alarm component there are relevant changes there. See: HA PR #21959.

I'd fork your repo and test the code change myself, but my day job prevents me from getting to this before the weekend...

akasma74 commented 5 years ago

You're more than welcome to test it yourself. I checked 0.92.1 breaking changes and there's nothing about MQTT (but following your link I can see it's already there from 0.90.. hmm..). However, I updated my HA to 0.92.1 and cannot reproduce the issue.

Anyway, I've just uploaded a new version of alarm_control_panel.py, could you check it out? Mine works fine, I was able to arm my alarm via MQTT.

LouPaloma commented 5 years ago

So I've upgraded to HA 0.92.2 and to your latest version (v1.1.5_ak74 per source code, but UI still shows 1.1.4_ak74), but the integration still doesn't work. I am seeing a different error on the logs now, though:

2019-05-05 10:22:34 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/lib64/python3.5/asyncio/tasks.py", line 240, in _step result = coro.send(None) File "/usr/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 363, in _async_add_entity await entity.async_added_to_hass() File "/usr/lib64/python3.5/asyncio/coroutines.py", line 223, in coro res = yield from await_meth() File "/usr/lib/python3.5/site-packages/homeassistant/components/mqtt/__init__.py", line 375, in async_subscribe async_remove = await hass.data[DATA_MQTT].async_subscribe( KeyError: 'mqtt'

ame9895 commented 5 years ago

I was having this same problem with the same versions as you, @LouPaloma. In troubleshooting something completely unrelated, I removed the “deps” directory from /config and restarted HA. This fixed the MQTT problem above. Worth a shot.

akasma74 commented 5 years ago

Huh.. my /config/deps is completely empty anyway, wonder if anyone of you guys had something in there..

LouPaloma commented 5 years ago

The deps directory is populated by HA upon startup. Mine was full of files. Deleting them only delayed HA startup until it could reinstall them. The issue remained.

However, I've set up a new conda environment using Python 3.7.3. Running HA under that version seems to resolve the issue. Still testing, though...

akasma74 commented 5 years ago

Any news on that?

LouPaloma commented 5 years ago

Been a week of running fine. I'd say close the ticket. Thanks.

rrbarrero commented 4 years ago

Hello! Can you help with this. I think its the same problem but not fixed changing Python version:

HA version | 0.103.2 Alarm Panel: v1.11.1 This integration: v1.11.1 Tryed with Python: 3.7.1, 3.7.4 and 3.8.1. No issues without MQTT

Traceback (most recent call last):
  File "/srv/homeassistant-3.8.1/lib/python3.8/site-packages/homeassistant/helpers/entity_platform.py", line 406, in _async_add_entity
    await entity.async_added_to_hass()
  File "/usr/local/lib/python3.8/asyncio/coroutines.py", line 136, in coro
    res = yield from await_meth()
  File "/srv/homeassistant-3.8.1/lib/python3.8/site-packages/homeassistant/components/mqtt/__init__.py", line 433, in async_subscribe
    async_remove = await hass.data[DATA_MQTT].async_subscribe(
KeyError: 'mqtt'

Error message its the same with all version (3.7.1, 3.7.4 and 3.8.1).

and my config of mqtt:

mqtt:
  enable_mqtt: true
  payload_arm_night: ARM_NIGHT
  override_code: true
  command_topic: home/alarm/set
  qos: '0'
  payload_arm_home: ARM_HOME
  payload_disarm: DISARM
  payload_arm_away: ARM_AWAY
  pending_on_warning: false
  state_topic: home/alarm

Without mqtt works fine.

akasma74 commented 4 years ago

could you please open a new issue as this one is closed?

rrbarrero commented 4 years ago

Sure, thank you.