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

HASS MQTT Cat Flap is not controllable, changing the switch results in frontend.py Error #24

Open
Pr0mises opened this issue Mar 28, 2023 · 1 comment · May be fixed by #25
Open

HASS MQTT Cat Flap is not controllable, changing the switch results in frontend.py Error #24

Pr0mises opened this issue Mar 28, 2023 · 1 comment · May be fixed by #25

Comments

@Pr0mises
Copy link

Pr0mises commented Mar 28, 2023

Firstly, awesome project and beautiful documentation. I didn't even need to change my Firmware as my Hub is using 2.43 (thankfully, I disabled the force updates on it).

Background information about my system:
RaspberryPi 4:

  • eclipse MQTT broker as docker container
  • HASS as docker
  • PHL as docker

Setup run fine and my HUB + Cat Flap got published into MQTT in HASS just fine as well.

In my cat flap I've 3 options as switches Curfew KeepInand KeepOut. All three aren't enabled yet by default.
I tried to hit any of those switches and got this error in PHL:

2023-03-28 01:13:52,992 : [ERROR] : Task exception was never retrieved
future: <Task finished name='Task-2' coro=<mqtt_start() done, defined at /usr/local/lib/python3.9/site-packages/pethublocal/frontend.py:204> exception=TypeError("emit() got an unexpected keyword argument 'broadcast'")>
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/pethublocal/frontend.py", line 295, in mqtt_start
    await asyncio.gather(*tasks)
  File "/usr/local/lib/python3.9/site-packages/pethublocal/frontend.py", line 345, in parse_message
    await sio.emit('web_message', data=parsed_result, broadcast=True, include_self=False)
TypeError: emit() got an unexpected keyword argument 'broadcast'

Start up logs:

2023-03-28 01:01:51,766 : [ INFO] : Start Pet Hub Local - Always blow on the pie, safer communities together
2023-03-28 01:01:51,768 : [ INFO] : Serve: Starting Server
2023-03-28 01:01:51,769 : [ INFO] : Loading Config file pethubconfig.json
2023-03-28 01:01:51,776 : [ INFO] : Starting HTTP Server
2023-03-28 01:01:51,777 : [DEBUG] : Using selector: EpollSelector
2023-03-28 01:01:51,780 : [ INFO] : MQTT: Init MQTT Host <IP>
2023-03-28 01:01:51,784 : [ INFO] : Starting HTTPS Server
2023-03-28 01:01:51,796 : [DEBUG] : Watchdog timer was reset
2023-03-28 01:01:51,797 : [DEBUG] : Watchdog status - Last Hub message was 0 seconds (0 minutes) ago
2023-03-28 01:01:51,801 : [DEBUG] : HAInit - Last Init Time: 1679964001
2023-03-28 01:01:51,801 : [ INFO] : MQTT: Initialise Home Assistant entities
2023-03-28 01:01:51,808 : [ INFO] : MQTT: Topic filter: pethub/hub/+/messages/+
2023-03-28 01:01:51,809 : [ INFO] : MQTT: Topic filter: pethub/hub/+/messages
2023-03-28 01:01:51,812 : [ INFO] : MQTT: Topic filter: pethub/ha/+/KeepIn
2023-03-28 01:01:51,813 : [ INFO] : MQTT: Topic filter: pethub/ha/+/KeepOut
2023-03-28 01:01:51,814 : [ INFO] : MQTT: Topic filter: pethub/ha/+/Curfew
2023-03-28 01:01:51,815 : [ INFO] : MQTT: Topic filter: v2/production/+/messages/+
2023-03-28 01:01:51,817 : [ INFO] : MQTT: Topic filter: v2/production/+/messages
2023-03-28 01:01:51,825 : [ INFO] : Client: Start
2023-03-28 01:01:51,839 : [ INFO] : 127.0.0.1 "GET /socket.io/?transport=polling&EIO=4&t=1679965311.8276188 HTTP/1.1" 200 288 "-" "Python/3.9 aiohttp/3.8.4"
2023-03-28 01:01:51,862 : [ INFO] : SIO: Connect <SIO>
2023-03-28 01:01:51,868 : [ INFO] : Client: Connected
2023-03-28 01:01:51,872 : [ INFO] : Client: SID <SID>

After pressing any Switch:

2023-03-28 01:13:49,956 : [ INFO] : MQTT: HA Message topic "pethub/ha/<Serial_Number> /Curfew" message "ON" 
2023-03-28 01:13:49,957 : [DEBUG] : Generate Message Hub:<Serial_Number> Product:3, Operation:CURFEWS
2023-03-28 01:13:49,966 : [DEBUG] : Updating Curfews
2023-03-28 01:13:49,973 : [ INFO] : ToHub: Moving from current lock mode UNLOCKED to lock mode CURFEW
2023-03-28 01:13:49,975 : [DEBUG] : Generate Message Hub<Serial_Number> Product:3, Operation:CURFEW
2023-03-28 01:13:52,992 : [ERROR] : Task exception was never retrieved
future: <Task finished name='Task-2' coro=<mqtt_start() done, defined at /usr/local/lib/python3.9/site-packages/pethublocal/frontend.py:204> exception=TypeError("emit() got an unexpected keyword argument 'broadcast'")>
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/pethublocal/frontend.py", line 295, in mqtt_start
    await asyncio.gather(*tasks)
  File "/usr/local/lib/python3.9/site-packages/pethublocal/frontend.py", line 345, in parse_message
    await sio.emit('web_message', data=parsed_result, broadcast=True, include_self=False)
TypeError: emit() got an unexpected keyword argument 'broadcast'
2023-03-28 01:14:01,975 : [ERROR] : packet queue is empty, aborting
2023-03-28 01:14:16,976 : [ INFO] : SIO: Disconnect <SIO>

I cleaned the log.
In the MQTT logs I get this:

1679968001: New connection from <IP>:54926 on port 1883.
1679968001: New client connected from <IP>:54926 as PetHubLocal (<cleared, not sure if needed>).

I'm kinda lost, and I've no clue where to debug, as it seems to work for you guys.
Maybe someone can help me with that or at least point me in a direction if it's my MQTT Broker or PHL.

Thank you

@Pr0mises Pr0mises changed the title HASS MQTT Cat Flap is not controllable, chaning the switch results in frontend.py Error HASS MQTT Cat Flap is not controllable, changing the switch results in frontend.py Error Apr 2, 2023
@Pr0mises
Copy link
Author

Pr0mises commented Apr 4, 2023

I did some more testing and it turned out that
await sio.emit('web_message', data=parsed_result, broadcast=True, include_self=False) (frontend.py#L345)

needs to be replaced to

await sio.emit('web_message', data=parsed_result)

now everything is working as expected

cacula added a commit to cacula/pethublocal that referenced this issue May 8, 2023
@cacula cacula linked a pull request May 8, 2023 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant