easy2ntfy

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

easy2ntfy

#1 Post by chromo23 » 07 Mar 2023, 19:25

Hi dear community,
i hacked together a gateway for controlling ESPeasy nodes with a special version of easyfetch.
The code for the gateway is maybe not very elegant since i don't really get used to c++ but it works (most of the time :) )

Introducing easy2ntfy (https://github.com/chromoxdor/easy2ntfy)
diagram.png
diagram.png (200.03 KiB) Viewed 2363 times

What is it for:
I created easy2ntfy because i was in need to access my ESPeasy nodes via the internet since there was no easy way for me to use a VPN since my Provider uses CGN (https://en.wikipedia.org/wiki/Carrier-grade_NAT). Although I have now solved this problem, I still wanted to work on esp2nfty because it is very easy to use.
It is a combination of a gateway (esp8266) and a web application (derivative of easyfetch) which offers almost the same functionality as easyfetch.
This gateway can also be used to send data from an ESPeasy device in a different location via PostToHttp.


How it works (see diagram):
The web-application sends a request with the title "send" on the command-channel every 60 seconds.
easy2ntfy sends JSON data via the json-channel of an ESPeasy node to a ntfy server as long as it receives the "send" command.
The web-application gets this data via SSE (server side events) and renders with the JSON data the easyfetch dashboard.
If e.g. a button on the dashboard is pressed, this command will be send via the command-channel to a ntfy server and received by easy2ntfy through
websocket. From there the message is parsed and send to the ESPeasy-node.


Security concerns:
The public instances of ntfy have no authentication, which means everyone can listen to a channel.
Since the channel name is needed to read and send messages from and to ESPeasy it is important to choose a channel name which is not easy to guess. (the channel name acts as a kind of password)
E.g.: bad channel name: "test"
good channel name: "Test_123-456_tesT"
For those who want to give it a try but suddenly feel uncomfortable with it, can enter the read-only mode by long pressing the channel in the web-application. Easy2ntfy will now block any command until it is restarted (the channel is now displayed in red):
readonly0.png
readonly0.png (12.33 KiB) Viewed 2485 times

Limitations:
Public ntfy server (at least ntfy.sh) have limitations: https://docs.ntfy.sh/publish/?h=limit#limitations
The total number of messages per day is 1000 and the rate of requests is one per 5 seconds.
That's why easy2ntfy only sends JSON updates once every 10 seconds.
Only when a command is issued (e.g. button is pressed), the node is changed or the site is refreshed, easy2ntfy will send an update immediately.
And since easy2ntfy uses two channels it is unlikely to hit at least the daily message limit.
If the rate of requests limit is exceeded the web application will show an alert and stops sending for 10 seconds
If the message length exceeds 4,096 bytes the content will be treated as an attachment and can no longer be parsed.
Filtering out unnecessary JSON by esasy2ntfy shortens the output but a node (especially esp32) with a lot of enabled devices could hit this limit and will not be displayed.


Todo:
- show amount of daily send messages
- authentication options for self hosted server
- add notification when JSON message gets to long
[done] - display saved parameters in WiFiManager if available (instead of default values)


Known issues:
Sometimes easy2ntfy hangs and with it the serial connection which makes it hard for me to debug. For now a reboot solves the issue.

How to use:
1. Compile and upload Arduino sketch or flash binary file to an esp8266.
2. Connect to Access Point "easy2ntfy" (password: "configesp") and open 192.168.4.1 in a browser.
3. Enter your WiFi network credentials .
4. Enter ntfy-channel, ntfy-server, default-node-IP (other public ntfy server can be found here: https://docs.ntfy.sh/integrations/ - ntfy.adminforge.de is an exception and doesn't work with easy2ntfy!)
(the WiFiManager is always running. by entering the local ip you can always access and change the credentials and parameter)
5. Add a channel to easyfetch: https://raw.githack.com/chromoxdor/easy ... fetch.html

Setting up a channel:
config wifi.png
config wifi.png (26.9 KiB) Viewed 2485 times
Adding a channel in the web application:
config web.gif
config web.gif (171.68 KiB) Viewed 2485 times
Last edited by chromo23 on 09 Mar 2023, 13:48, edited 4 times in total.

User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

Re: easy2ntfy

#2 Post by chromo23 » 07 Mar 2023, 22:10

It seems, that ntfy.sh no longer works in it´s free version for easy2ntfy since you have to register.
Please use one of these server:
ntfy.mzte.de
ntfy.envs.net
Last edited by chromo23 on 09 Mar 2023, 14:57, edited 1 time in total.

User avatar
Ath
Normal user
Posts: 3417
Joined: 10 Jun 2018, 12:06
Location: NL

Re: easy2ntfy

#3 Post by Ath » 07 Mar 2023, 22:16

Though security by obscurity isn't very secure, by using a GUID it might be harder to guess, but it is of course still possible to capture the traffic and extract the channel identifier.
For non-critical service units it is quite usable though.

And now we should get your project added to these Projects and Forum posts lists :lol:
/Ton (PayPal.me)

User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

Re: easy2ntfy

#4 Post by chromo23 » 07 Mar 2023, 22:30

Ath wrote: 07 Mar 2023, 22:16 but it is of course still possible to capture the traffic
One can capture the traffic from the gateway sending json since it is the only one not using https. (which i will change eventually) other than that you have to log into the channel... but you are right. security looks different. But for now i feel safe. :)
Ath wrote: 07 Mar 2023, 22:16 And now we should get your project added to these Projects and Forum posts lists
This one i don’t get. Did i miss something?

Edit: for real safety one should use an selfhosted instance of ntfy or pay for using ntfy.sh

User avatar
Ath
Normal user
Posts: 3417
Joined: 10 Jun 2018, 12:06
Location: NL

Re: easy2ntfy

#5 Post by Ath » 07 Mar 2023, 23:13

chromo23 wrote: 07 Mar 2023, 22:30 This one i don’t get. Did i miss something?
The link you shared https://docs.ntfy.sh/integrations/ has lists of Projects + scripts and Blog + forum posts. I'm suggesting to get your project listed there too :D
/Ton (PayPal.me)

User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

Re: easy2ntfy

#6 Post by chromo23 » 07 Mar 2023, 23:52

Ath wrote: 07 Mar 2023, 23:13 I'm suggesting to get your project listed there too :D
I see :)
I have no problems if somebody puts it there… :D

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: easy2ntfy

#7 Post by TD-er » 08 Mar 2023, 08:34

And maybe we can also add some sub-forum here on the letscontrolit forum for these, as we also did for RPiEasy :)

Anyway, I would for sure suggest to have such a service self-hosted if possible.

Have not yet looked into it enough, but at first glance it already looks like you've put in a lot of work already (again :) )
So I have to free up some time to give it the attention it deserves to properly look into this.

Smotek7
Normal user
Posts: 142
Joined: 01 Aug 2020, 16:18
Location: SK

Re: easy2ntfy

#8 Post by Smotek7 » 09 Aug 2023, 21:34

@chromo23
thanks for advice.
I didn't try it, it seemed laborious.
In the end, I used the service remotexy.com
It suits me perfectly, up to 5 elements are free.
It would be awesome if something like that was part of ESPeasy.
For example as "alternative controller".

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests