As the title says... Chat on...

User avatar
By ClosetSparky
#12454 Ribs99,

Thank you very much for posting your code. I'm attempting to use it to Push notices for my Garage Door sensor. I say attempting, because I haven't been successful yet.

I'm using NodeMCU 0.9.5 build 20150212 and your unmodified code. Unmodified except for the po_token and po_user strings. Admittedly I'm new to Lua. The lack of diagnostic response makes debugging very difficult.

Any guidance would be very much appreciated!! I'd love to prove I can push messages before my trial period runs out.

Thanks,
ClosetSparky
User avatar
By Carlos Krieg
#13603 Hi,
I found out, this slightly changed code works fine... but I don't know, for how Long, because the Pushover Website says:
"HTTPS is required for all API calls, and for security purposes, your application should enable your HTTP library's SSL verification"


po_token="TOKEN"
po_user="USER"
po_title="Test"
po_string="token="..po_token.."&user="..po_user.."&message=test&title="..po_title
post_length=string.len(po_string)

conn=net.createConnection(net.TCP, 0)
conn:on("receive", function(conn, payload)
print(payload)
end )
conn:connect(80,"api.pushover.net")
conn:send("POST /1/messages.json HTTP/1.1\r\nHost: api.pushover.net\r\n"
.."Connection: keep-alive\r\nkeep-alive: 1\r\nPragma: no-cache\r\n"
.."Cache-Control: no-cache\r\nContent-Type: application/x-www-form-urlencoded"
.."\r\nContent-Length: "..post_length.."\r\nAccept: */*\r\n\r\n"
..po_string
)
conn:close()
User avatar
By ClosetSparky
#24345 Carlos,

Thank you very much for the response and the code. I was finally able to get my code working. Yee haw!

My next step is to integrate the web server and the push-over functionality. If only there was more time for play. ;-)

Here's my code for anyone that may be interested.

ClosetSparky

Code: Select allprint('PushNew.lua started')

-- Config Variables
po_token="My Token Here"
po_user="My User Here"

po_message="Test2"
po_title="Test"
po_sound="intermission"

po_string="token="..po_token.."&user="..po_user.."&message="..po_message.."&title="..po_title.."&sound="..po_sound
post_length=string.len(po_string)

conn = nil

conn=net.createConnection(net.TCP, 0)

conn:on("receive", function(conn, payload)
   success = true
   print(payload)
   end)

-- when connected, send stuff
conn:on("connection", function(conn, payload)
      print('\nConnected')
      conn:send("POST /1/messages.json HTTP/1.1\r\nHost: api.pushover.net\r\n"
      .."Connection: keep-alive\r\nkeep-alive: 1\r\nPragma: no-cache\r\n"
      .."Cache-Control: no-cache\r\nContent-Type: application/x-www-form-urlencoded"
      .."\r\nContent-Length: "..post_length.."\r\nAccept: */*\r\n\r\n"
      ..po_string
      )
   end)
conn:close()
-- when disconnected, let it be know
conn:on("disconnection", function(conn, payload) print('\nDisconnected') end)

conn:connect(80,'api.pushover.net'
User avatar
By negrito
#60931 Hello guys, nice job.

But is this all what I need uploaded to the ESP8266 or do I need to also put the
part to connect to my wifi? If yes! Please provide me the complete code or even
better a howto or tutorial.

Kind regards,