Skip to content

Commit

Permalink
Add support for VSENSOR in MQTT Client.
Browse files Browse the repository at this point in the history
New commands:
 - SYS:MQTT:INT:VSENSOR
 - SYS:MQTT:INT:VSENSOR?
 - SYS:MQTT:MASK:VTEMP
 - SYS:MQTT:MASK:VTEMP?
 - SYS:MQTT:MASK:VHUM
 - SYS:MQTT:MASK:VHUM?
 - SYS:MQTT:MASK:VPRE
 - SYS:MQTT:MASK:VPRE?
 - SYS:MQTT:TOPIC:VTEMP
 - SYS:MQTT:TOPIC:VTEMP?
 - SYS:MQTT:TOPIC:VHUM
 - SYS:MQTT:TOPIC:VHUM?
 - SYS:MQTT:TOPIC:VPRE
 - SYS:MQTT:TOPIC:VPRE?
  • Loading branch information
tjko committed Sep 19, 2024
1 parent 9fa215d commit f7a9e9e
Show file tree
Hide file tree
Showing 6 changed files with 399 additions and 1 deletion.
186 changes: 185 additions & 1 deletion commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,20 @@ Fanpico supports following commands:
* [SYStem:MQTT:INTerval:STATUS?](#systemmqttintervalstatus-1)
* [SYStem:MQTT:INTerval:TEMP](#systemmqttintervaltemp)
* [SYStem:MQTT:INTerval:TEMP?](#systemmqttintervaltemp-1)
* [SYStem:MQTT:INTerval:VSENsor](#systemmqttintervalvsensor)
* [SYStem:MQTT:INTerval:VSENsor?](#systemmqttintervalvsensor-1)
* [SYStem:MQTT:INTerval:RPM](#systemmqttintervalrpm)
* [SYStem:MQTT:INTerval:RPM?](#systemmqttintervalrpm-1)
* [SYStem:MQTT:INTerval:PWM](#systemmqttintervalpwm)
* [SYStem:MQTT:INTerval:PWM?](#systemmqttintervalpwm-1)
* [SYStem:MQTT:MASK:TEMP](#systemmqttmasktemp)
* [SYStem:MQTT:MASK:TEMP?](#systemmqttmasktemp-1)
* [SYStem:MQTT:MASK:VTEMP](#systemmqttmaskvtemp)
* [SYStem:MQTT:MASK:VTEMP?](#systemmqttmaskvtemp-1)
* [SYStem:MQTT:MASK:VHUMidity](#systemmqttmaskvhumidity)
* [SYStem:MQTT:MASK:VHUMidity?](#systemmqttmaskvhumidity-1)
* [SYStem:MQTT:MASK:VPREssure](#systemmqttmaskvpressure)
* [SYStem:MQTT:MASK:VPREssure?](#systemmqttmaskvpressure-1)
* [SYStem:MQTT:MASK:FANRPM](#systemmqttmaskfanrpm)
* [SYStem:MQTT:MASK:FANRPM?](#systemmqttmaskfanrpm-1)
* [SYStem:MQTT:MASK:FANPWM](#systemmqttmaskfanpwm)
Expand All @@ -167,6 +175,12 @@ Fanpico supports following commands:
* [SYStem:MQTT:TOPIC:RESPonse?](#systemmqttopicresponse-1)
* [SYStem:MQTT:TOPIC:TEMP](#systemmqtttopictemp)
* [SYStem:MQTT:TOPIC:TEMP?](#systemmqttopictemp-1)
* [SYStem:MQTT:TOPIC:VTEMP](#systemmqtttopicvtemp)
* [SYStem:MQTT:TOPIC:VTEMP?](#systemmqttopicvtemp-1)
* [SYStem:MQTT:TOPIC:VHUMidity](#systemmqtttopicvhumidity)
* [SYStem:MQTT:TOPIC:VHUMidity?](#systemmqttopicvhumidity-1)
* [SYStem:MQTT:TOPIC:VPREssure](#systemmqtttopicvpressure)
* [SYStem:MQTT:TOPIC:VPREssure?](#systemmqttopicvpressure-1)
* [SYStem:MQTT:TOPIC:FANRPM](#systemmqtttopicfanrpm)
* [SYStem:MQTT:TOPIC:FANRPM?](#systemmqttopicfanrpm-1)
* [SYStem:MQTT:TOPIC:FANPWM](#systemmqtttopicfanpwm)
Expand Down Expand Up @@ -2254,6 +2268,29 @@ SYS:MQTT:INT:TEMP?
```


#### SYStem:MQTT:INTerval:VSENsor
Configure how often unit will publish (send) virtual sensor status messages.
Set this to 0 (seconds) to disable publishing status updates.
Recommended values are 60 (seconds) or higher.

Default: 0 (disabled)

Example:
```
SYS:MQTT:INT:VSEN 60
```


#### SYStem:MQTT:INTerval:VSENsor?
Query how often unit is setup to publish virtual sensor status messages.

Example:
```
SYS:MQTT:INT:VSENP?
60
```


#### SYStem:MQTT:INTerval:RPM
Configure how often unit will publish (send) RPM status updates for
fans (and mbfans).
Expand Down Expand Up @@ -2328,6 +2365,78 @@ SYS:MQTT:MASK:TEMP?
```


#### SYStem:MQTT:MASK:VTEMP
Configure which virtual sensors should publish (send) temperature data to MQTT server.

Sensors can be specified as comma separated list (2,3) or as range (1-3)
or as combination of both.

Default: <empty> (do not publish data from any sensor)

Example:
```
SYS:MQTT:MASK:VTEMP 1,2,3,4
```


#### SYStem:MQTT:MASK:VTEMP?
Query which virtual sensors are configured to publish (send) temperature data to MQTT server.

Example:
```
SYS:MQTT:MASK:VTEMP?
1-4
```


#### SYStem:MQTT:MASK:VHUMidity
Configure which virtual sensors should publish (send) humidity data to MQTT server.

Sensors can be specified as comma separated list (2,3) or as range (1-3)
or as combination of both.

Default: <empty> (do not publish data from any sensor)

Example:
```
SYS:MQTT:MASK:VHUM 1,2
```


#### SYStem:MQTT:MASK:VHUMidity?
Query which virtual sensors are configured to publish (send) humidity data to MQTT server.

Example:
```
SYS:MQTT:MASK:VHUM?
1-2
```


#### SYStem:MQTT:MASK:VPREssure
Configure which virtual sensors should publish (send) pressure data to MQTT server.

Sensors can be specified as comma separated list (2,3) or as range (1-3)
or as combination of both.

Default: <empty> (do not publish data from any sensor)

Example:
```
SYS:MQTT:MASK:VPRE 1,2
```


#### SYStem:MQTT:MASK:VPREssure?
Query which virtual sensors are configured to publish (send) pressure data to MQTT server.

Example:
```
SYS:MQTT:MASK:VPRE?
1-2
```


#### SYStem:MQTT:MASK:FANRPM
Configure which fan ports should publish (send) RPM data to MQTT server.

Expand Down Expand Up @@ -2502,7 +2611,7 @@ Default: <empty>

Example:
```
SYS:MQTT:TOPIC:TEMP musername/feeds/temp%d
SYS:MQTT:TOPIC:TEMP mysername/feeds/temp%d
```


Expand All @@ -2516,6 +2625,81 @@ myusername/feeds/temp%d
```


#### SYStem:MQTT:TOPIC:VTEMP
Configure topic template for publishing virtual sensor temperature data to.
If this is left to empty, then unit won't send response to any commands.

This is template string where ```%d``` should be used to mark the port number.


Default: <empty>

Example:
```
SYS:MQTT:TOPIC:VTEMP mysername/feeds/vtemp%d
```


#### SYStem:MQTT:TOPIC:VTEMP?
Query currently set topic template for virtual sensor temperature data.

Example:
```
SYS:MQTT:TOPIC:VTEMP?
myusername/feeds/vtemp%d
```


#### SYStem:MQTT:TOPIC:VHUMidity
Configure topic template for publishing virtual sensor humidity data to.
If this is left to empty, then unit won't send response to any commands.

This is template string where ```%d``` should be used to mark the port number.


Default: <empty>

Example:
```
SYS:MQTT:TOPIC:VHUM mysername/feeds/humidity%d
```


#### SYStem:MQTT:TOPIC:VHUMidity?
Query currently set topic template for virtual sensor humidity data.

Example:
```
SYS:MQTT:TOPIC:VHUM?
myusername/feeds/humidity%d
```


#### SYStem:MQTT:TOPIC:VPREssure
Configure topic template for publishing virtual sensor pressure data to.
If this is left to empty, then unit won't send response to any commands.

This is template string where ```%d``` should be used to mark the port number.


Default: <empty>

Example:
```
SYS:MQTT:TOPIC:VPRE mysername/feeds/pressure%d
```


#### SYStem:MQTT:TOPIC:VPREssure?
Query currently set topic template for virtual sensor pressure data.

Example:
```
SYS:MQTT:TOPIC:VPRE?
myusername/feeds/pressure%d
```


#### SYStem:MQTT:TOPIC:FANRPM
Configure topic template for publishing fan RPM data to.
If this is left to empty, then unit won't send response to any commands.
Expand Down
55 changes: 55 additions & 0 deletions src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -2275,6 +2275,12 @@ int cmd_mqtt_temp_interval(const char *cmd, const char *args, int query, struct
&conf->mqtt_temp_interval, 0, (86400 * 30), "MQTT Publish Temp Interval");
}

int cmd_mqtt_vsensor_interval(const char *cmd, const char *args, int query, struct prev_cmd_t *prev_cmd)
{
return uint32_setting(cmd, args, query, prev_cmd,
&conf->mqtt_vsensor_interval, 0, (86400 * 30), "MQTT Publish VSENSOR Interval");
}

int cmd_mqtt_rpm_interval(const char *cmd, const char *args, int query, struct prev_cmd_t *prev_cmd)
{
return uint32_setting(cmd, args, query, prev_cmd,
Expand Down Expand Up @@ -2321,6 +2327,27 @@ int cmd_mqtt_temp_topic(const char *cmd, const char *args, int query, struct pre
sizeof(conf->mqtt_temp_topic), "MQTT Temperature Topic", NULL);
}

int cmd_mqtt_vtemp_topic(const char *cmd, const char *args, int query, struct prev_cmd_t *prev_cmd)
{
return string_setting(cmd, args, query, prev_cmd,
conf->mqtt_vtemp_topic,
sizeof(conf->mqtt_vtemp_topic), "MQTT VTemperature Topic", NULL);
}

int cmd_mqtt_vhumidity_topic(const char *cmd, const char *args, int query, struct prev_cmd_t *prev_cmd)
{
return string_setting(cmd, args, query, prev_cmd,
conf->mqtt_vhumidity_topic,
sizeof(conf->mqtt_vhumidity_topic), "MQTT VHumidity Topic", NULL);
}

int cmd_mqtt_vpressure_topic(const char *cmd, const char *args, int query, struct prev_cmd_t *prev_cmd)
{
return string_setting(cmd, args, query, prev_cmd,
conf->mqtt_vpressure_topic,
sizeof(conf->mqtt_vpressure_topic), "MQTT VPressure Topic", NULL);
}

int cmd_mqtt_fan_rpm_topic(const char *cmd, const char *args, int query, struct prev_cmd_t *prev_cmd)
{
return string_setting(cmd, args, query, prev_cmd,
Expand Down Expand Up @@ -2363,6 +2390,27 @@ int cmd_mqtt_mask_temp(const char *cmd, const char *args, int query, struct prev
1, "MQTT Temperature Mask");
}

int cmd_mqtt_mask_vtemp(const char *cmd, const char *args, int query, struct prev_cmd_t *prev_cmd)
{
return bitmask16_setting(cmd, args, query, prev_cmd,
&conf->mqtt_vtemp_mask, VSENSOR_MAX_COUNT,
1, "MQTT VSENSOR Temperature Mask");
}

int cmd_mqtt_mask_vhumidity(const char *cmd, const char *args, int query, struct prev_cmd_t *prev_cmd)
{
return bitmask16_setting(cmd, args, query, prev_cmd,
&conf->mqtt_vhumidity_mask, VSENSOR_MAX_COUNT,
1, "MQTT VSENSOR Humidity Mask");
}

int cmd_mqtt_mask_vpressure(const char *cmd, const char *args, int query, struct prev_cmd_t *prev_cmd)
{
return bitmask16_setting(cmd, args, query, prev_cmd,
&conf->mqtt_vpressure_mask, VSENSOR_MAX_COUNT,
1, "MQTT VSENSOR Pressure Mask");
}

int cmd_mqtt_mask_fan_rpm(const char *cmd, const char *args, int query, struct prev_cmd_t *prev_cmd)
{
return bitmask16_setting(cmd, args, query, prev_cmd,
Expand Down Expand Up @@ -2864,6 +2912,9 @@ const struct cmd_t wifi_commands[] = {
#ifdef WIFI_SUPPORT
const struct cmd_t mqtt_mask_commands[] = {
{ "TEMP", 4, NULL, cmd_mqtt_mask_temp },
{ "VTEMP", 5, NULL, cmd_mqtt_mask_vtemp },
{ "VHUMidity", 4, NULL, cmd_mqtt_mask_vhumidity },
{ "VPREssure", 4, NULL, cmd_mqtt_mask_vpressure },
{ "FANRPM", 6, NULL, cmd_mqtt_mask_fan_rpm },
{ "FANPWM", 6, NULL, cmd_mqtt_mask_fan_duty },
{ "MBFANRPM", 8, NULL, cmd_mqtt_mask_mbfan_rpm },
Expand All @@ -2874,6 +2925,7 @@ const struct cmd_t mqtt_mask_commands[] = {
const struct cmd_t mqtt_interval_commands[] = {
{ "STATUS", 6, NULL, cmd_mqtt_status_interval },
{ "TEMP", 4, NULL, cmd_mqtt_temp_interval },
{ "VSENsor", 4, NULL, cmd_mqtt_vsensor_interval },
{ "RPM", 3, NULL, cmd_mqtt_rpm_interval },
{ "PWM", 3, NULL, cmd_mqtt_duty_interval },
{ 0, 0, 0, 0 }
Expand All @@ -2884,6 +2936,9 @@ const struct cmd_t mqtt_topic_commands[] = {
{ "COMMand", 4, NULL, cmd_mqtt_cmd_topic },
{ "RESPonse", 4, NULL, cmd_mqtt_resp_topic },
{ "TEMP", 4, NULL, cmd_mqtt_temp_topic },
{ "VTEMP", 5, NULL, cmd_mqtt_vtemp_topic },
{ "VHUMidity", 4, NULL, cmd_mqtt_vhumidity_topic },
{ "VPREssure", 4, NULL, cmd_mqtt_vpressure_topic },
{ "FANRPM", 6, NULL, cmd_mqtt_fan_rpm_topic },
{ "FANPWM", 6, NULL, cmd_mqtt_fan_duty_topic },
{ "MBFANRPM", 8, NULL, cmd_mqtt_mbfan_rpm_topic },
Expand Down
Loading

0 comments on commit f7a9e9e

Please sign in to comment.