question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception when running miflora-mqtt-daemon.py

See original GitHub issue
[21:02:34] root@smarthome:/opt/miflora-mqtt-daemon# python3 /opt/miflora-mqtt-daemon/miflora-mqtt-daemon.py

Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon
Source: https://github.com/ThomDietrich/miflora-mqtt-daemon

[2019-01-15 21:02:47] Connecting to MQTT broker ...
Adding sensor to device list and testing connection ...
Name:          "Flowercare"
Internal name: "Flowercare"
Device name:   "Flower care"
MAC address:   C4:7C:XX:XX:XX:XX
Firmware:      2.7.0
[2019-01-15 21:02:52] Initial connection to Mi Flora sensor "Flowercare" (C4:7C:8D:67:58:3B) successful

[2019-01-15 21:02:52] Announcing Mi Flora devices to MQTT broker for auto-discovery ...
Traceback (most recent call last):
  File "/opt/miflora-mqtt-daemon/miflora-mqtt-daemon.py", line 251, in <module>
    mqtt_client.publish('{}/$announce'.format(base_topic), json.dumps(flores_info), retain=True)
  File "/usr/local/lib/python3.5/dist-packages/paho/mqtt/client.py", line 1057, in publish
    raise ValueError('Publish topic cannot contain wildcards.')
ValueError: Publish topic cannot contain wildcards.

I’ve commented in base_topic = mqttjson to get it into OpenHAB items. running the script with this line commented out it works perfect, but the OpenHAB items never get updated. Can someone help?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Markkuusscommented, Jan 17, 2019

Maybe that’ll help you. I’m using the new MQTT plugin from Openhab 2.4 with the internal broker.

Thing file:

Bridge mqtt:systemBroker:MqttBroker "MQTT Broker" [ brokerid="embedded-mqtt-broker" ]
{
    Thing topic FicusBenjamin "Ficus Benjamin"
    {
        Channels:
            Type number : light         "Lichtstärke"           [ stateTopic="miflora/FicusBenjamin", transformationPattern="JSONPATH:$.light" ]
            Type number : battery       "Batterieladung"        [ stateTopic="miflora/FicusBenjamin", transformationPattern="JSONPATH:$.battery" ]
            Type number : temperature   "Lufttemperatur"        [ stateTopic="miflora/FicusBenjamin", transformationPattern="JSONPATH:$.temperature" ]
            Type number : conductivity  "Bodenfruchtbarkeit"    [ stateTopic="miflora/FicusBenjamin", transformationPattern="JSONPATH:$.conductivity" ]
            Type number : moisture      "Bodenfeuchtigkeit"     [ stateTopic="miflora/FicusBenjamin", transformationPattern="JSONPATH:$.moisture" ]
    }
}

Item File:

Number:Illuminance      Miflora_Ficus_Light         "Lichtstärke Ficus [%d lx]"             <light>         { channel="mqtt:topic:MqttBroker:FicusBenjamin:light" }
Number:Dimensionless    Miflora_Ficus_Battery       "Batterieladung Ficus [%d %%]"          <battery>       { channel="mqtt:topic:MqttBroker:FicusBenjamin:battery" }
Number:Temperature      Miflora_Ficus_Temperature   "Lufttemperatur Ficus [%.1f °C]"        <temperature>   { channel="mqtt:topic:MqttBroker:FicusBenjamin:temperature" }
Number                  Miflora_Ficus_Conductivity  "Bodenfruchtbarkeit Ficus [%d µS/cm]"   <lawnmower>     { channel="mqtt:topic:MqttBroker:FicusBenjamin:conductivity" }
Number:Dimensionless    Miflora_Ficus_Moisture      "Bodenfeuchtigkeit Ficus [%d %%]"       <humidity>      { channel="mqtt:topic:MqttBroker:FicusBenjamin:moisture" }
1reaction
ThomDietrichcommented, Jan 16, 2019

Results are published to the MQTT broker but not retrieved by openHAB. Should be simple to debug. My best guess is that with openHAB 2.4 you are now using the new MQTT binding and need to adapt your configuration. The one generated with --gen-openhab is for the old binding and won’t help you much. Either install the old binding or modify your configuration. Both should be easy. If you need help, please contact the openHAB community.

I’ve moved into a new apartment and did not yet implement the needed changes for this daemon. The solution will be #57 - to update the Homie reporting_method and have plants automatically discovered by openHAB 💪

Read more comments on GitHub >

github_iconTop Results From Across the Web

getting exception when running python script using mule
Hi All,. I have python code which is running fine in my raspberry Pi. However, when I am running the same code using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found