Commit 1107a5e5 authored by kranthi.kumar's avatar kranthi.kumar

Basic Commit

parent ca363906
Timestamp,kWh,kVAh,kW,kVA,current
09:00:00 PM,46.22821577,49.7593361,183.6689727,200.5324961,281.5829239
09:15:00 PM,45.76348548,50.22821577,183.4625521,200.5679427,281.6174316
09:30:00 PM,45.76348548,50.49377593,184.8895508,201.7947969,283.0400848
09:45:00 PM,46.55271632,50.4829459,184.3258984,201.4236094,282.4467697
10:00:00 PM,46.0045831,50.13828878,182.370349,199.2714219,279.4285278
10:15:00 PM,46.11068702,50.63358779,184.1894414,201.0399102,281.9737778
10:30:00 PM,46.47655816,50.83407914,186.4005052,203.868026,285.96993
10:45:00 PM,46.29657417,50.86875391,185.9188438,203.1028672,285.101181
11:00:00 PM,46.59622563,51.31205403,185.9425469,203.3676146,285.2346293
11:15:00 PM,46.76348548,50.51452282,185.3914844,202.4448047,283.9910583
11:30:00 PM,46.7912623,50.96601625,185.4971133,202.893375,284.5935898
11:45:00 PM,46.86088154,51.14325069,186.9712305,204.7621445,287.1810226
12:00:00 AM,46.68810512,51.33056708,187.2335677,204.5804583,286.9411825
12:15:00 AM,46.73200508,51.18733925,186.0456563,202.8139453,284.3181686
12:30:00 AM,46.79496588,51.26079353,186.8331797,204.3109961,286.5990677
12:45:00 AM,46.85892116,51.12863071,187.1399102,204.2709375,286.5819321
01:00:00 AM,47.14894649,51.88054822,186.9562344,204.2602708,286.5058187
01:15:00 AM,47.48590828,51.36011568,186.92925,204.0068555,286.2642593
01:30:00 AM,47.09100852,50.81574333,187.3521875,204.5727891,287.0003738
01:45:00 AM,46.8301533,50.63238945,186.0468398,203.1011367,285.0034714
02:00:00 AM,45.72398066,51.17797744,184.3389375,201.2684948,282.404541
02:15:00 AM,46.3553719,50.29752066,184.6342422,201.8070938,283.0306931
02:30:00 AM,46.24793388,50.97933884,184.6788633,201.5256367,282.820137
02:45:00 AM,46.76814924,50.49951991,184.2325885,201.2694792,282.310201
03:00:00 AM,45.77178423,50.50207469,183.580625,200.7382461,281.3659744
03:15:00 AM,46.70848452,50.43419157,184.7863125,201.8739492,282.9246216
03:30:00 AM,46.00105905,50.73593292,185.7652891,203.5681875,285.0090561
03:45:00 AM,46.5852337,51.22910737,184.7759896,202.2692083,283.2581685
04:00:00 AM,46.45626007,50.2771167,185.0352969,202.3385234,283.6272812
04:15:00 AM,46.11618257,50.22406639,184.8881992,201.9441992,282.904007
04:30:00 AM,46.76348548,51.11618257,184.9109375,202.3414063,283.5337219
04:45:00 AM,45.77150989,50.50246905,184.7092813,201.8274167,283.0511068
05:00:00 AM,46.80525359,51.11163883,184.6931289,201.988832,282.9909058
05:15:00 AM,46.06639004,50.22406639,186.5683164,204.0375039,286.0867615
05:30:00 AM,46.44140733,51.13850277,184.707875,201.8596094,283.1792603
05:45:00 AM,46.78265906,50.54614454,184.230651,201.262401,282.2118937
06:00:00 AM,46.28445527,50.52096979,184.7952656,202.1291055,283.3441238
06:15:00 AM,46.29230822,50.74873976,185.7647031,202.6981094,283.8277054
06:30:00 AM,45.76348548,50.26556017,184.8259896,202.1638958,282.53243
06:45:00 AM,46.76348548,51.18257261,184.8970625,202.0656445,282.3910522
07:00:00 AM,46.79229107,50.83618532,184.5802461,201.3318242,281.4895248
07:15:00 AM,46.24214876,50.92899449,185.7976797,203.4111563,284.364624
07:30:00 AM,46.65020747,50.54187414,185.5356615,203.3179531,284.45755
07:45:00 AM,46.51673468,51.09111485,186.1933711,203.3625078,284.3076477
08:00:00 AM,46.5247591,51.25743287,186.3628906,203.6023125,284.8340454
08:15:00 AM,46.49377593,51.22406639,185.9764805,203.1833945,284.1766663
08:30:00 AM,47.49377593,51.22406639,186.4182448,203.8110938,285.1260071
08:45:00 AM,46.52074689,51.25311203,186.3151016,203.7405,284.8326874
09:00:00 AM,46.43723849,50.93723849,186.2049961,203.4351641,283.949173
09:15:00 AM,46.61462873,50.57728433,185.295651,203.0170677,283.3728841
09:30:00 AM,46.76348548,51.18672199,186.1303594,203.7046406,284.8661957
09:45:00 AM,46.21770515,50.83181304,185.5998945,202.961207,284.3711319
10:00:00 AM,46.51673468,50.67441103,185.3284844,202.9535039,284.0480423
10:15:00 AM,46.60580913,51.22406639,186.3175937,203.9241094,285.1775411
10:30:00 AM,46.76348548,51.22406639,186.9348398,204.3435625,285.485817
10:45:00 AM,47.1228976,51.21081055,186.2981719,203.9254414,284.9080963
11:00:00 AM,46.4656781,50.83473721,185.9884948,203.7065938,284.5499674
11:15:00 AM,46.78572559,51.22447041,186.0624102,203.3610469,284.1670303
11:30:00 AM,46.79167381,50.95819759,186.8676094,204.143082,285.2875519
11:45:00 AM,46.76348548,51.49377593,185.8260664,203.3497227,283.8757019
12:00:00 PM,46.49507368,50.46602804,187.0693906,204.6899688,285.6078288
12:15:00 PM,47.0816898,51.06924167,186.5178438,203.9836055,284.4987106
12:30:00 PM,46.76348548,51.22406639,186.9434922,204.0151992,284.5806808
12:45:00 PM,46.72029423,51.2267069,183.9988281,201.5383021,281.3934835
01:00:00 PM,45.85646926,50.27951716,183.1253711,200.096832,279.4674225
01:15:00 PM,45.76348548,50.22406639,182.4745547,199.5217461,278.4521103
01:30:00 PM,45.91286307,50.22406639,183.8831992,200.6780937,280.0551987
01:45:00 PM,46.45315301,50.30377542,183.3296823,200.4262396,279.4595032
02:00:00 PM,45.97423288,50.58834076,184.0671641,201.4087773,280.7499008
02:15:00 PM,46.10788382,50.49377593,184.1131406,201.4959727,280.7490387
02:30:00 PM,46.41908714,50.49377593,183.9537656,200.6890273,279.8290939
02:45:00 PM,45.77315593,50.31003738,183.1457344,200.3349271,280.4654439
03:00:00 PM,46.34302665,50.7314564,185.7474883,203.0448242,284.3976135
03:15:00 PM,46.49377593,50.76348548,186.3097344,203.5141055,284.8322296
03:30:00 PM,46.44418916,51.16621515,185.9589635,203.9565,285.7725525
03:45:00 PM,46.82644628,50.5661157,186.4073828,203.576793,285.2424927
04:00:00 PM,46.92561983,51.1446281,185.6820234,202.6229375,284.267395
04:15:00 PM,46.78714722,51.25167175,186.0387031,203.1809063,284.955864
04:30:00 PM,46.70458832,51.22766709,184.8634167,202.0778958,283.2348429
04:45:00 PM,46.54437434,50.60635781,186.2454453,204.0464453,285.9152679
05:00:00 PM,46.49377593,50.89626556,185.4037383,202.4774922,283.8940964
05:15:00 PM,46.39943402,50.99694439,185.7739414,203.2029727,284.7158051
05:30:00 PM,46.72504731,50.58811785,185.0127344,201.8797292,283.0105387
05:45:00 PM,46.37869072,51.1106615,185.4774102,202.8813281,284.3863449
06:00:00 PM,46.5258736,50.25863311,185.2086055,202.2409453,283.3320618
06:15:00 PM,46.43568465,51.1659751,185.4590156,202.1452305,283.3671875
06:30:00 PM,46.56323514,50.29440005,184.829151,202.0933073,283.2255351
06:45:00 PM,45.98760331,50.71900826,184.3945508,201.1546719,281.9291687
07:00:00 PM,46.71440921,50.6874719,185.4610938,202.8501563,284.1721344
07:15:00 PM,45.83848678,50.32816542,184.3159896,201.3630521,282.2196655
07:30:00 PM,46.59999657,50.61659408,184.4464258,201.6729648,282.6120453
07:45:00 PM,46.07635198,50.98921505,182.8969297,199.8778906,280.1493378
08:00:00 PM,45.95020747,50.0373444,182.4403594,199.3924023,279.737442
08:15:00 PM,46.49823394,50.41558931,184.4423073,201.8952552,283.3975627
08:30:00 PM,45.89180755,50.27735674,183.2539531,200.4252383,281.1324539
08:45:00 PM,41.18257261,44.87966805,183.2521641,200.4773047,281.2613144
import csv
import logging
import time
class Mqtt_Publish:
@staticmethod
def mqtt_publish(client):
choice = input("please enter topic you need(kWh/kVAh/kW/kVA/current) :")
# covert input to lower case
choice = choice.lower()
def on_message(client, userdata, message):
print("message received ", str(message.payload.decode("utf-8")))
print("message topic=", message.topic)
print("message qos=", message.qos)
print("message retain flag=", message.retain)
client.on_message = on_message
list_kwh = []
list_kvah = []
list_kw = []
list_kva = []
list_current = []
try:
with open('input.csv', mode='r') as csv_file:
csv_reader = csv.DictReader(csv_file)
for row in csv_reader:
list_kwh.append({"Timestamp": row["Timestamp"], "Value": row['kWh']})
list_kvah.append({"Timestamp": row["Timestamp"], "Value": row['kVAh']})
list_kw.append({"Timestamp": row["Timestamp"], "Value": row['kW']})
list_kva.append({"Timestamp": row["Timestamp"], "Value": row['kVA']})
list_current.append({"Timestamp": row["Timestamp"], "Value": row['current']})
except Exception :
logging.exception("Exception occurred in connection", exc_info=True)
client.loop_start()
if choice == "kwh":
client.subscribe("Kwh")
elif choice == "kvah":
client.subscribe("kVAh")
elif choice == "kw":
client.subscribe("kW")
elif choice == "kva":
client.subscribe("kVA")
elif choice == "current":
client.subscribe("current")
else:
print("Invalid Input")
client.publish("Kwh", str({"Kwh": list_kwh}))
client.publish("kVAh", str({"KVAh": list_kvah}))
client.publish("kW", str({"kW": list_kw}))
client.publish("kVA", str({"kVA": list_kva}))
client.publish("current", str({"current": list_current}))
time.sleep(4)
client.loop_stop()
# print({"Timestamp":row["Timestamp"],"Kwh":row['kWh']}
Timestamp,kWh,kVAh,kW,kVA,current
09:00:00 PM,46.22821577,49.7593361,183.6689727,200.5324961,281.5829239
09:15:00 PM,45.76348548,50.22821577,183.4625521,200.5679427,281.6174316
09:30:00 PM,45.76348548,50.49377593,184.8895508,201.7947969,283.0400848
09:45:00 PM,46.55271632,50.4829459,184.3258984,201.4236094,282.4467697
10:00:00 PM,46.0045831,50.13828878,182.370349,199.2714219,279.4285278
10:15:00 PM,46.11068702,50.63358779,184.1894414,201.0399102,281.9737778
10:30:00 PM,46.47655816,50.83407914,186.4005052,203.868026,285.96993
10:45:00 PM,46.29657417,50.86875391,185.9188438,203.1028672,285.101181
11:00:00 PM,46.59622563,51.31205403,185.9425469,203.3676146,285.2346293
11:15:00 PM,46.76348548,50.51452282,185.3914844,202.4448047,283.9910583
11:30:00 PM,46.7912623,50.96601625,185.4971133,202.893375,284.5935898
11:45:00 PM,46.86088154,51.14325069,186.9712305,204.7621445,287.1810226
12:00:00 AM,46.68810512,51.33056708,187.2335677,204.5804583,286.9411825
12:15:00 AM,46.73200508,51.18733925,186.0456563,202.8139453,284.3181686
12:30:00 AM,46.79496588,51.26079353,186.8331797,204.3109961,286.5990677
12:45:00 AM,46.85892116,51.12863071,187.1399102,204.2709375,286.5819321
01:00:00 AM,47.14894649,51.88054822,186.9562344,204.2602708,286.5058187
01:15:00 AM,47.48590828,51.36011568,186.92925,204.0068555,286.2642593
01:30:00 AM,47.09100852,50.81574333,187.3521875,204.5727891,287.0003738
01:45:00 AM,46.8301533,50.63238945,186.0468398,203.1011367,285.0034714
02:00:00 AM,45.72398066,51.17797744,184.3389375,201.2684948,282.404541
02:15:00 AM,46.3553719,50.29752066,184.6342422,201.8070938,283.0306931
02:30:00 AM,46.24793388,50.97933884,184.6788633,201.5256367,282.820137
02:45:00 AM,46.76814924,50.49951991,184.2325885,201.2694792,282.310201
03:00:00 AM,45.77178423,50.50207469,183.580625,200.7382461,281.3659744
03:15:00 AM,46.70848452,50.43419157,184.7863125,201.8739492,282.9246216
03:30:00 AM,46.00105905,50.73593292,185.7652891,203.5681875,285.0090561
03:45:00 AM,46.5852337,51.22910737,184.7759896,202.2692083,283.2581685
04:00:00 AM,46.45626007,50.2771167,185.0352969,202.3385234,283.6272812
04:15:00 AM,46.11618257,50.22406639,184.8881992,201.9441992,282.904007
04:30:00 AM,46.76348548,51.11618257,184.9109375,202.3414063,283.5337219
04:45:00 AM,45.77150989,50.50246905,184.7092813,201.8274167,283.0511068
05:00:00 AM,46.80525359,51.11163883,184.6931289,201.988832,282.9909058
05:15:00 AM,46.06639004,50.22406639,186.5683164,204.0375039,286.0867615
05:30:00 AM,46.44140733,51.13850277,184.707875,201.8596094,283.1792603
05:45:00 AM,46.78265906,50.54614454,184.230651,201.262401,282.2118937
06:00:00 AM,46.28445527,50.52096979,184.7952656,202.1291055,283.3441238
06:15:00 AM,46.29230822,50.74873976,185.7647031,202.6981094,283.8277054
06:30:00 AM,45.76348548,50.26556017,184.8259896,202.1638958,282.53243
06:45:00 AM,46.76348548,51.18257261,184.8970625,202.0656445,282.3910522
07:00:00 AM,46.79229107,50.83618532,184.5802461,201.3318242,281.4895248
07:15:00 AM,46.24214876,50.92899449,185.7976797,203.4111563,284.364624
07:30:00 AM,46.65020747,50.54187414,185.5356615,203.3179531,284.45755
07:45:00 AM,46.51673468,51.09111485,186.1933711,203.3625078,284.3076477
08:00:00 AM,46.5247591,51.25743287,186.3628906,203.6023125,284.8340454
08:15:00 AM,46.49377593,51.22406639,185.9764805,203.1833945,284.1766663
08:30:00 AM,47.49377593,51.22406639,186.4182448,203.8110938,285.1260071
08:45:00 AM,46.52074689,51.25311203,186.3151016,203.7405,284.8326874
09:00:00 AM,46.43723849,50.93723849,186.2049961,203.4351641,283.949173
09:15:00 AM,46.61462873,50.57728433,185.295651,203.0170677,283.3728841
09:30:00 AM,46.76348548,51.18672199,186.1303594,203.7046406,284.8661957
09:45:00 AM,46.21770515,50.83181304,185.5998945,202.961207,284.3711319
10:00:00 AM,46.51673468,50.67441103,185.3284844,202.9535039,284.0480423
10:15:00 AM,46.60580913,51.22406639,186.3175937,203.9241094,285.1775411
10:30:00 AM,46.76348548,51.22406639,186.9348398,204.3435625,285.485817
10:45:00 AM,47.1228976,51.21081055,186.2981719,203.9254414,284.9080963
11:00:00 AM,46.4656781,50.83473721,185.9884948,203.7065938,284.5499674
11:15:00 AM,46.78572559,51.22447041,186.0624102,203.3610469,284.1670303
11:30:00 AM,46.79167381,50.95819759,186.8676094,204.143082,285.2875519
11:45:00 AM,46.76348548,51.49377593,185.8260664,203.3497227,283.8757019
12:00:00 PM,46.49507368,50.46602804,187.0693906,204.6899688,285.6078288
12:15:00 PM,47.0816898,51.06924167,186.5178438,203.9836055,284.4987106
12:30:00 PM,46.76348548,51.22406639,186.9434922,204.0151992,284.5806808
12:45:00 PM,46.72029423,51.2267069,183.9988281,201.5383021,281.3934835
01:00:00 PM,45.85646926,50.27951716,183.1253711,200.096832,279.4674225
01:15:00 PM,45.76348548,50.22406639,182.4745547,199.5217461,278.4521103
01:30:00 PM,45.91286307,50.22406639,183.8831992,200.6780937,280.0551987
01:45:00 PM,46.45315301,50.30377542,183.3296823,200.4262396,279.4595032
02:00:00 PM,45.97423288,50.58834076,184.0671641,201.4087773,280.7499008
02:15:00 PM,46.10788382,50.49377593,184.1131406,201.4959727,280.7490387
02:30:00 PM,46.41908714,50.49377593,183.9537656,200.6890273,279.8290939
02:45:00 PM,45.77315593,50.31003738,183.1457344,200.3349271,280.4654439
03:00:00 PM,46.34302665,50.7314564,185.7474883,203.0448242,284.3976135
03:15:00 PM,46.49377593,50.76348548,186.3097344,203.5141055,284.8322296
03:30:00 PM,46.44418916,51.16621515,185.9589635,203.9565,285.7725525
03:45:00 PM,46.82644628,50.5661157,186.4073828,203.576793,285.2424927
04:00:00 PM,46.92561983,51.1446281,185.6820234,202.6229375,284.267395
04:15:00 PM,46.78714722,51.25167175,186.0387031,203.1809063,284.955864
04:30:00 PM,46.70458832,51.22766709,184.8634167,202.0778958,283.2348429
04:45:00 PM,46.54437434,50.60635781,186.2454453,204.0464453,285.9152679
05:00:00 PM,46.49377593,50.89626556,185.4037383,202.4774922,283.8940964
05:15:00 PM,46.39943402,50.99694439,185.7739414,203.2029727,284.7158051
05:30:00 PM,46.72504731,50.58811785,185.0127344,201.8797292,283.0105387
05:45:00 PM,46.37869072,51.1106615,185.4774102,202.8813281,284.3863449
06:00:00 PM,46.5258736,50.25863311,185.2086055,202.2409453,283.3320618
06:15:00 PM,46.43568465,51.1659751,185.4590156,202.1452305,283.3671875
06:30:00 PM,46.56323514,50.29440005,184.829151,202.0933073,283.2255351
06:45:00 PM,45.98760331,50.71900826,184.3945508,201.1546719,281.9291687
07:00:00 PM,46.71440921,50.6874719,185.4610938,202.8501563,284.1721344
07:15:00 PM,45.83848678,50.32816542,184.3159896,201.3630521,282.2196655
07:30:00 PM,46.59999657,50.61659408,184.4464258,201.6729648,282.6120453
07:45:00 PM,46.07635198,50.98921505,182.8969297,199.8778906,280.1493378
08:00:00 PM,45.95020747,50.0373444,182.4403594,199.3924023,279.737442
08:15:00 PM,46.49823394,50.41558931,184.4423073,201.8952552,283.3975627
08:30:00 PM,45.89180755,50.27735674,183.2539531,200.4252383,281.1324539
08:45:00 PM,41.18257261,44.87966805,183.2521641,200.4773047,281.2613144
import logging
import paho.mqtt.client as mqtt
from Scripts.core.mqtt_publish_subscribe import Mqtt_Publish
mqtt_publish_object = Mqtt_Publish()
def on_connect(client, userdata, flags, rc):
if rc == 0:
print("connected OK Returned code")
else:
print("Bad connection Returned code")
broker_address = "192.168.0.220"
port = 1883
client = mqtt.Client("P091119")
try:
# to Know connection is established
client.on_connect = on_connect
print("conecting to brocker to ", broker_address)
client.connect(broker_address, port)
mqtt_publish_object.mqtt_publish(client)
# to Know connection is established
"""client.loop_start()
time.sleep(4)
client.loop_stop()"""
except Exception as e:
logging.exception("Exception occurred in connection", exc_info=True)
print(e)
finally:
client.disconnect()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment