Dummy device to generate Message?


#1

In short, I am trying to set up a simple “dummy” switch in ARTIK Cloud such that when I invoke it a message is generated that can be used in a rule so that I can perform an action on another device.

This is what I have done:

  1. I have manually added an “ARTIK Cloud Switch” to my device list (no physical device is present.). I’ll call this device “Dummy Switch”
  2. I have created a rule that sends an action to another device whenever a “state” field is included in a message for the Dummy Switch
  3. I send the “SetOn” action to the dummy device.

The action is successfully processed…so I was expecting the dummy device to send a message indicating the state is “true”…though perhaps because there is no physical device attached there is no message? Since there’s no message, the rule I created is not invoked.

So in short, how can I do what I want to do? That is, create a “dummy” switch (no physical device), such that when I invoke an action it generates a message that a rule can act on? Is there another standard device type that I can use…or do I need to learn how to develop my own?


#2

Hi Joseph,

My understanding to your question is that your rule has triggered with the following setup via your Rule Dashboard:

"IF" ("Field: State" on Device #1) / "THEN" (Send Acton `setOn`) to Device #2

However, you are wondering how to go about also updating Device #2 with {state:on} upon receiving the action.

You’ll need to develop a program that will implement this “setOn” action within your own developed program to update its field - ie: {state:true}

At this time Rules follow the following pattern (IF Field THEN Action), so a Rule cannot be used to update the Device Field.

//example:
IF "Device #1 (FIELD)" THEN "Device #2 (ACTION)"

I’ll see if we can get a sample up regarding this and will communicate to the team. However, you might find the following “websocket” documentation (below) as a good start. Below, also a “device simulator” console application so you can receives actions and manually send the “state:on” you wish (ie: act on device behalf)


websocket: https://developer.artik.cloud/documentation/api-reference/websockets-api.html
device simulator: https://developer.artik.cloud/documentation/tools/device-simulator.html


#3

[quote=“Jonathan_Paek_Artik, post:2, topic:2950”]
My understanding to your question is that…you are wondering how to go about also updating Device #2 with {state:on} upon receiving the action.[/quote]

That’s not quite what I’m asking. I’ll try and explain a little better. :slight_smile:

I want to create a “virtual” device that includes the SetOn action. (The “ARTIK Cloud Switch” is a device type that happens to be suitable).

So I merely “added” a new device to my ARTIK Cloud, based on the ARTIK Cloud Switch device type. I call this device “Dummy Switch”.

When I trigger the setOn action on the ARTIK Cloud Switch, I want this ARTIK Cloud Switch to generate a message in response to that action being invoked (much like a real device might do). That message would then be processed by my rule which sends a separate action to Device 2.

Does that make sense? I will try reading up on the topics you mentioned and educate myself more. If you want to know “why” I want to do this, I’ll gladly explain…it may prompt a solution that is different than the way I am trying to go about it.

Thanks for your response…I appreciate it!

Joe


#4

It looks like I was able to find a solution to my problem. I stumbled upon a device type that does exactly what I needed:

device Type: zz_Mock_Generic_Switch

I just added a new device with this device type to my ARTIK Cloud…and when I execute the setOn action, it generates a message containing {“state”:true}. No additional coding or set-up involved.

So why did I need to do this?

At the end of the day, I wanted to use an Amazon Alexa voice command to execute a Legrand lighting scene. This was the only way I could think of to do it:

  1. The Legrand lighting controller (hub device) and mobile app is integrated with my ARTIK cloud. So as I set up my lights and create lighting scenes with the mobile app, ARTIK cloud devices are created with several device types, including dimmers, switches and scenes.

  2. While Alexa integrates with ARTIK Cloud devices, it does not support all device type…it does not support the Legrand Scene device type. So using an Alexa voice command I cannot execute lighting scenes that I’ve created…even though the scene devices are sitting in my ARTIK cloud. I can, however, execute the scenes with an appropriate action and parameter using the ARTIK cloud directly.

  3. Because the “Mock Switch” has the “SetON” action with no parameters, Alexa supports this device like any other switch, using the “Turn On” voice command. Furthermore…when the setOn action is invoked, the mock switch generates a message with the value of the “state” variable.

  4. So…the Mock Switch can be invoked with an Alexa voice command (“Turn On…”) and because the mock switch generates a message, I can now effectively create an ARTIK Cloud rule to act on this message…and execute the action with a scene device. The execution path is thus:

Alexa Voice Command --> ARTIK Cloud Mock Switch --> Rule --> Execute Legrand Scene

This will have to do until when and if Alexa supports the ARTIK cloud “Legrand Scene” device type natively. I would be curious if anyone else sees another solution for this!


#5

If you are wondering if you can some how “bake” this update logic (ie: IF action, THEN message) directly into the ARTIK Cloud device, this is currently not available, however, team is aware of this for maybe future revisit.

At this time your 'custom" program should receive the “action” and then “send message” as a pattern for updating its fields (ie: state).

Note: the RULE dashboard allows IF (message), THEN action … but not the other way around. IF (action) THEN (message) for this reason.


#6

Yes, that is pretty much what I am wondering. Per my last post I found a different device type that has this update logic already baked in: zz_Mock_Generic_Switch…cloud.artik.mock.generic.commutator.

For now that device does what I need it to do. :slight_smile:


#7

Hi Joseph,

Thanks for your comments and sharing your experience.

This appears to be an older Device Type and does “bake” in the logic you stated:
(action triggers) => (auto update to message state field)


I learned recently it is made possible by creating a Cloud Connector Device Type, however, at this time not officially documented for this same purpose. You’re welcome to check out the cloud connector documentation below:

About Cloud Connector:
https://developer.artik.cloud/documentation/cloud-connectors/using-cloud-connectors.html

Implement Cloud Connector:
https://developer.artik.cloud/documentation/cloud-connectors/implement-a-cloud-connector.html


Would like to summarize your experience:

My understanding and summary of your experience:

  1. You need to “send an action” to your Legrand Panel (with no further programming), mainly to work around it not being discovered by the ARTIK Cloud Alexa Skill - at this time only discovering “switch on/off” like devices.

  2. Your intent is to use a different device (ie: zz_Mock_Generic_Switch) since it has on/off capabilities and can be discovered by Alexa.

  3. Since Rules are current constraint being triggered on “Messages”, rather than “Actions”, you needed above device to “auto update” its message field (ie: state) after receiving corresponding action. Since it has a baked in Rule: IF (Action), THEN (Message) you are able to relay this command via new custom rule to trigger a Legrand Scenes Action.

With above in place, you can now trigger the “Legrand Scenes Actions via Alexa” proxied through the switch device you have added.


#8

Hi Jonathan,
Your summary is indeed accurate. Thanks for the response…I will look
into cloud connectors and see if as an exercise I can create my own "mock"
device that does what I want.

FYI, another work-around I contemplated was to have IFTTT app act as an
intermediary between Alexa and ARTIK cloud and trigger the scene that way.
However, like the current Alexa skill, the Legrand scene device is not
exposed to IFTTT. The IFTTT app can currently only utilize ARTIK Cloud
device actions that do not take parameters. Because the Legrand scene
device actions require parameters I could not utilize IFTTT as an
intermediary between Alexa and ARTIK Cloud.

Finally, (if you’re interested) the Legrand device in question is:
“Legrand Adorne RFLC Scene”.


#9

Hi,

This is exactly what I am trying to accomplish using the “Dummy Switch”. I added the zz_Mock_Generic_Switch as a new switch, but am having trouble figuring out how to write the rule. Can you tell me how to write the rule step by step to activate a scene? Thank you.


#10

Hi Larry,
Sure, I can help. However, we need to first make sure that your “scenes” show up as devices in ARTIK cloud and that they function. Out of curiosity, what types of scenes are you trying to activate? (Legrand scenes? Some other lighting device?)

In my case, (Legrand RFLC Scnene), these scenes are added to my ARTIK cloud automatically when you set them up with Legrand’s mobile app. You can test your scenes by going into your ARTIK cloud device list, find the scene in your device list and then execute it.: Click on the lightning bolt (send action to device) for that specific scene device. You will be given a choice of actions to send from a drop down list. For legrand RFLC device scenes, the action is “execute”, with a value (you type this in) of “true”. If your device is not a legrand RFLC Scene, the action may be different.

Once you are able to successfully execute the scene manually from your ARTIK cloud, we can move on to the next step of creating a rule based on the dummy switch to activate the scene.


#11

Hi Joseph,

I think I may have figured it out. I am doing exactly as you are- trying to activate Legrand RFLC Scenes on my LC7001.

This is what I did.

  1. I made a scene called “Lights Out” in Legrand iPhone App to turn off all the lights at night.
  2. I made a zz_Mock_Generic_Switch on Artik cloud website called “All Lights”. You can make this name whatever you want Alexa to recognize to turn out the lights.
  3. I then made a rule as follows- If “All Lights” state “is in message”, then “Lights Out” execute state = true

Here is the description of the rule: IF All Lights state is present
THEN send to Lights Out the action execute with state = true‌

What is neat about this rule is that I can say- “Alexa, turn off all lights” because the rule is looking for any state in the message. I could also say “Alexa, turn on all the lights” (obviously, I wouldn’t do this) and the Legrand “Lights Out” scene will turn off all the lights. It is just more natural to me to say “turn off all lights”, rather than something like “Alexa, turn on lights out”.

Then I took this one step further to make an IFTTT recipe with multiple actions (which I think you have to pay extra for using IFTTT to get more than one “that” action to run)

  1. I made another zz_Mock_Generic_Switch on Artik cloud website called “Bedtime”

I made this rule:
IF Bedtime state is true
THEN send to All Lights the action setOn and Nest Master Bedroomthe action setTemperatureInFahrenheit with temp = 75‌

At bedtime, I say “Alexa, turn on bedtime”. This rule activates my “All Lights” mock switch (ie. runs my “lights out” scene in Legrand" and sets my Nest thermostat to 75 degrees.

This Artik cloud is so much more powerful than IFTTT app (and free). Let me know if this is what you did, or if there is anything I can do to improve. Thanks.

Larry


#12

Thank you Jonathan for referring me to this thread. Thank you Joseph for discovering the functionality I was asking for. I wish it came in a dimmer variant as well. I am controlling such mock switches through Google Home integration to turn on and off “scenes”. For example “hey google, turn off ‘indoor lights’”. The scenes are defined by ARTIK Cloud rules which can control multiple Legrand Adorne switches and scenes. The rules are triggered by turning on and off these mock switches. Thanks again.


#13

This thread was very useful to me, and I have a new question.

I’ve used the zz_Mock_Generic_Switch as described, as a proxy for Alexa to trigger something and an Artik Cloud rule to take action to activate an Adorne scene, amongst other things.

Like @Ross_Tyler I would like to have a dimmer version of this virtual device. Does something like this exist now? Actually, more generally, it would be helpful if Artik provided a general virtual device that one could configure with various fields. The reason for this is that such virtual devices can be useful for storing state that can be helpful for rules run later. Does something like this exist?

Example use case: want turning on LightA to set LightB to 100%, and turning off LightA to return LightB to the previous state and level. For this, one would like to have a virtualLightB, which does not have a physical device but can store state for later use.

Desired Implementation:

Rule 1: if LightA = on,
then (a) set virtualLightB.state = lightB.state; set virtualLightB.level = lightB.level;
then (b) set lightB.level = 100; lightB.state = true;

Rule 2: if LightB = off,
then setLightB.level = virtualLightB.level; setLightB.state = virtualLightB.state;

Note: currently, this can be partially implemented (successfully in real world) with zz_Mock_Generic_Switch, except that the dim state cannot be preserved because zz_Mock_Generic_Switch has state but no level.

As a related point, as a convention it would be practically helpful if Artik devices would, for the state variable, provide a setState(bool) rather than only setOn and setOff actions. Otherwise, the rules in the example above actually have to be implemented by duplicating the desired rules, with a condition on the state (say of lightB), using setOn and setOff in the action.


#14

The zz_Mock_Generic_Switch is an older Device Type in the earlier days of our platform.

Unfortunately, we do not have a similar variant available today, and also I am unable to comment for any plans to create a similar variants.

One solution, you could create and maintain your own running service, listening for changes in particular field (or action), and apply respective changes you need. You would also use your own custom Device Type.

Here is a suggestion which may help where B is a custom Device Type, which can hold a dimmer “level” and also hold a “previous” state:

B.on = true
B.level = 0.5  // Light is currently on at 0.5 setting.

//listen via websocket
1. IF( A=on), then (B.prev = B.level) //B:  store the current value to prev
2. IF( A=on), then (B.level = 1.0)    //B:  set to 100%.  Do this only after #1 completes.
IF( A=off), then (B.level  = B.prev)  //B:  restore to 0.5