Consider this scenario in ThingsBoard, default installation, single server:
There is only one device (for sake of simplicity) configured called "device_name", authenticated via token "device_token", no password. It already communicates successfully via MQTT with ThingsBoard and I already set up a small, working dashboard with a gauge and controls attached to the methods described below:
read_sensor, returns value from internal sensor (let's say, for example, ambient light); Not directly relevant to the question, included to make the scenario clear.
activate, turns on internal relay (controls lights, for example) and sets internal variable status to "on". Returns this variable.
deactivate, turns off internal relay and sets internal variable status to "off". Returns this variable.
toggle, turns internal relay on or off depending on previous value of the status variable based on "not" operation. Sets the status
variable to the opposite of previous value and returns it.
The question is "how do I call the methods activate and deactivate at specific dates/times (server time) of the day using ThingsBoard rules and plugins?"
Examples:
Call activate after 18:00 every weekday from monday to friday, but
not on saturdays and sundays.
Call deactivate after 08:00 every weekday from monday to friday,
but not on weekends.
I already set up and configured the Time, Telemetry and RPC system plugins.
There is an alternate configuration of the device with an extra method change(status) that turns on or off the relay based on the status provided, sets the internal variable to the value provided and returns it.
In the Thingsboard Professional Edition there is an action node "generator" that you can link to the PE feature "Scheduler". Within the scheduler it is possible to define an event being created according to a daily or weekly schedule.
For your application there would be two separate timers necessary for activation and deactivation. The events created must the be linked to a generator in your rule chain to trigger method execution.
Related
The subject is:
I have connected one of my processes to an external sql database through Database Connection( very hard of course due to lack of sql connection!). In my dynaform i have two textbox that are named RefNumber and Value and also i have a button. i want to enter a number in RefNumber and press the button and related value to that number appears in Value (i have that number and its corresponding value in my database that i earlier connected).
So the first question is : Which one should i use ?Trigger or Javascript?
and the second question: what is the code?
Any comment is appreciated.
It depends on you whether you want to update your value at database side or backend side.
Also I would like to add that trigger sometimes fail due to bad connection issues or some random user shit error and it might happen that your data is updated and value is not incremented(updated). So I recommend not to use trigger, yes trigger saves time but sometimes it doesn't work.
And benefit of doing it at backend side is that if your data is not updated, failed, value will also not.
My solution is to create an API on server app processmaker(use plugin to create api). Or the server BackEnd will configure CORS enabled so that the client side can call the api.
In dynaform, use ajax to make request to api.
I have freeradius server installed on centos 6 with MySQL and Mikrotik as a controller.
I want to restrict the user to use internet according to billing plan like use internet for 1 hour in 3 days. After 3 days the same username should get again 1 hour for next 3 days.
Please suggest which modification should I need to do in radius configuration and which parameters should I send.
A Session-Time attribute will set the maximum time a session may take. This does not account for other rules like a maximum time over a day or a week. You need more logic for this than an attribute in your RADIUS reply.
A stateful storage is needed to keep track of the used time for a user. RADIUS accounting is sufficient for this purpose. For example, when storing accounting data in MySQL you can query the already used session time for a period to calculate a new Session-Time for the upcoming session.
You can use Radclient to disconnect sessions in Mikrotik.
FreeRADIUS has modules for this purpose: sqlcounter and counter. The documentation covers examples of implementation.
I am testing the how publisher confirm works in Spring-AMQP, trying to find How to control max unconfirmed publishes using Spring AMQP?
Basically i want pause publisher when unconfirmed messages count is greater than some limit.
it seems rabbitTemplate.getUnconfirmed(age) gives list of unconfirmed messages but it removes them from unconfirmed list once method is called.
Yes; we don't currently have an API for that, getUnconfirned(age) is intended to expire pending confirms older than an age.
We should probably add an overloaded method (with no argument) which just gets the unconfirmed correlation data, or a method that just returns the number of such.
Feel free to open an "improvement" JIRA Issue and we should be able to get something in the next release.
I have implemented a chat feature using ActionCable. I am now trying to implement a presence status based on the implementation of user appearances in the README.
This documentation mention the following statement:
The #subscribed callback is invoked when, as we'll show below, a
client-side subscription is initiated. In this case, we take that
opportunity to say "the current user has indeed appeared". That
appear/disappear API could be backed by Redis or a database or
whatever else.
I can implement an online attribute in my database and update it when the application receives appear/disappear notifications. But I have no guarantee about the reliability of this attribute. It could become out of sync in case of a server failure for example.
How could I implement this in a reliable way?
Place it in a Redis structure that expires in a certain amount of time (use TTL). If you store it somewhere for an infinite amount of time (like the DB) it can go out of sync. You might argue that you can set all user presence to false on application startup, but that will only work until you run multiple servers or workers. While a user is connected: insert a presence value for this user into Redis every few minutes. Also handle the connection close event to delete the user presence from Redis for higher accuracy than a few minutes.
Our system has two servers (S1) one is running processesing and data storage (basically DB) and the other one is a webserver (WS).
There are two types of even that can happen in the system:
User A pings User B. In this case we check if user B is logged in and we push a notification to User B client throw SignalR. It works.
Services constantly running on S1 and generating new data that concenrs multiple users. My goal is as soon as a new data important for user A is generated I immediately want to dispatch a signalR notification to user A client provided he/she is logged in.
This part 2 is not quite clear for me how to design. My thought right now is to start an indefinite process on webserves that monitors our DataBase and checks if new records are generated fpr this user and then push a SignalR message.
That would be fine, but now we have 10k users logged in and I don't think the right decision would be run 10k threads monitoring activities.
Basically, my question is what would a proper way do design signalR based notification mechanism that is based on events that are not originated on our webserver.
I would use a service bus or mq, for example this Free MQ https://www.rabbitmq.com/
You can proxy the messages direcly to the Clients using this proxy library (I'm the author).
Doc's here https://github.com/AndersMalmgren/SignalR.EventAggregatorProxy/wiki
Demo https://github.com/AndersMalmgren/SignalR.EventAggregatorProxy/tree/master/SignalR.EventAggregatorProxy.Demo.MVC4
You can also set up a sql dependency that triggers a message to your signalr clients,
http://techbrij.com/database-change-notifications-asp-net-signalr-sqldependency
This link is the one that I based my code on.
couple of things to watch for, the setup of the table. You cannot use 3 part table names
"SELECT [CMRID],
[SolutionID],
[CreateDT],
[ModifyDT]
**FROM [dbo].[Case]**
WHERE [ModifyDT] > " + LastExecutionDateTime;
Also, and this is very important, you MUST reset the event handler every time the dependency triggers, if not it will work the first time and then stop working.
I hope this helps you.