Freedom and Privacy, Nymea, Technology, Tutorial, Ubuntu Touch

Nymea Journey 3 – Making Some Stuff Work Without Smart Hardware

Not sure if you’re like me, but I like to try out some quick tests of a new system before I start buying hardware. My plan for the Nymea journey is first figure out how how to install it (covered here), then figure out how to be able to use it a bit before committing to server (covered here), then do some quick tests to make sure it works well enough using only open source software (that’s this blog now), and finally start buying some hardware including a server and the smart stuff (later).

In defense of the awesome team at Nymea (and trust me they are), I didn’t actually read the documentation before starting. This makes developers angry but on the other hand, it also exposes weaknesses in the user interface and also shows what users are thinking (or not thinking) so I wanted to go this route. There very well could be detailed instructions, but I was unable to find walk-throughs like the ones I’m doing here. In either case, always refer to the official documentation at nymea.io rather than my diary-blog 😉

Soft Testing

I just made this term now ‘soft testing’. It might exist or not, but I’m too lazy to search. What this means now is testing a hardware-based system (like Nymea) with software before buying hardware.

My testing hardware setup before soft-testing is:

a) Nymea:Core running on live USB Ubuntu installation with persistency (see my blog above if you want to do the same)

b) Nymea:App running on ubuntu touch

Now that I have the software up and running, I need something to test. What I’m planning to do for this part of the journey is figure out how to send myself an email notification if something happens…

Step One – Set up Email Notifications

In Nymea app as admin,

INSTALL THE PLUGIN

  1. Go to “Configure things’ in main menu
  2. + plus sign top right to ‘Set up new thing’
  3. In the search field type ‘mail’ and enter. This will fail because it’s not installed but will bring up an ‘install plugins’ button
  4. Select ‘install plugins’ button
  5. Hit the ‘x’ button by search field and type ‘mail’ again. You should see nymea-plugin-mailnotifications option.
  6. select that
  7. Select ‘install’ button

You may need to close / re-open your Nymea app to see the thing show up now (mail notification)

CONFIGURE THE PLUGIN

After installing the plugin, you need to configure it. This process will be training for how to ‘add things’ to your system. The way I think about it is like this: I’m going to ‘add a notification thing’. In order to add this ‘thing’ which is a notification, I do these steps from the dashboard of Nymea:App:

  1. Configure things
  2. Plus + icon top right
  3. In this ‘setup new thing’ menu, search ‘mail’ or ‘e-mail’ and the ‘E-mail notifications’ option should show up. If it doesn’t something went wrong in your installation of the plugin (see section above)
  4. Select it
  5. Sender mail: the the ‘from’ address of your notification. I just used the same email address since it’s both sending to and from this email address. This probably isn’t smart but .. it worked. ha
  6. Recipient: to whom the notification should send
  7. smtp server: your email server
  8. Port (the sending port): mine was 587 but yours could be 465 etc. Note: I’m using my own email server on yunohost which is another amazing project and ties in well with Nymea since it works perfectly for email notifications from Nymea in my experience
  9. Authentification: probably ‘login’ if you have username and password on your email
  10. encryption: typically ‘none’ but adjust according to your situation.
  11. Name the ‘notification thing’ according to what you’d like or leave it as default ‘E-mail notifications’
  12. ok

You should now see ’email notifications’ on your ‘configure things’ page

Step Two – Set up a thing that Can Notify you by Email – Weather!

I don’t have hardware yet, so I can’t trigger a sensor or anything cool and then have that thing email me, so I’m going to try to use a weather app for my local area and when the temperature hits a certain temperature, send me an email… not sure if this is possible, but I’m going to try… you can try a different path if you want by looking at the nymea integrations page…

The only option that had hope for me was the open weather map. I installed this plugin exactly the same way instructed above for the mail notification plugin.

IMPORTANT! For some reason I discovered that the plugin is in metric by default. However, my Nymea App was in imperial by default. I was trying to do ‘magic’ and would continually get this error:

Oh Snap! and unexpected error happened. We're sorry for that. Error code -1

It turns out the cause must have been that somehow these were conflicting because after I forced my Nymea app to be in metric, the ‘magic’ started working. I did that by doing the following steps which I would also recommend if you encounter errors:

  1. Main hamburger menu
  2. App settings
  3. Look & Feel
  4. Unit System: Change to ‘metric’ if set to ‘imperial’

Now that both Open Weather Map and Mail Notifications are installed, it’s time to do try adding ‘magic’.

Doing Some Notification ‘Magic’

