-
Notifications
You must be signed in to change notification settings - Fork 0
/
layer.py
62 lines (43 loc) · 2.11 KB
/
layer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# BeagleBB-sending-receiveing-whatsapp-message
from yowsup.layers.interface import YowInterfaceLayer, ProtocolEntityCallback
from yowsup.layers.protocol_messages.protocolentities import TextMessageProtocolEntity
from yowsup.layers.protocol_receipts.protocolentities import OutgoingReceiptProtocolEntity
from yowsup.layers.protocol_acks.protocolentities import OutgoingAckProtocolEntity
import time
import datetime
import json
import Adafruit_BBIO.GPIO as GPIO
import Adafruit_BBIO.ADC as ADC
# Text Message to check
ADC.setup()
message = 'help'
message1 = 'info'
message2 = 'water'
message3 = 'stop water'
value1= ADC.read("P9_35")
a=str(value1)
class EchoLayer(YowInterfaceLayer):
@ProtocolEntityCallback("message")
def onMessage(self, messageProtocolEntity):
#send receipt otherwise we keep receiving the same message over and over
if True:
receipt = OutgoingReceiptProtocolEntity(messageProtocolEntity.getId(), messageProtocolEntity.getFrom())
if messageProtocolEntity.getBody().lower() == message.lower() :
response ="1. Type 'info' to get info about temperature, moisture and weather.\n 2. Type 'water' to irrigate.\n 3. Type 'stop '
elif messageProtocolEntity.getBody().lower() == message1.lower() :
response = a
elif messageProtocolEntity.getBody().lower() == message2.lower() :
response = "enter"
elif messageProtocolEntity.getBody().lower() == message3.lower() :
response = "Enter your command stop water"
else :
response = "Enter your command"
outgoingMessageProtocolEntity = TextMessageProtocolEntity(
response,
to = messageProtocolEntity.getFrom())
self.toLower(receipt)
self.toLower(outgoingMessageProtocolEntity)
@ProtocolEntityCallback("receipt")
def onReceipt(self, entity):
ack = OutgoingAckProtocolEntity(entity.getId(), "receipt", entity.getType(), entity.getFrom())
self.toLower(ack)