rasProject_01 / weSweetHome  R. 116 2026-05-14
process control       /     RasPi software         by   weinert-automation
Loading...
Searching...
No Matches
mqttHome.h File Reference

MQTT related definitions for an experimental smart home (lab) project. More...

#include <mosquitto.h>

Functions

void mqttClean ()
 End as MQTT client.
int mqttInit ()
 Initialise as MQTT client.
void mqttPlg01Set (uint8_t const on)
 Switch the plug Plug01.
void mqttPlg02Set (uint8_t const on)
 Switch the plug PLG2.
void mqttPlg03Set (uint8_t const on)
 Switch the plug PLG3.
void mqttPlg04Set (uint8_t const on)
 Switch the plug PLG4.

Variables

char clientId [38]
 MQTT client ID.
char subTopStPlg01 [14]
 State sub topic of S20 plug Number 01 to 09.

Detailed Description

MQTT related definitions for an experimental smart home (lab) project.

MQTT is used to control relay devices like Sonoff S20 switchable plugs with Tasmota.

Revision history

Function Documentation

◆ mqttInit()

int mqttInit ( )

Initialise as MQTT client.

On success only: subscribe, loop and publish.

Returns
0: success the common mosq is set and usable; else: errno

◆ mqttPlg01Set()

void mqttPlg01Set ( uint8_t const on)

Switch the plug Plug01.

This function publishes the switch command via MQTT to the relay device Plug01, usually a Sonoff S20 with Tasmota.

Parameters
onswitch on when true, else off

◆ mqttPlg02Set()

void mqttPlg02Set ( uint8_t const on)

Switch the plug PLG2.

See mqttPlg01Set

◆ mqttPlg03Set()

void mqttPlg03Set ( uint8_t const on)

Switch the plug PLG3.

See mqttPlg01Set

◆ mqttPlg04Set()

void mqttPlg04Set ( uint8_t const on)

Switch the plug PLG4.

See mqttPlg01Set

Variable Documentation

◆ subTopStPlg01

char subTopStPlg01[14]
extern

State sub topic of S20 plug Number 01 to 09.

It's preset as plug01/POWER for 01, but the digit at index [5] will be set before each use accordingly.

◆ clientId

char clientId[38]
extern

MQTT client ID.

default value: sweetHomeControl; length: 15; max. length: 36
May be changed before mqttInit().