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.