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

Switchbot-mqtt not sending various data? #127

Open
DutchessNicole opened this issue Dec 8, 2022 · 3 comments
Open

Switchbot-mqtt not sending various data? #127

DutchessNicole opened this issue Dec 8, 2022 · 3 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@DutchessNicole
Copy link

Hi! I'm not quite sure whether I should file this here or with PySwitchbot but I'll start here I guess.

I have switchbot-mqtt 3.3.1 running on a raspberry pi. The MQTT part works fine and I get events sent which I process in HA, however a few things don't seem to work, of which one is documented and doesn't work, and the others aren't documented at all and might not be implemented.

The device I'm having trouble with is a Switchbot Curtain, for clarity.

  1. I run switchbot-mqtt as a systemd service using the following command:
  ExecStart=/path/to/switchbot-mqtt --mqtt-host <mqtt_host> --mqtt-disable-tls --mqtt-username <username> --mqtt-password <password> --fetch-device-info

This works and the log gives feedback on the lines of

Dec 07 19:30:00 ble-relay switchbot-mqtt[1209]: Successfully sent command to Switchbot (MAC: dc:7e:60:4a:f7:f3)
Dec 07 19:30:00 ble-relay switchbot-mqtt[1209]: switchbot curtain dc:7e:60:4a:f7:f3 opening
Dec 07 19:30:09 ble-relay switchbot-mqtt[1209]: Successfully sent command to Switchbot (MAC: dc:7e:60:4a:f7:f3)
Dec 07 19:30:09 ble-relay switchbot-mqtt[1209]: switchbot curtain dc:7e:60:4a:f7:f3 closing
Dec 08 06:23:51 ble-relay switchbot-mqtt[1209]: Successfully sent command to Switchbot (MAC: dc:7e:60:4a:f7:f3)
Dec 08 06:23:51 ble-relay switchbot-mqtt[1209]: switchbot curtain dc:7e:60:4a:f7:f3 opening

So that's all good.

According to the readme, the --fetch-device-info option should enable sending of position and battery data when an action is finished.
I do get the battery data sent on the homeassistant/cover/switchbot-curtain/MAC_ADDRESS/battery-percentage topic, but the position is never sent.
homeassistant/cover/switchbot-curtain/MAC_ADDRESS/position stays empty

  1. The switchbot sends the state opening and closing after you send an OPEN or CLOSE command. However, I never get the event for opened or closed, which should appear after the action has stopped. The reason I know the device is done is because the battery percentage does update. Are these events simply not passed on or do you not get these at all to pass through to mqtt?

  2. The Curtain device has a light sensor built in, I would love to have the information about that in the mqtt data as well. Is this possible? Or is that something that PySwitchbot hasn't done yet?

Thanks!

@fphammerle fphammerle added the question Further information is requested label Dec 13, 2022
@fphammerle
Copy link
Owner

fphammerle commented Dec 13, 2022

Hi,

regarding 1)

The command-line option --fetch-device-info enables position reports on topic homeassistant/cover/switchbot-curtain/MAC_ADDRESS/position after STOP commands [...]. These reports may be requested manually by sending a MQTT message to the topic homeassistant/cover/switchbot-curtain/MAC_ADDRESS/request-device-info (requires --fetch-device-info)

source: https://github.com/fphammerle/switchbot-mqtt/tree/v3.3.1#curtain-motor

Automatic position updates after "open" and "close" command have not been implemented yet.

regarding 2)
Sorry, not implemented yet.

regarding 3)
Reporting the measured light levels has not been implemented yet.
pySwitchbot seems to support it though: https://github.com/Danielhiversen/pySwitchbot/blob/0.23.1/switchbot/devices/curtain.py#L108
Currently, switchbot-mqtt does not support PySwitchbot>=0.13 though
(due to breaking changes in PySwitchbot including the switch to "async", see #103 (comment))

@DutchessNicole
Copy link
Author

Okay, that answers those questions. I guess those things would be feature requests then with the exception of 3) which is a different beast.

Thank you for checking!

@fphammerle fphammerle added the enhancement New feature or request label Dec 17, 2022
fphammerle added a commit that referenced this issue Nov 5, 2023
…, drop compatibility with python3.8, alpine v3.18.4 base image

#103
#180 (comment)
#127 (comment)
@fphammerle
Copy link
Owner

Update regarding 3)
Main branch of switchbot-mqtt now supports pySwitchbot's latest release
(e964cce)

Support for reporting light levels in switchbot-mqtt can be added here:
https://github.com/fphammerle/switchbot-mqtt/blob/v4.0.0a0/switchbot_mqtt/_actors/__init__.py#L197

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants