element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Upcycle It
  • Challenges & Projects
  • Design Challenges
  • Upcycle It
  • More
  • Cancel
Upcycle It
Blog [Upcycle It] WiFi Connected Smoke Detector #7: Translating Alarms
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: vlasov01
  • Date Created: 7 May 2017 1:50 AM Date Created
  • Views 2494 views
  • Likes 1 like
  • Comments 6 comments
  • mqtt
  • rules engine
  • sonoff
  • decision table
  • translators
Related
Recommended

[Upcycle It] WiFi Connected Smoke Detector #7: Translating Alarms

vlasov01
vlasov01
7 May 2017
<< Previous

Project Index

Next>>

 

New questions and solutions

 

As I start thinking about integration with connected appliances in more details I realized that I havent address yet the following challenges.

1. How communicate to any MQTT connected device, that can understand switch off/on commands?

There is no standards for MQTT topics in IoT space. There are best practices for topics naming, but it is not necessary followed.

Sonoff devices are not following these recommendations. So to turn off Sonoff device the following topic and command should be used: cmnd/sonoff/power off.

I've defined my topic structure as been described in one of my previous blogs [Upcycle It] WiFi Connected Smoke Detector #3: Connecting dots - MQTT + Node.js + Slack based on best practices.

So, a command to turn off socket 1 of PDU in a workshop will look like:

workshop/appliance/pdu-socket1/power off

A command to turn off outlet 1 in a workshop will be:

workshop/appliance/outlet1/power off

It is clear that a translator is required to map them.

Upcycle topic/commandSonoff topic/command
workshop/appliance/outlet1/power offcmnd/sonoff/power1 off

 

2. How to publish command to multiple connected appliances/sockets/outlets?

MQTT publication doesn't supports wildcards. Wildcards only supported for subscriptions. It means that a command to switch off power should be published to different topics for a different connected devices. should listen to a generic command for the location.

My approach to this challenge is to split it in two parts. I've defined a special appliance id - all. So to substitute a wildcard gap in MQTT publication I can just publish a command to all appliances workshop/appliance/all/power off . It only helps partially as most of the appliances will not be smart enough to listen to several topics for a command. So the second part of the solution is to map one incoming publication to many predefined topics, so we can control several appliances. In addition, it possible that someone would like to switch lights on to support evacuation process as been suggested by rhe123 .

Upcycle topic/commandSonoff topic/command
workshop/appliance/all/power offcmnd/sonoff/power1 off
cmnd/sonoff/power2 off
cmnd/sonoff/light on

 

Mapping and translation will not be required in all cases. So I've decided to make it as a separate optional process "Publication Translation Processing".

image

This approach for integration now need to be confirmed with jasonwier92, so we can have an integrated solution.

 

Translation and Mapping decision

Now I need to decide to keep it simple and just code mapping/translation or find library that already implemented these capabilities.

I've looked briefly and found the following Node.js projects, that can satisfy these requirements:

Decision table and BizRez Rules . Both projects haven't been updated for at least a year and have no collaborators besides their authors.

Next step is to try them and see if they really simplify solution by externalizing mapping and translation in configuration file or make solution more complex to maintain.

  • Sign in to reply

Top Comments

  • DAB
    DAB over 8 years ago +1
    Nice update. I have found that anytime you deal with legacy hardware or software it is always useful to build a mapping table so that you can better define your actions for inputs and outputs. Putting…
  • Jan Cumps
    Jan Cumps over 8 years ago +1
    when I need a command interpreter, I usually go for a scpi library. Not too resource hungry, works with callbacks, has a solution for commands like cmnd:sonoff: power1 ON, power2, powerN.
Parents
  • mcb1
    mcb1 over 8 years ago

    It's always the little extra parts of these things that make what seems very simple, into something more complicated.

     

    It's also nice to see some of the sugestions coming from readers.

     

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • mcb1
    mcb1 over 8 years ago

    It's always the little extra parts of these things that make what seems very simple, into something more complicated.

     

    It's also nice to see some of the sugestions coming from readers.

     

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube