mduran80 / pymadoka

A python library to control Daikin BRC1H (Madoka) thermostat
MIT License
26 stars 8 forks source link

Default Topic MQTT seems broken #10

Open rekkebus opened 1 year ago

rekkebus commented 1 year ago

Hi there,

Thanks for making a great library on pymadoka and a MQTT broker, trying to get this to work for HVACS.

I noticed 2 things already:

When using root topic starting with a / you get some weird behaviour, at least on mosquito:

Defining a root topic without a trailing / fixes this, although the default ROOT TOPIC in mqtt.py is still defined with a /

Furthermore, my madoka keeps changing names in bluetooth. Half of the time it is called "UE878_RF_MODULE" and the other half "BRC1H_AA_BB-CC" . i changed the mqtt library to accept a config value "root_topic_only" that omits the device name.

def get_device_topic(self): """ Get the customized device topic using the device name and the root topic. Returns: str: The device topic in the form /root_topic/device_name""" root_topic = self.ROOT_TOPIC if "root_topic" in self.mqtt_cfg: root_topic = self.mqtt_cfg["root_topic"] if "root_topic_only" in self.mqtt_cfg: return root_topic else: normalized_name = self.controller.connection.name normalized_name = normalized_name.replace(" ","_") normalized_name = normalized_name.replace(":","_") normalized_name = normalized_name.replace("/","_") return "/".join([root_topic,normalized_name])

mduran80 commented 1 year ago

Hi,

I will have a look at it and issue a new version with your suggestions. I didn't test it with mosquito and it looked good by the time with the command line tools I used. The problem with the name comes from the thermostat and the BT library, but there isn't much I can do to override it because no configuration is stored by the pymadoka library. Anyway, your patch should be enough, thank you.

On Sat, 5 Nov 2022 at 14:53, rekkebus @.***> wrote:

Hi there,

Thanks for making a great library on pymadoka and a MQTT broker, trying to get this to work for HVACS.

I noticed 2 things already:

When using root topic starting with a / you get some weird behaviour, at least on mosquito:

Defining a root topic without a trailing / fixes this, although the default ROOT TOPIC in mqtt.py is still defined with a /

Furthermore, my madoka keeps changing names in bluetooth. Half of the time it is called "UE878_RF_MODULE" and the other half "BRC1H_AA_BB-CC" . i changed the mqtt library to accept a config value "root_topic_only" that omits the device name.

def get_device_topic(self): """ Get the customized device topic using the device name and the root topic. Returns: str: The device topic in the form /root_topic/device_name""" root_topic = self.ROOT_TOPIC if "root_topic" in self.mqtt_cfg: root_topic = self.mqtt_cfg["root_topic"] if "root_topic_only" in self.mqtt_cfg: return root_topic else: normalized_name = self.controller.connection.name normalized_name = normalizedname.replace(" ","") normalized_name = normalizedname.replace(":","") normalized_name = normalizedname.replace("/","") return "/".join([root_topic,normalized_name])

— Reply to this email directly, view it on GitHub https://github.com/mduran80/pymadoka/issues/10, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFK3CTZND7G2UPXHHIGMWCTWGZRFLANCNFSM6AAAAAARX6AFRA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

mduran80 commented 1 year ago

I updated the library (0.2.8) so the address is always sent as part of the root topic (instead of the name provided by the bluetooth connection). Anyway, using the root_topic_only is still supported with slight changes to what you proposed.