Unfortunately this took me quite a while to figure out but to actually find out whether this weather app was installed I had to go to ‘configure things’ and then the + plus sign and there it was. I was expecting it to appear in the ‘add magic’ section right away but it wasn’t selectable. This makes sense because it should first be configured.

After opening up Open Weather App I am prompted for location in which I entered my city name and ‘next’ and it was in the list.

I was then prompted to name the thing. I called it ‘Delta Weather Info’ for now.

I am now given the message ‘Thing Added!” – this would explain why it wasn’t showing up in magic section – it wasn’t yet added, only installed.

After this process was complete, I also discovered ‘Delta Weather Info’ showing up as both a ‘Sensor’ device and a ‘Weather’ device – nice. That’s promising.

Adding ‘Magic’ (aka logic and events)

This nymea page about rules is worth a read first, by the way.

Upon selecting the ‘Magic’ button from the main menu, i’m greeted with ‘Add some magic’ button and a + sign in the top right. They both do the same thing


MAKE A CONDITION

  1. Magic
  2. Add some magic button (or plus sign top right) where you are presented with these three options:
  • Execute actions when something happens
  • Do something while a condition is met
  • Create a Scene
  1. In the ‘Do something while a condition is met” section, select the ‘Configure’ button. You will then be presented with the following three options:
  • When one of my things is in a certain state
  • When a thing of a given type enters a state
  • During a given time
  1. Select the second option: “When a thing of a given type enters a state”
  2. Select ‘Weather’
  3. Select ‘Temperature’
  4. Select ‘is greater than or equal to’ in drop down
  5. Select ‘a static value’ (instead of another thing’s state)
  6. Press plus button to select temperature 2 degrees lower than current temperature shown at open weather map for your city unless you have already reached your peak temperature for day in which case adjust however you like. This will make sure that the event triggers as ‘true’ right away instead of waiting. If you have time to kill you can adjust however you like…
  7. Ok button – you should see screen with your new condition in the ‘when this condition…’ section.

MAKE AN ACTION

  1. In the ‘…come true, execute those acions:’ section, select “Add an action” button.
    You will be presented with two options:
  • Execute an Action on one of my things
  • Execute an action on an entire kind of things
  1. Select the first option: “Execute an Action on one of my things”
  2. “E-mail Notifications’ from list
  3. “Send mail”
  4. For this test simply select: Use a static value as parameter (for subject)
  5. Enter ‘Weather temperature test subject’ into field as value
  6. For this test simply select: Use a static value as parameter (for body)
  7. Enter ‘Weather temperature test body’ into the field as value
  8. Select OK button

You should now be back at the page which should now show your condition and your action.

NAME, SAVE, AND EXECUTE IT

  1. At the top of page in the ‘Name:’ Field, enter: ‘Weather Temperature test TITLE’ for now. I used capital letters for TITLE so that I can easily see which parts do what in the notifications.
  2. Press ‘enter’ key on keyboard to get out of your keyboard
  3. Press the check mark icon in the top right to save everything

You should now see your magic / rule on the Magic page list

Note: The free version of Open Weather App has a 900 second (15 minute) cron job repetition to save resources. You should patiently wait about 20 minutes therefore to see what happens. You should hopefully receive your email notification by then if it’s working.


The example was pretty cool, except it didn’t work or was taking too long. That’s because I learned that Nymea counts decimals for temperature so I set 5 degrees but the temperature was not descending going low enough or quickly quickly enough. So I started again and in the ‘make a condition’ section above in step 7, to ‘greater or equal to’ and then in step 9, simply selected the current temperature showing on Open Weather Map. The goal here was not precision but simply to test to see if I can trigger an email notification so this is sufficient.

Seeing if the Magic Ran

This part also wasn’t super intuitive. But it’s very useful and important to know about this. My Telegram notificaitons were not working at the time of this blog (will hopefully publish a similar article on that one) but one (only) of my many test email notifications did go out. But why? And how do you know if the event even ran? The good news is once you know where it is, it’s pretty simple and quite nice to know.

  1. From main Nymea dashboard
  2. Scroll until you see ‘Notification Services’. You should see ‘2 things’ under it (or however many things you configured)
  3. Touch notification services tile / button
  4. You should see your ’email notifications’ as an option to select. Select it
  5. You should now see any / all notifications that have run. If they ran and failed, you would see a red triangle. This is what I saw for my Telegram notifications but the one email that ran seemed to work.

Note: another cool feature is that you can type (manually) a message to test with the Title / text fields and the send button at the top of this window. This is a good way to test to see if your email is set up properly to send. Try it out! If it fails you’ll probably have to go repeat / fix your email notification plugin setup.

Hope some or all of this helps

Tagged , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *