rasProject_01 / weSweetHome  R. 240
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. More...
 
void mqttPlg01Set (uint8_t const on)
 Switch the plug Plug01. More...
 
void mqttPlg02Set (uint8_t const on)
 Switch the plug PLG2. More...
 
void mqttPlg03Set (uint8_t const on)
 Switch the plug PLG3. More...
 
void mqttPlg04Set (uint8_t const on)
 Switch the plug PLG4. More...
 

Variables

char clientId [38]
 MQTT client ID. More...
 
char mqttHost [68]
 The MQTT broker URL or name. More...
 
int mqttPort
 MQTT port 1883.
 
char subTopStPlg01 [14]
 State sub topic of S20 plug Number 01 to 09. More...
 

Detailed Description

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

Copyright (c) 2018 Albrecht Weinert
weinert-automation.de a-weinert.de
/ / /\
/ /___ / \ |
\ /____\ /____\ | _|__
\ /\ / \ / \| |
\/ \/ \__/ \__/|_

Revision history

Rev. 218 07.09.2019 : MQTT excepted from sweetHome2.h
Rev. 219 30.09.2019 : reconstructed after HDD crash

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

◆ mqttHost

char mqttHost[68]
extern

The MQTT broker URL or name.

May be set by option –mqttHost meterPi or –mqttBroker 192.168.178.87

default: localhost MQTTBroker (currently localhost !)

◆ 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().

MQTT client ID.