A Fine Sunny Weekend

Scargill's Man-CabinEvening all, it has been a busy weekend here at the Scargill’s man-cabin. No Friday, frequent blog-visitor JAY popped over for a visit and we spend some time discussing new stuff:

First on the list was a new toy Jay just picked up on offer at Maplin – a “SmartSensor Energy Egg” solo pack which comprises a PIR Egg and a mains socket. The two operate on 433Mhz and allow for turning a light on for a predetermined time when someone moves in the room. Simple enough – but At under £8 on offer I guess Jay could not refuse. I have one sitting in front of me now looking for a home in my office. There is a website – energy-egg.com but I advise against it – half of the links go no-where. Anyway – special offer – Maplin.

The gadgets are meant to run stand-alone but of course we had to try it out with the RFLINK 433Mhz setup and sure enough – the RFLINK registers activity in the PIR.

Turning the PIR on and off with the handy button on the top produced this output.

“20;31;Eurodomest;ID=0eec5a;SWITCH=05;CMD=ALLON;”

“20;30;Eurodomest;ID=0eec5a;SWITCH=01;CMD=OFF;”

ChatbotEnergy EggStrangely the effect was the opposite of what you might expect – the ALLON command turned the light off!! Anyway the upshot being we can easily monitor this device along with others using the RFLINK.  Sadly when we tried to turn this into a COMMAND to turn the light on and off from the RFLINK unit, while we could turn the device ON, the OFF command stubbornly refused to work – but we started sending emails off to Frank Zirrone of RFLink software fame – and he was very helpful – we’ve now send some diagnostics off (this all comes in the software folder for RFLink) and he’s taking a look.

Meanwhile we discovered a potential issue with the playground covered earlier in this blog – the mobile phone as server. I’ve been using TASKER on the phone to pick up MQTT messages from the Debian installation (to in turn play a really nice doorbell sound) – using the MQTTCLIENT Tasker Plug-in App which you might recall replaced it’s somewhat ill-fated predecessor. Well, it seems it is still not out of the woods.

ChatbotWhile it works GREAT, if you reboot the phone, while everything else comes up perfectly including Debian itself, Tasker and, well, yes, everything – the MQTT plugin – would you believe does NOT re-connect with the MQTT broker until you open the app.  Now this may be because it is starting before Debian is ready – but you would think that such a program designed to run in the background, would try, try, try again until it got through. We even tried using Tasker to initialise it – no joy.  So until the author comes back, we’re on the hunt for alternatives – and it is possible that TELEGRAM may be it  – Chatbotexcept having installed it on my phone (easy) and on my PC (easy) and installed node-red-contrib-chatbot on Node-Red – with a wopping 37 nodes  – I’m now utterly confused. Jay helped me set up a bot and send a message to it – but getting it to arbitrarily send a message… I’m not quite there yet – and what you’re supposed to do with all those OTHER nodes….

ChatbotThere is a TELEGRAM app for Android, a plug in for Node-Red and in fact it comes on just about all platforms – this is similar to other messaging apps in that you can send text message back and forth – so the hope is that we can send messages between Node-Red on Debian – and the Android Tasker reliably – more on that later.

Anyone have any experience of using TELEGRAM? I swear this could be the death of me.  A video showing the various nodes in action would be nice!

 

I’ve fitted some door sensors 433Mhz model DC55 from Friedland – comprising a magnet and a reed-switch-triggered 4533Mhz transmitter – all very nice and small – they work a treat with RFLink but right now I’m looking for the meaning of the codes – clearly I figured out the ones for open and close – and there’s another when an internal spring is released – this is for security – but there is a 4th code which comes out very occasionally – and I have no idea what it is for. Maybe “battery ok” – maybe “battery shot” – no way to tell and their manuals don’t seem to help.  Any ideas anyone?

Finally – the script – just updated it to handle that Node-Red initialisation we discussed in a previous blog entry.

Hope you had a nice weekend.

Facebooktwitterpinterestlinkedin

