Showing results for 
Search instead for 
Did you mean: 

Can we create asset rules using API ?


Is it possible to create Rules through API?

Scenario - I have one aspect with “X” variable and i want to create rule for that variable. If “X” value is greter than 40 then event will be generated.



Re: Can we create asset rules using API ?

The rule API is currently undergoing the final polishing and it should be released soon for general use Smiley Happy

Re: Can we create asset rules using API ?

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

There are following options avaliable currently

1)  Use Data Flow Engine (DFE) services to create workflows (like creating events, sending email etc..) based on platform events and ingested data.

Please refer to following documentation and samples that creates events based on changes in timeseires data


Example below demonstrate sending email if variable value is less than thresold. However, you could follow sample  (as above) to create events also.


Creating a Stream for Filtering Messages according to a Condition

This sample shows how to create a stream using FilterProcessor processor for filtering messages, where a specific value does not fulfill a given condition. The stream shall only send an e-mail, if the value of revolutionPerMinute is greater than 1500.

TimeSeriesSource --entities=[{"id":"f7012b9215b448228def9726deffcfc9"}] | FilterProcessor --expression="newProperties.revolutionPerMinute > 1500" | EventSink --message-category-id=7070 --body'{"message":"The RPM value exceeded the 1500 value"}

The FilterProcessor of the stream defined above filters the incoming messages according the criterion of the defined parameter expression. If the expression is false, the message is discarded. In this example, the FilterProcessor proceeds the message, because the value of revolutionPerMinute is greater than 1500.

Filtering based on a combination of multiple expressions is possible. The following stream definition is a valid example:

TimeSeriesSource --entities=[{"id":"f7012b9215b448228def9726deffcfc9"}] | FilterProcessor --expression="newProperties.temperature < 50 || newProperties.temperature > 80" | EventSink --message-category-id=7070 --body'{"message":"The temperature value left the desired interval"}

The stream defined above only forwards messages, where the value of temperature is less than 50 or greater than 80.


2)  Subscribe to incoming timeseies data using Visual Flow Creator Mindsphere node - Subscribe Timeseries Node to perform event creation task if variable value exceeds certain threshold. The VFC doc for timeseries subscription is as per following doc