The Scheduled MQTT control is meant for scheduled messages ahead of time. For live control, see Live MQTT Control instead.
This guide will help you configure MQTT on your Sofar EMS to remotely control and monitor battery and solar panel installations.
This guide will help you configure MQTT on your Sofar EMS to remotely control and monitor battery and solar panel installations.
I have a Sofar EMS that I'd like to setup for MQTT Remote Control.
Before continuing, make sure your network and devices are ready by following the MQTT Setup guide.
Request the required Eniris MQTT username and password through the distributor before starting the configuration.
Select all devices that you'd wish to include in MQTT Remote Control.
The MQTT Remote Control interface has now been activated on the Sofar EMS.
We are now ready to send some basics commands using a simple example. The Status column tells you if any command is active.
A good first starting point would be to test your newly setup integration with a simple example.
This test code does a simple job of continuously sending the following schedule:
The Sofar EMS responds with an acknowledgement message containing the unique schedule identifier, or an error message.
We then fetch the next schedule for both device types, confirming that the command was successful.
Please download the file below in your preferred Python IDE. Fill in your serial number and the MQTT credentials requested through the distributor, then execute the script:
When the above is successful, you can continue with sending other type of messages. All messages are described below.
This section details the MQTT messaging format and payload requirements for setting up scheduled control of devices within the Sofar EMS's network.
standard1/rp_one_s/remoteScheduleMetrics/<controller SN>standard1/outbound/remoteScheduleMetrics/feedback/<controller SN>Where <controller SN> should be replaced with the actual serial number of the Sofar EMS you intend to control.
set_schedule)Creates a new schedule for a device type.
{
"extraTags": {
"nodeId": "<Controller SN>_site_0"
},
"time": <Unix Timestamp>,
"message_type": "set_schedule",
"fields": {
"device_type": "<Device Type>",
"node_id": "<Node ID>" (Optional),
"start_time": <Unix Timestamp>,
"end_time": <Unix Timestamp>,
"policy": "<Policy>",
"power_setpoint_w": <Setpoint in watts>,
"site_import": <Site Import in Watts>,
"site_export": <Site Export in Watts>,
"remove_overlap": <True/False> (Optional) (default=False),
"tag": <Tag String> (Optional) (default=None),
}
}
Response (Success):
{
"requestTime": <Unix Timestamp>,
"time": <Unix Timestamp>,
"siteNodeId": "<Controller SN>_site_0",
"data": {
"message_type": "set_schedule_ack",
"state": {
"schedule_id": <Schedule ID>,
"deleted_ids": <Schedulde IDs deleted if remove_overlap=True>
"tag": <Tag String> (default=None),
},
"responseCode": 0
}
}
set_schedules)Creates multiple new schedules.
{
"extraTags": {
"nodeId": "<Controller SN>_site_0"
},
"time": <Unix Timestamp>,
"message_type": "set_schedules",
"fields":
"0": "{
"device_type": "<Device Type>",
"node_id": "<Node ID>" (Optional),
"start_time": <Unix Timestamp>,
"end_time": <Unix Timestamp>,
"policy": "<Policy>",
"power_setpoint_w": <Setpoint in watts>,
"site_import": <Site Import in Watts>,
"site_export": <Site Export in Watts>,
"remove_overlap": <True/False> (Optional) (default=False),
}",
"1": "{
"device_type": "<Device Type>",
"node_id": "<Node ID>" (Optional),
"start_time": <Unix Timestamp>,
"end_time": <Unix Timestamp>,
"policy": "<Policy>",
"power_setpoint_w": <Setpoint in watts>,
"site_import": <Site Import in Watts>,
"site_export": <Site Export in Watts>,
"remove_overlap": <True/False> (Optional) (default=False),
}",
...
}
Response (Success):
{
"requestTime": <Unix Timestamp>,
"time": <Unix Timestamp>,
"siteNodeId": "<Controller SN>_site_0",
"data": {
"message_type": "set_schedules_ack",
"state": {
"schedule_ids": <Schedule IDs>,
"deleted_ids": <Schedulde IDs deleted if remove_overlap=True>
},
"responseCode": 0
}
}
get_schedule)Retrieves a specific schedule by ID.
{
"extraTags": {
"nodeId": "<Controller SN>_site_0"
},
"time": <Unix Timestamp>,
"message_type": "get_schedule",
"fields": {
"id": <Schedule ID>
}
}
Response:
{
"requestTime": <Unix Timestamp>,
"time": <Unix Timestamp>,
"siteNodeId": "<Controller SN>_site_0",
"data": {
"message_type": "get_schedule_ack",
"state": <Schedule>,
"responseCode": 0
}
}
get_active_schedule)Retrieves the currently active schedule for a device type.
{
"extraTags": {
"nodeId": "<Controller SN>_site_0"
},
"time": <Unix Timestamp>,
"message_type": "get_active_schedule",
"fields": {
"device_type": "<Device Type>",
"node_id": "<Node ID>" (Optional),
}
}
Response (Success):
{
"requestTime": <Unix Timestamp>,
"time": <Unix Timestamp>,
"siteNodeId": "<Controller SN>_site_0",
"data": {
"message_type": "get_active_schedule_ack",
"state": <Schedule>,
"responseCode": 0
}
}
get_next_schedule)Retrieves the next upcoming schedule for a device type.
{
"extraTags": {
"nodeId": "<Controller SN>_site_0"
},
"time": <Unix Timestamp>,
"message_type": "get_next_schedule",
"fields": {
"device_type": "<Device Type>",
"node_id": "<Node ID>" (Optional),
}
}
Response (Success):
{
"requestTime": <Unix Timestamp>,
"time": <Unix Timestamp>,
"siteNodeId": "<Controller SN>_site_0",
"data": {
"message_type": "get_next_schedule_ack",
"state": <Schedule>,
"responseCode": 0
}
}
get_schedules)Retrieves all schedules for a specific date.
{
"extraTags": {
"nodeId": "<Controller SN>_site_0"
},
"time": <Unix Timestamp>,
"message_type": "get_schedules",
"fields": {
"date": "<Date String of Format dd/mm/yyyy>"
}
}
Response (Success):
{
"requestTime": <Unix Timestamp>,
"time": <Unix Timestamp>,
"siteNodeId": "<Controller SN>_site_0",
"data": {
"message_type": "get_schedules_ack",
"state": {
"schedules": [<Schedule>, ...]
},
"responseCode": 0
}
}
get_future_schedules)Retrieves all future schedules.
{
"extraTags": {
"nodeId": "<Controller SN>_site_0"
},
"time": <Unix Timestamp>,
"message_type": "get_future_schedules",
"fields": {}
}
Response (Success):
{
"requestTime": <Unix Timestamp>,
"time": <Unix Timestamp>,
"siteNodeId": "<Controller SN>_site_0",
"data": {
"message_type": "get_future_schedules_ack",
"state": {
"schedules": [<Schedule>, ...]
},
"responseCode": 0
}
}
remove_schedule)Removes a specific schedule by ID.
{
"extraTags": {
"nodeId": "<Controller SN>_site_0"
},
"time": <Unix Timestamp>,
"message_type": "remove_schedule",
"fields": {
"id": <Schedule ID>
}
}
Response (Success):
{
"requestTime": <Unix Timestamp>,
"time": <Unix Timestamp>,
"siteNodeId": "<Controller SN>_site_0",
"data": {
"message_type": "remove_schedule_ack",
"state": "Schedule <Schedule ID> removed successfully",
"responseCode": 0
}
}
get_feedback)Retrieves detailed feedback on the state of the system.
{
"extraTags": {
"nodeId": "<Controller SN>_site_0"
},
"time": <Unix Timestamp>,
"message_type": "get_feedback",
"fields": {
"device": <Device (node) level>
}
}
Response (Success):
get_toplogy)Gets the topology of the site.
{
"extraTags": {
"nodeId": "<Controller SN>_site_0"
},
"time": <Unix Timestamp>,
"message_type": "get_topology",
"fields": {}
}
Response (Success):
{
"requestTime": <Unix Timestamp>,
"time": <Unix Timestamp>,
"siteNodeId": "<Controller SN>_site_0",
"data": {
"message_type": "get_topology_ack",
"state": {
"nodeId": <nodeId>,
"isControllable": <boolean>,
"nodeType": <nodeType>,
"nomCurrent": <nominalCurrent>
"children": [{<ChildObject>}]
},
"responseCode": 0
}
}
{
"id": <Schedule ID>,
"device_type": "<Device Type>",
"node_id": "<Node ID>" (Optional),
"start_time": <Unix Timestamp>,
"end_time": <Unix Timestamp>,
"policy": "<Schedule Policy>",
"power_setpoint_w": <Setpoint in watts>,
"created_at": <Unix Timestamp>
}
For details about available components and policies that can be scheduled, refer to the MQTT Components and Policies section in the Live MQTT Control documentation.
Device-specific schedules can be sent using the optional node_id field, referring to the node ID of the controllable device.
All messages can return an error response with responseCode: 1 when an error occurs:
{
"requestTime": <Unix Timestamp>,
"time": <Unix Timestamp>,
"siteNodeId": "<Controller SN>_site_0",
"data": {
"message_type": "<Message Type>_ack",
"error": <Error Body>,
"responseCode": 1
}
}
When an unrelated error occurs, the message type will be (general_error).
Common errors include:
remove_overlap variable is set to True when creating a new schedule.