nickiv / node-red-huawei-sms

Node-RED module to send and receive SMS from Huawei LTE USB Stick
1 stars 0 forks source link

Improvements to SMS reading #3

Open PandCall opened 6 months ago

PandCall commented 6 months ago

Hi Three improvements that could be made to your SMS reader module three variables Delay between readings (default 20 seconds) Possibility of not deleting messages after reading Ability to define the last x SMS messages to be read (in case we don't delete on reading) These are my first ideas. Regards

nickiv commented 6 months ago

Hi!

  1. Delay between readings. Sure, that can be done. I can decrease it and check if it will work reliably. Now it is set "by eye".
  2. No deletion on reading. Why do you need it? If inbox of the stick will become full, it will stop accepting new messages. Looks like a complication to me.

It is possible to add node for reading inbox, and node for deletion of inbox entry. This way you can adjust the interval and number of messages and clear inbox in manual way. But building flows will be much more cumbersome. You will need to track index of processed message and so on. Can you please clarify what are you trying to achive?

PandCall commented 6 months ago

Hello For the read delay, the simplest thing to do would be to add a parameter to the Node configuration, and yes, of course, check beforehand for the minimum value so as not to throw the device into error.

When it comes to deleting data, the idea is to keep track of it without having to save it in a database or file. It's true that in some countries and for some packages, the size is limited. For this reason, retention must be combined with the possibility of deleting all or part of the sms. Tracing is necessary to keep track of the telephone numbers and dates of those who have issued an order, for example, for an alarm system. Yes, why not the idea of adding Nodes that would be used as needed. But for each Node, depending on their functions, you could adjust the parameters in the Node, to make use more flexible. For example, for the Delete Node, you could specify either the number to be retained, or a date range to be deleted, and so on. In the same vein, NODEs for : Read the number of SMS in the card, read or unread Read and change wifi and guest wifi status Read and change mobile data status Read the size of mobile data uploads and downloads (data package monitoring) Read router information. Basically, monitor router activity and, for certain functions, enable or disable them.

Why am I asking you this? In API mode, it's easy enough in Python or Shell to get the information, but in an environment like HA, it's more complex, it's running in Dockers and not so simple (at least for me) and your NODE manages to query the API URL of IP 192.168.8.1. But maybe it's my programming limitations that are holding me back. All these suggestions are ideas for evolving your development if you want to make it more functional. Regards

nickiv commented 6 months ago

I will let you know when there will be version with adjustable polling interval. Or may be it will be just lower, because I suppose that everyone will be happy with just minimal possible interval.

It looks like you are using the stick and the module for doing some business. My initial goal with this module was to send alerts from NR and receive commands from it. So I cannot promise you that I will add other modules that you're asking. I will consider to add something like "API request". With it you can send any payload to http api of stick, and internally it will handle queuing and authorizing. Does it make sense?

Do you regularly use stick web interface for reading inbox? I didnt expect that. My suggestion is to add "write to file" module right after Receive SMS. That way you will have like paper trail of incoming SMS messages. Almost as reliable as inbox itself.

PandCall commented 6 months ago

No problem, I wasn't shopping :) I was just talking to you and discussing development possibilities. I imagine that if you made this NODE, it's because you had a need. I'm happy with it because now I can read SMS without having to use the web interface. I'd probably use your NODE with or without upgrades, because its primary function suits me fine. We have the same usage objectives, which is why I like it. No, I'm not trading, I'm using it for personal use, when I trade a product, I pay for it. This is for me and to share with my close group. Yes, the API request might be the solution to give you the freedom to obtain a precise result at any level. The very principle of REST, you know the key to interogate, you get the result.

I never use the web interface to read the key, which is the whole point of your NODE.

I'm not sure it's necessary to add the Wite File, NODE-RED has the NODE for that and it's easy to set up.

For the moment, I'm doing some tests that work well Writing to a test file Writing to a Mysql database Writing to an MQTT broker

image

Thanks for your NODE and I wasn't asking you for any particular development, just to exchange ideas.

PandCall commented 6 months ago

I've just discovered a little behavior that you could probably correct.

I forward incoming messages, if I do it on one number no problem, it works perfectly, but if I start using several forwarding instances, it crashes the following forwardings, but that's normal, because NR tries to forward all forwarding instances simultaneously.

Perhaps you could include an availability check mechanism in your "SEND SMS" NODE, or a retry mechanism, or allow the NODE to have several numbers in the queue.

For the moment, I've used a NODE DELAY to give the router time to hand over, but if this were included in the "SEND SMS" NODE itself, it would be simpler.

image

Regards

nickiv commented 5 months ago

@PandCall I have published a new version (0.0.9). In this version polling interval of incoming messages is reduced to 5 seconds. Also, I fixed simultaneous sending. It should work without "Delay" node. Delay and retry are implemented internally.

There is also improvement in Send SMS. You can specify several phone numbers with semicolon. And you can override Phone setting in Node with msg.phone.

Please let me know if something doesnt work as expected!

PandCall commented 5 months ago

Nice, The multi-number Send seems to work well, making processing easier. However, I don't understand the subtlety of your "And you can override Phone setting in Node with msg.phone" function. There used to be 4 parts of information index,content,date,phone It's this last one that can be called by msg.phone, right? If so, when can you use msg.phone? Regards and Good Job

nickiv commented 5 months ago

@PandCall when you are sending messages you can now define phone numbers to send "on the fly" by specifying msg.phone. For example to load them from database. Before 0.0.9 only option was to specify exact number in Send SMS node's Phone setting.

PandCall commented 4 months ago

Hi Nickiv, Would you have a solution for sending MMS (SMS + Photo) for an alarm system for example, connected doorbell or any other system that needs a visual? Regards

nickiv commented 4 months ago

AFAIK it is not possible to do with the API of Huawei stick. There is no send MMS using web interface of the stick, right?

On the other hand, why use MMS for this task? You have the internet connection, right? You can use Telegram (https://flows.nodered.org/node/node-red-contrib-telegrambot). I use it very long time, it is convinient and robust.

Other options: PushOver app or simply Email. I did not try it, but I'm sure it will work.

And if it fail for some reason, then you can use SendSMS of this module to backup text-only notification.

In my setups I do just that. I use Telegram Send node, and if it produces error, I send SMS message through Huawei.

How does it sound to you?

PandCall commented 4 months ago

Yes, there are several alternative solutions. One of the objectives, for example in a security solution, is not to depend on the Internet for alerts. In the event of voluntary or involuntary disconnection of the line. That's the whole point of using an LTE key or router, because my French operator also gives me access to an API for sending SMS messages. https://flows.nodered.org/node/node-red-contrib-sms-free-mobile

It was just a question, if you had already explored this possibility, and yes, I had a doubt about the possibility of exploiting MMS with the API.

nickiv commented 4 months ago

This this LTE router, it is directly connected to the internet even if there is no other connections. So it cannot be disconnected by intruders from outside. And if it will be disconnected by intruders, at that point we will not be able to send even SMS.

My secure setup look like this.

  1. I have dedicated computer which is connected to the internet with wired connection.
  2. To this computer Huawei LTE Router is attached. It is being used for sending SMS alerts and also as backup internet connection.
  3. Computer is powered by APC UPC. APC is connected to a computer with USB for status updates.
  4. Computer runs Linux and Node-RED.
  5. Node-RED pings cronitor.io so I will be notified whenever NR is down for any possible reason. Cronitor is free with some limits. This is the most reliable way to detect connection, software, hardware failures of remote monitoring system. For pinging I'm using HTTP node in combination with Inject node.
  6. Node-RED connects to the APC UPS via https://flows.nodered.org/node/node-red-contrib-apcaccess module. If power is down SMS alert is being sent. This way I will be notified if there is power outage on premises. If power is down you can expect subsequent failures.
  7. Node-RED send me different alerts to Telegram. If Telegram Send node fails, I do send SMS. You can setup simultaneous sending to Telegram and SMS for most critical notifications.
  8. I did setup of failover routing in Linux, so if wired connection fails, default route is being switched to LTE. Connection is tested by pinging some well know high-availibility hosts like 1.1.1.1 or 8.8.8.8. When wired connection is live again it will be prioritized. That requires some scripting. But once it is done, your system can overcome wired connection issues while being able to send alerts to Telegram (or email).
PandCall commented 4 months ago

Hi For me, The LTe router doesn't use the Internet, so I only have 50 MB of data. It only costs me 2€/month or 0€/Month if you have your internet box with the operator. On the other hand, you don't get much data or phone. That's why I only use it for SMS. And MMS, even if they use Data, are not deducted from the 50 MB of Data included in the package. For internet failover, my Pro operator provides me with an LTE box in case of loss of fiber. So my huawei LTE is only used for SMS. And I want to be able to use it no matter what. But the origin of my question was, had you managed to exploit MMS, but obviously, the API doesn't allow it, that answers the question. Regards