IBM Watson IoT Rules

  • 15 Jul, 2019

Rules are key elements for an IoT solution. Using rules you can trigger an action or send an alert any kind of notification. IBM update his platform and now you can create rules using a graphical interface.

The key part of a rule is the expression that will be evaluate to true or false.  The expression language are built using JSONata. JSONata is a lightweight query and transformation language for JSON data.

The point is that IBM are using JSONata v1.4x. and the current version of JSONata is v1.6.5. The versions have lots of difference. Yesterday i was writing a rule to get the hour for an event. If you are using v1.6.5 you can use the function $fromMilllis with picture. $fromMillis(1510067557121, ‘[H01]’, ‘-0500’) => “10” But Watson IoT are using v1.4x  and $fromMillis doesn’t have the picture implemented. The only way i found is to manipulate strings and i got the following expression:

$number($substring($fromMillis($state.datahora),11,1)) < 1 and $number($substring($fromMillis($state.datahora),12,1)) < 3 ? $number($substring($fromMillis($state.datahora),12,1))+24-3 : $number($substring($fromMillis($state.datahora),11,1))*10+ $number($substring($fromMillis($state.datahora),12,1))-3 $state.datahora returns an epoch timestamp. This expression returns the hour on my timezone (-3). If anyone have a more elegant solution post on comments. I know my solution can’t be the better one, but it works.

Related Posts

Proud to be an IBM Champion 2021

  • 14 Jan, 2021

This history began in 2011 when the category IBM Champions for Social Business was created.At that time there were only 50.  During the following years I was also nominated in other categories such as IBM Middleware, IBM Cloud and recently IBM Watson IoT.It is a journey of many years, a lot of learning and also knowledge sharing.!(http://www.mysphere.com.br/wp-content/uploads/2021/01/Screen-Shot-2021-01-14-at-13.57.14.png)

Proud to be an IBM Champion 2021Read More

AWS Lambda now supports container images as a packaging format

  • 03 Dec, 2020

You can now package and deploy AWS Lambda(https://aws.amazon.com/lambda/) functions as a container image of up to 10 GB. This makes it easy to build Lambda based applications using familiar container tooling, workflows, and dependencies. Just like functions packaged as ZIP archives, functions deployed as container images will benefit from AWS Lambda’s operational simplicity, automatic scaling with sub-second startup times, high availability, and native integrations with 140 AWS services. More information here(https://aws.amazon.com/about-aws/whats-new/2020/12/aws-lambda-now-supports-container-images-as-a-packaging-format/)

AWS Lambda now supports container images as a packaging formatRead More

VCP Driver for macOS Big Sur 11.0.x not available yet

  • 24 Nov, 2020

With new version of macOS released which is macOS Big Sur 11.0.x, the latest version of our VCP driver for Macintosh OSX (v5.3.5) now becomes incompatible. The reason for this is because of new driver model change on macOS which you can find more information from links below: https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11\0\1-release-notes https://developer.apple.com/support/kernel-extensions/ We currently are working to update our driver to fix this issue, although due to testing requirements, we do not expect the new version of driver to be available on our website for now. So please be up to date on our page for VCP drivers below for latest information r

VCP Driver for macOS Big Sur 11.0.x not available yetRead More