34 thoughts on “A Fine Sunny Weekend

  1. Latest great video by Csongor Varga, about Telegram and Node-Red: https://www.youtube.com/watch?v=wR1zWroRtCg

    This is a quite long and extensive flow I built for telegram integration. It does a few things just to mention a few:
    – Registration of telegram users in the bot (to control who can use the services offered by the bot)
    – Receiving and responding to commands as simple words (not /command)
    – Handling complex conversation where the bot responds with options as keyboard
    – Handling user control where users can only access commands based on their access level
    – Sending text, image and voice messages
    – Complete framework open for adding new functions

    Download the entire flow seen in this video: https://drive.google.com/file/d/1QzcbgBDWSexz5UfEaHVGyEXLrghKwAhO/view

  2. Hi, great blog, hope you’re feeling better, with the prospect of a Happy New Year!

    I picked up a couple of EnergyEgg 2-gang wall switches for 99p each in a sell-out by Maplins – had to be done!

    Reading the above, did you get anything concrete from Frank the RFLink guy about handling this stuff? I don’t have a remote or Egg to copy its signals, so some more clues would be useful. I’m about to power them up and see what happens…

    Cheers, thanks

    1. Hi Pete and thanks for the email reply.

      I used the ALLON string you described, in conjunction with setting the switch to “learn” (hold switch on for 5+ secs), and it now responds to the ALLON command by turning on. However, like yours, it doesn’t respond to the OFF! Drat. It’s less of a problem than it might seem though, as I fried the first one starting it up, so only one left.

  3. I’m a little late in seeing this but it looks very interesting. I have yet to install and try chatbot but anyone also tried to use the Listen node to parse messages from Alexa? Is this an option?

    Mike

  4. I’ve been using Tasker for just a few days (thanks for the tip Peter!). I may be over-the-top on my “tasks”, however I’ve found that by setting up a Profile with the System Event – Device Boot that contains the following tasks, I’m able to have Tasker publish messages to my broker at startup. The messages take the better part of a minute to show up, I’m assuming it’s because the phone is busy doing some other housekeeping.

    Tasks:
    1. Say “Hi” (to have Tasker doing something else in advance of the next tasks)
    2. Launch App MQTT Client
    3. Wait 2 seconds (to allow time to connect)
    4. Launch App MQTT Client (again)
    5. Publish MQTT Message, Configuration S7:Start
    6. Wait 1 second
    7. Go Home (to clear the screen)

  5. Hmmm.. I have to admit to feeling a bit thick at the moment … I just don’t get this ‘Bot’ thing.
    I use pushbullet at the moment to send the odd warning message from Node red to my phone/PC and I can read/answer test messages when my phone’s in another room.

    With pushbullet I setup a token etc and send a message, this message appears on my phone and PC, great.

    I setup Telegram thinking it was similar but with extras that might be interesting but after setting up a bot and getting a token I can’t get it to just send a message from node red to the telegram app on my phone or PC.

    There’s something I’m just not getting!

    1. Well, Phil, if you’re feeling thick that makes two of us. So I’ve been using Pushbullet but various comments about changes including limits have put me off. Someone mentioned Telegram and I looked into it – and in fact it it is a LOT more powerful by the look of it.

      I don’t understand the various mechanisms of the Node-Red nodes I just fitted but I CAN say that the ones I have tried – work perfectly. I now have my phone and PC alerting me when doors open and close and doorbells are pushed (just for testing – that lot is going into a database) and up to now I have to say, reliability 100%.

      I cannot even claim I did it alone – reader JAY who no doubt is looking in – helped me through – perhaps if he is around he can help you.

      In the simplest case I have a Telegram Receiver on the left complete with the name and token of my chosen BOT…. after that is a TEXT node with some text.

      The output of that goes to the TELEGRAM SENDER node. It has the same credentials as the first one.

      And that’s it – using my phone I send a message to the BOT and it sends me a reply.

      If you want to send something custom to the Telegram sender – it is just as easy. You send a payload through the CONVERSATION node – which has the credentials of the BOT – into the same Telegraph sender. In my case the payload I’m sending in is..

      msg.payload={“content”:”Back Door Bell UK”,”chatId”:xxxxx”,”type”:”message”};

      where xxxx is the bot ID – the same number that goes into the Conversation node.

      It is all a lot easier to do than talk about. Once you get that far you can go wild, you can send QR codes, KEYBOARDS, images, videos, ALL sorts to the end client…

      1. Pete,
        Thanks for the pointers on that, I tried to install the telegram bot nodes but nothing appears on the right, I also installed what looks like the simpler version that just has the 4 nodes, I’ll have to get that sorted first ….. it’s certainly a roller-coaster ride this hobby 🙂

          1. Thanks, I have started to get somewhere, I can send a request from my phone to node red and get an answer, slowly getting there.

    2. You’ve already got a bot using Node-RED to work with PushBullet.

      A bot is only an automated interaction with a messaging service.

      With chatbot, you need 3 nodes to initiate an output to Telegram (plus whatever triggers it). A conversation node followed by a text node and finally an output node.

  6. I’ve just also learnt that I cannot have my python and node-red scripts using the same Bot Token. My python script is terminated with this message (I’ve replaced square&curly brackets with ‘?’ to avoid any other inconvenience in the blog pages):

    2017-03-25 23:16:26,534 (__init__.py:211 MainThread) ERROR – TeleBot: “A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
    ?b’?”ok”:false,”error_code”:409,”description”:”Conflict: terminated by other long poll or webhook”?’?”

    1. Interesting. Always a twist somewhere in this stuff 🙁

      Still, Telegram bots are vastly simpler to engineer than Microsoft ones! Still haven’t managed to get my head round those. And though there is now a Node-RED helper node, I can’t get it to work or get the dev to give further information sadly.

  7. I’ve deleted a comment here (code) as requested – then realised of course that it deletes everything subsequent to that comment!

  8. thank you very much, but publish it on flows.nodered.org or some other site, and link it here… if you publish code in comments, you risk wordpress cuts something or format it in unusual ways, and the COMMENTS page is all messed up 🙂

  9. Bit late to this conversation but I also use Telegram and have done for ages, replacing PushBullet whose clients were, quite frankly, pants.

    I currently use the older telegram nodes in my “live” installation and they work just fine and seem very reliable. Both sending and receiving works.

    I had a couple of goes with Chatbot and it is true to say that the documentation is certainly lacking clarity. My first couple of attempts didn’t get anywhere but my recent attempt is now working and I’ve even written a Rivescript handler which greatly simplifies the typical back and forth “conversations” you might have with bots.

    I’ve some working test examples if you want them, just let me know. The main thing I learned is that many (most?) of the intermediary nodes need to be passed through a text output node before sending if you actually want anything to appear.

    I’ll probably switch to Chatbot when I get a chance if only for the RiveScript feature.

    1. Thanks for that Julian – any examples – sure – fire away… here’s where I am up to now – thanks to a conversation with JAY…

      I can take in a message as a bot – split into two responses, one for authorised people – another for not authorised people – the authorised one – by reading msg.payload.content I can read the input and send something out depending on what came in – and then finally at the bottom – I can send an arbitrary message – that ‘s about it for now 🙂 – Pizza is ready…

        1. You know – I was GOING to and I completely forgot about it – I’m not the cook mind you – I was sitting contemplating embroidery, unable to figure out how to use 37 nodes of Chatbot, when I got a call to say “Pizza is ready”.

  10. Hi Pete,

    im using the chatbot node with telegram – now for some months, since pushbullet goes pro and restrict the free amount of messages.
    It works great, i use it send text and images to the bot i have created.
    Bot creation and get the chat id was the most complicated part of all… Maybe today it is easier? You can also send messages to node red from telegram, i use this f.e. to query the status of devices like power ports or reed switches from the windows.
    I like it.

    best regards

    -Andreas

    1. I’m following your lead Andreas – fitted Telegram on my phone and PC – no problem at all – went to Node-Red, installed CHATBOT and – THIRTY SEVEN NODES – I think I’m going to take up painting and decorating!

      1. To send a message you only need CHATBOT-CONVERSATION, and next node could be a message (CHATBOT-MESSAGE) or an image (CHATBOT-IMAGE) and as last node CHATBOT-TELEGRAM-NODE.
        To receive a message you need a receiver node and as next node an authentication node to check if you are allowed to receive messages from this bot… Do you just want to send messages to telegram bot?
        To create a bot is really easy https://core.telegram.org/bots#3-how-do-i-create-a-bot

        You should restrict the messages to the bot to only your user id, nowadays it is much easier to get your user id: http://telegram.me/myidbot
        /getid

  11. Hi Pete,

    tried (and did) recently using the Telegram Bot together with node-red (MQTT not needed), in order to:

    1) if a certain event happens in node-red, send a specified message from the Telegram sender to the bot’s chat (i.e. home alarm switched ON/OFF), so I receive a notification on my phone wherevere I am
    2) send a simple text message from the bot’s chat (inside the Telegram smartphone app), grabbed by the Telegram node in node-red, then follow something planned in your flow. I’ve still have to dig a bit about using the APIs of the chatbots, to embed chatbots in personal apps

    Found useful this page: https://github.com/guidone/node-red-contrib-chatbot

    Andrea

  12. Hi,
    I use a TelegramBot (the client runs in a Raspberry Pi using a small python script), BUT I also installed a XMPP server on the same Pi (a small python script on the Pi handle my in/out XMLL messages. I use Pidgin in Windows/Ubuntu and Freelab Messenger on Android as clients too).

    Two ways to receive the important notifications from my home IoT…

    The nice thing about the Telegram Bot is that you can have ‘special keyboards’ (buttons) to send your own commands. You can also receive files, pictures, videos (as you would do with WhatsApp).

  13. always refused to use telegram (“everybody is on whatsapp”…), but then it’s time to start… the good about it is that you can generate BOTs that can auto answer some you ask them… very useful…

    http://flows.nodered.org/node/node-red-contrib-telegrambot
    https://github.com/guidone/node-red-contrib-chatbot
    http://ktinkerer.co.uk/setting-node-red-interact-telegram-bot/
    https://www.hackster.io/sergiol/telegram-bot-to-control-lightblue-bean-17ebe9

    problem with telegram: it’s a “cloud” service, while the mqtt plugin was/is a local one…

  14. Hi,

    I also tried to use the mqttclient for android in combination with automate (free alternative to tasker) and it also does not reconnect, even if I just want to publish something. Have you received feedback from the author? Do others have other alternatives?

    1. So two things Cinchet…

      1. Thanks for the heads up on Automate – wasn’t aware of that.
      2. Yes, see his GIT repository – I have opened an issue – he has confirmed he does not start up the app on power up (yes, well) – and he will fix that in the next release, yes I have asked him when. It would help immensely if you would go there – and add your voice and anyone elses… so he knows it is worthwhile speeding this up.

Comments are closed.