# Email Alert when Input Threshold Reached

**URL:** <https://community.openenergymonitor.org/t/email-alert-when-input-threshold-reached/16346>\
**Category:** Emoncms\
**Tags:** emoncms\
**Created:** [27 December 2020 13:52 UTC](https://community.openenergymonitor.org/t/email-alert-when-input-threshold-reached/16346 "2020-12-27T13:52:42Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![icenov](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/icenov/32/14539_2.png) [@icenov](https://community.openenergymonitor.org/u/icenov)\
**Post date:** [1 January 2021 00:48 UTC](https://community.openenergymonitor.org/t/email-alert-when-input-threshold-reached/16346/11 "2021-01-01T00:48:30Z")

</div>

I found python mqtt not too hard to setup - I used paho.mqtt.client and found some useful hints on the web. If you are using mqtt on emoncms you’ll need the standard user and password if you’ve not changed them. This is how I’ve used it - my data is in a python dictionary data\_dict[“A9val”] which publishes to emon/rain:

```auto
import paho.mqtt.client as mqttClient

def on_connect(client, userdata, flags, rc):
    if rc == 0:
        print("Connected to broker")
        global Connected
        Connected = True
    else:
        print("Connection failed")

Connected = False # for state value

broker_address = "192.168.20.xxx" # your broker address
port = 1883
user = 'emonpi'
password = 'emonpimqtt2016'
client = mqttClient.Client("Python")
client.username_pw_set(user, password=password)
client.on_connect = on_connect
client.connect(broker_address, port = port)
client.loop_start()

client.publish("emon/rain/rainfall",data_dict["A9val"])

``
```

---

_[View the full topic](https://community.openenergymonitor.org/t/email-alert-when-input-threshold-reached/16346)._
