yp87 / leaf2mqtt

Pull in data from the Nissan Connect platform for the LEAF and publish over MQTT
GNU General Public License v3.0
42 stars 39 forks source link

No MQTT sent commands working #10

Closed mitsumaui closed 2 years ago

mitsumaui commented 3 years ago

Hey!

First of all - thanks for taking this to the next Level! I have actually forked your code and published a container on GHCR, along with a helm chart if you are interested in maintaining a published version.

I seem to be struggling to get any update commands to work. Whilst MQTT messages are being published at the set interval, none of the update commands result in further logging or new values being published.

From Home-Assistant

service: mqtt.publish
data:
  topic: leaf/SJNFAAZE1U0000000/command/battery
  payload: update

Finest logging from leaf2mqtt

FINEST: 2021-06-16 20:23:50.227732: MqttClientWrapper: Publishing message SJNFAAZE1U0000000/climate/lastReceivedDateTimeUtc 2021-06-16T19:23:50.225208Z
FINER: 2021-06-16 20:36:02.691615: MqttClientWrapper: Received data: leaf/SJNFAAZE1U0000000/command update
FINER: 2021-06-16 21:11:42.073827: MqttClientWrapper: Received data: leaf/SJNFAAZE1U0000000/command/battery update
FINER: 2021-06-16 21:23:50.228763: main: Loop delay of 60 ended for SJNFAAZE1U0000000
FINER: 2021-06-16 21:23:50.228865: main: fetchAndPublishAllStatus for SJNFAAZE1U0000000

I've not developed with Dart before so I'm still trying to make sense of what's happening. Given that the wrapper receives the published topic / payload, it seems to not be triggering the update routine - so I wonder if there is some conversion / case issue?

Let me know if there is any further information you need!

mitsumaui commented 3 years ago

Done some debugging with this. It seems that the topic/payload has some characters which are not being stripped when split into the payload variable: https://github.com/yp87/leaf2mqtt/blob/c7643adcd72f0e120149235e781895123391d7e8/src/mqtt_client_wrapper.dart#L103

If you change it to the below it shows the correct payload value: payloadWithTopic.substring(payloadWithTopic.indexOf(message.topic) + message.topic.length+2)

Not sure what other impact this might have, or if it's a manifest of either the DART MQTT client, or my MQTT broker (VerneMQ).

yp87 commented 2 years ago

Hello!

Thank you for reporting the issue. I updated the code to use the solution from your fork.

Regards