oneM2M air quality monitoring system

Raspberry Pi based air quality monitoring system connecting ESP32-S sensor nodes, actuators and Smart LEDs via Zigbee and MQTT to a ACME CSE

IntermediateFull instructions provided4 hours2,008
oneM2M air quality monitoring system

Things used in this project

Hardware components

Raspberry Pi 4 Model B
Raspberry Pi 4 Model B
×1
ESP32-S NodeMCU Development Board V2
×2
Grove - CO2 & Temperature & Humidity Sensor (SCD30)
Seeed Studio Grove - CO2 & Temperature & Humidity Sensor (SCD30)
×2
SONOFF Zigbee 3.0 USB Dongle Plus
×2
SONOFF BASICZBR3 Zigbee Actuator
×2
eWeLight ZAH-BL01-RGBCW Zigbee Smart LED
×2

Software apps and online services

Node-RED
Node-RED
Zigbee2MQTT Bridge
Portainer Container Management Plattform
Eclipse IoT Eclipse Mosquitto
ACME oneM2M CSE

Story

Read more

Schematics

Breadboard Layout

Power with USB, 3.3 or 5 Volts at the corresponding pin.

Schematic

Power with USB, 3.3 or 5 Volts at the corresponding pin.

Code

docker-compose.yml

YAML
Docker compose file. Must be executed with "docker compose up -d".
  version: '3.9'
  services:
    mosquitto:
      image: eclipse-mosquitto:1.6
      container_name: mqtt-AID
      hostname: "mosquitto"
      restart: unless-stopped
      volumes:
        - mosquittoConfigVolume:/mosquitto/config
        - mosquittoDataVolume:/mosquitto/data
        - mosquittoLogVolume:/mosquitto/log
      ports:
        - 1883:1883
        - 8883:8883
        - 9001:9001
      networks:
        - onem2mnet
      logging:
        options:
          max-file: "5"
          max-size: "10m"
      # user: 1000:1000

    nodered:
      image: nodered/node-red:latest
      container_name: nodered-AID
      hostname: "nodered"
      environment:
        - TZ=Europe/Vienna
      restart: unless-stopped
      ports:
        - 1880:1880
      volumes:
        - noderedVolume:/data
      networks:
        - onem2mnet
      logging:
        options:
          max-file: "5"
          max-size: "10m"
      # user: 1000:1000

    grafana:
      image: grafana/grafana-oss:latest
      container_name: grafana-AID
      hostname: "grafana"
      environment:
        - TZ=Europe/Vienna
      restart: unless-stopped
      ports:
        - 3000:3000
      volumes:
        - grafanaVolume:/var/lib/grafana
      networks:
        - onem2mnet
      logging:
        options:
          max-file: "5"
          max-size: "10m"
      # user: 1000:1000
    
    portainer:
      image: portainer/portainer-ce:latest
      container_name: portainer
      hostname: "portainer"
      restart: always
      security_opt:
        - no-new-privileges:true
      volumes:
        - /etc/localtime:/etc/localtime:ro
        - /var/run/docker.sock:/var/run/docker.sock:ro
        - portainerVolume:/data
      networks:
        - onem2mnet
      ports:
        - 8000:8000
        - 9443:9443
      # user: 1000:1000
        
    cse:
      image: philipp666/cse:v0.2
      container_name: acme-cse-AID
      hostname: "cse"
      working_dir: "/opt/ACME-oneM2M-CSE/"
      volumes:
        - cseVolume:/opt/ACME-oneM2M-CSE
      networks:
        - onem2mnet
      entrypoint: "python3 -m acme"
      restart: unless-stopped
      ports: 
        - 8080:8080
      # user: 1000:1000

    zigbee2mqtt:
      image: koenkk/zigbee2mqtt
      container_name: zigbee2mqttAID
      hostname: "zigbee2mqtt"
      restart: unless-stopped
      volumes:
        - zigbee2mqttVolume:/app/data
        - /run/udev:/run/udev:ro
      networks:
        - onem2mnet
      ports:
        # Frontend port
        - 8081:8080
      environment:
        - TZ=Europe/Vienna
      devices:
        # Make sure this matched your adapter location
        - /dev/ttyUSB0:/dev/ttyACM0        

  volumes:
    mosquittoConfigVolume:
    mosquittoDataVolume:
    mosquittoLogVolume:
    noderedVolume:
    grafanaVolume:
    portainerVolume:
    zigbee2mqttVolume:
    cseVolume:

  networks:
    onem2mnet:
      external: true

acme.ini

INI
Configuration file for the ACME-oneM2M-CSE.
Must be added to: /opt/ACME-oneM2M-CSE (/var/lib/docker/volumes/acme_cseVolume/_data)
; acme.ini
;
; Simplified configuration file for the [ACME] CSE
;
; created: 2022-10-06 10:50:35
;
; CSE type: IN
; Environment: Development
;

[basic.config]
cseType=IN
cseID=id-in
cseName=cse-in
adminID=aid
dataDirectory=${baseDirectory}
networkInterface=0.0.0.0
cseHost=0.0.0.0
httpPort=8080
logLevel=info
databaseInMemory=False

[server.http]
enableUpperTesterEndpoint=true
enableStructureEndpoint=true

[server.http.security]
; Enable TLS for communications.
; This can be overridden by the command line arguments --http and --https.
; See oneM2M TS-0003 Clause 8.2.1 "Overview on Security Association Establishment Frameworks".
; Default: False
useTLS=true
; TLS version to be used in connections.
; Allowed versions: TLS1.1, TLS1.2, auto . Use "auto" to allow client-server certificate version negotiation.
; Default: auto
tlsVersion=auto
; Verify certificates in requests. Set to False when using self-signed certificates.
; Default: False
verifyCertificate=false
; Path and filename of the certificate file.
; Default: None
caCertificateFile=/opt/ACME-oneM2M-CSE/cert/mio_aid.crt
; Path and filename of the private key file.
; Default: None
caPrivateKeyFile=/opt/ACME-oneM2M-CSE/cert/mio_aid.key

[client.mqtt]
; Enable the MQTT binding.
; Default: False
enable=True
; The hostname of the MQTT broker.
; Default; 127.0.0.1
address=mosquitto
; Set the port for the MQTT broker. 
; Default: 1883, or 8883 for TLS
port=8883
; Value for the MQTT connection's keep-alive parameter in seconds.
; Default: 60 seconds
keepalive=60
; Interface to listen to. Use 0.0.0.0 for "all" interfaces. 
; Default: 127.0.0.1
listenIF=${basic.config:networkInterface}
; Optional prefix for topics.
; Default: empty string
topicPrefix=
; Timeout when sending MQTT requests and waiting for responses.
; Default: 5.0 seconds
timeout=5.0

[client.mqtt.security]
; The username for MQTT broker authentication if required by the broker.
; Default: None
; username=
; The password for MQTT broker authentication.
; Default: None
; password=
;Enable TLS for communications with the MQTT broker.
;Default: False
useTLS=true
; Verify certificates in requests. Set to False when using self-signed certificates..
; Default: False
verifyCertificate=false
; Path and filename of the certificate file.
; Default: None
caCertificateFile=/opt/ACME-oneM2M-CSE/cert/ca.crt
; List of credential-IDs that can be used to register an AE via MQTT. If this list is empty then all credential IDs are allowed.
; This is a comma-separated list. Wildcards (* and ?) are supported.
; Default: empty list
; allowedCredentialIDs = []

Notificationserver.py

Python
Adapted notificationserver.py with added MQTTS Support.
Credits to Andreas Kraft: The original file is part of the ACME-oneM2M-CSE.
Must be added to: /opt/ACME-oneM2M-CSE/tools/notificationServer (/var/lib/docker/volumes/acme_cseVolume/_data/tools/notificationServer)
#
#	notificationServer.py
#
#	(c) 2020 by Andreas Kraft
#	License: BSD 3-Clause License. See the LICENSE file for further details.
#
#	Simple base implementation of a notification server to handle notifications 
#	from a CSE.
#

from __future__ import annotations
from http.client import HTTPMessage
from typing import cast
from http.server import HTTPServer, BaseHTTPRequestHandler
import email.parser
import json, argparse, sys, ssl, signal
import cbor2
from rich.console import Console
from rich.syntax import Syntax
from automations import *

import pathlib, os
parent = pathlib.Path(os.path.abspath(os.path.dirname(__file__))).parent.parent
sys.path.append(f'{parent}')
from acme.helpers.MQTTConnection import MQTTConnection, MQTTHandler
from acme.helpers.TextTools import toHex
from acme.etc.RequestUtils import serializeData
from acme.etc.DateUtils import getResourceDate
from acme.etc.Types import ContentSerializationType
from acme.etc.Constants import Constants as C

##############################################################################
#
#	HTTP Server
#

port = 9999	# Change this variable to specify another port.
messageColor = 'spring_green2'
errorColor = 'red'

failVerification = False

class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):

	def do_GET(self) -> None:
		"""	Just provide a simple web page.
		"""
		self.send_response(200)
		self.send_header('Content-type', 'text/html')
		self.end_headers()
		self.wfile.write(bytes("<html><head><title>[ACME] Notification Server</title></head><body>This server doesn't provide a web page.</body></html>","utf-8")) 


	def do_POST(self) -> None:
		"""	Handle notification.
		"""

		_responseHeaders:list = []

		# Get headers and content data
		length = int(self.headers['Content-Length'])
		contentType = self.headers['Content-Type']
		requestID = self.headers['X-M2M-RI']
		post_data = self.rfile.read(length)

		# Construct return header
		# Always acknowledge the verification requests
		self.send_response(200)
		self.send_header('X-M2M-RSC', '2000' if not failVerification else '4101')
		self.send_header('X-M2M-RI', requestID)
		_responseHeaders = self._headers_buffer	# type:ignore [attr-defined]
		self.end_headers()


		
		# Print the content data
		console.print(f'[{messageColor}]### Notification (http)')
		console.print(self.headers, highlight = False)

		#Start Automation
		automation(mqttClient, post_data)
		# Print JSON
		if contentType in [ 'application/json', 'application/vnd.onem2m-res+json' ]:
			console.print(Syntax(json.dumps(json.loads(post_data.decode('utf-8')), indent=4),
							 'json', 
							 theme='monokai',
							 line_numbers=False))
		
		# Print CBOR
		elif contentType in [ 'application/cbor', 'application/vnd.onem2m-res+cbor' ]:
			console.print('[dim]Content as Hexdump:\n')
			console.print(toHex(post_data), highlight=False)
			console.print('\n[dim]Content as JSON:\n')
			console.print(Syntax(json.dumps(cbor2.loads(post_data), indent=4),
							 'json', 
							 theme='monokai',
							 line_numbers=False))		

		# Print other binary content
		else:
			console.print(toHex(post_data), highlight=False)
		
		# Print HTTP Response
		# This looks a it more complicated but is necessary to render nicely in Jupyter
		console.print(f'[{messageColor}]### Notification Response (http)')
		console.print(email.parser.Parser(_class = HTTPMessage).parsestr(b''.join(_responseHeaders).decode('iso-8859-1')), highlight = False)


	def log_message(self, format:str, *args:int) -> None:
		if (msg := format%args).startswith('"GET'):	return	# ignore GET log messages
		console.print(f'[{messageColor} reverse]{msg}', highlight = False)


##############################################################################
#
#	MQTT Client
#

mqttNotificationTopic = [ '/oneM2M/req/id-in/+/#' ]

class MQTTClientHandler(MQTTHandler):

	def __init__(self, topic:str|list[str], enableLogging:bool) -> None:
		super().__init__()
		self.topic = topic
		self.enableLogging = enableLogging
		self.isShutdown = False


	def onConnect(self, connection:MQTTConnection) -> bool:
		try:
			connection.subscribeTopic(self.topic, self._requestCB)					# Subscribe to general requests
		except Exception as e:
			self.onError(connection, -1, f'MQTT {str(e)}')
		return True


	def onError(self, connection:MQTTConnection, rc:int=-1, msg:str=None) -> bool:
		if rc in [5]:		# authorization error
			console.print(f'[{errorColor}]MQTT authorization error')
			connection.shutdown()
			console.print(f'[{messageColor}]MQTT client shutdown')
		if rc == -1: 	# unknown. probably connection error?
			if msg:
				console.print(f'[{errorColor}]{msg}')
			connection.shutdown()
			console.print(f'[{messageColor}]MQTT client shutdown')
		# ignore all others
		return True


	def logging(self, connection:MQTTConnection, level:int, message:str) -> bool:
		if self.enableLogging:
			console.print(f'{level}: {message}')
		return True


	def onShutdown(self, connection: MQTTConnection) -> None:
		if not self.isShutdown:
			os.kill(os.getpid(), signal.SIGUSR1)
	

	def _requestCB(self, connection:MQTTConnection, topic:str, data:bytes) -> None:
		# TODO is it actually a notification? no -> do nothing, yes -> reply

		def _constructResponse(frm:str, to:str, jsn:dict) -> dict:
			responseData = 	{ 	'fr':	frm,
								'to':	to, 
								'rsc':	2000 if not failVerification else 4101,
								'ot':	getResourceDate()
							}
			if (rqi := jsn.get('rqi')):
				responseData['rqi'] = rqi
			if (rvi := jsn.get('rvi')):
				responseData['rvi'] = rvi
			return responseData


		console.print(f'[{messageColor}]### Notification (MQTT)')
		console.print(f'Topic: {topic}')
		topicArray	= topic.split('/')
		if len(topicArray) > 4 and topicArray[-4] == 'req' and topicArray[-5] == 'oneM2M':
			_frm		= topicArray[-3]
			_to			= topicArray[-2]
			encoding	= topicArray[-1]
		else:
			_frm 		= 'non-onem2m-entity'	
			_to 		= 'unknown'
			encoding	= 'json'

		# Print JSON
		responseData = None
		if encoding.upper() == 'JSON':
			console.print(Syntax(json.dumps((jsn := json.loads(data)), indent=4),
							 'json', 
							 theme='monokai',
							 line_numbers=False))
			to 	= jsn['to'] if 'to' in jsn else _to
			frm = jsn['fr'] if 'fr' in jsn else _frm
			responseData = cast(bytes, serializeData(_constructResponse(to, frm, jsn), ContentSerializationType.JSON))
			console.print(responseData)



		# Print CBOR
		elif encoding.upper() == 'CBOR':
			console.print('[dim]Content as Hexdump:\n')
			console.print(toHex(data), highlight=False)
			console.print('\n[dim]Content as JSON:\n')
			console.print(Syntax(json.dumps((jsn := cbor2.loads(data)), indent=4),
							 'json', 
							 theme='monokai',
							 line_numbers=False))		
			to 	= jsn['to'] if 'to' in jsn else to
			frm = jsn['fr'] if 'fr' in jsn else frm
			responseData = cast(bytes, serializeData(_constructResponse(to, frm, jsn), ContentSerializationType.CBOR))

		# Print other binary content
		else:
			console.print('[dim]Content as Hexdump:\n')
			console.print(toHex(data), highlight=False)
		# TODO send a response

		if responseData:
			# connection.publish(f'/oneM2M/resp{frm}/{to.lstrip("/").replace("/", ":")}/{encoding}', responseData)
			connection.publish(f'/oneM2M/resp/{_frm}/{_to}/{encoding}', responseData)


class MQTTClient(object):

	def __init__(self, args:argparse.Namespace) -> None:
		# Assume a couple of meaningful defaults here
		self.mqttConnection = MQTTConnection(address			= args.mqttAddress,
											 port				= args.mqttPort,
											 keepalive			= 60,
											 interface			= '0.0.0.0',
											 username 			= args.mqttUsername,
											 password			= args.mqttPassword,
											 useTLS				= args.mqtts,
											 caFile				= args.caFile,
											 certfile			= args.mqttCert,
											 keyfile			= args.mqttKey,
											 messageHandler 	= MQTTClientHandler	(args.mqttTopic, args.mqttLogging))
	

	def run(self) -> None:
		self.mqttConnection.run()
		console.print(f'[{messageColor}]MQTT client started. Connected to {args.mqttAddress}:{args.mqttPort}.')
	

	def shutdown(self) -> None:
		self.mqttConnection.messageHandler.isShutdown = True	# type:ignore [attr-defined]
		if self.mqttConnection:
			self.mqttConnection.shutdown()
			console.print(f'[{messageColor}]MQTT client stopped.')
	
##############################################################################

#
#	Help with exiting and terminating all the threads programmatically
#	
class ExitCommand(Exception):
	pass

def exitSignalHandler(signal, frame) -> None:	# type: ignore [no-untyped-def]
	raise ExitCommand()

def exitAll() -> None:
	os.kill(os.getpid(), signal.SIGUSR1)

signal.signal(signal.SIGUSR1, exitSignalHandler)
	
if __name__ == '__main__':
	console = Console()
	console.print(f'\n{C.textLogo} - [bold]Notification Server[/bold]\n\n')


	# parse command line argiments
	parser = argparse.ArgumentParser()

	# mutual exlcusive arguments for http
	groupHttp = parser.add_mutually_exclusive_group()
	groupHttp.add_argument('--http', action='store_false', dest='usehttps', default=None, help='run as http server (the default)')
	groupHttp.add_argument('--https', action='store_true', dest='usehttps', default=None, help='run as https server')
	parser.add_argument('--port', action='store', dest='port', default=port, type=int, help='specify the server port')
	parser.add_argument('--certfile', action='store', dest='certfile', required='--https' in sys.argv, metavar='<filename>', help='specify the certificate file for https')
	parser.add_argument('--keyfile', action='store', dest='keyfile', required='--https' in sys.argv, metavar='<filename>', 	help='specify the key file for https')

	# MQTT arguments
	parser.add_argument('--mqtt', action='store_true', dest='mqtt', default=False, help='enable MQTT for notifications')
	parser.add_argument('--mqtt-address', action='store', dest='mqttAddress', default='localhost', required='--mqtt' in sys.argv, metavar='<host>', help='MQTT broker address (default: localhost)')
	parser.add_argument('--mqtt-port', action='store', dest='mqttPort', default=1883, metavar='<port>',  help='MQTT broker port (default: 1883)')
	parser.add_argument('--mqtt-topic', action='store', dest='mqttTopic', default=mqttNotificationTopic, metavar='<topic>', nargs='+', help=f'MQTT topic list (default: {mqttNotificationTopic})')
	parser.add_argument('--mqtt-username', action='store', dest='mqttUsername', default=None, metavar='<username>',  help='MQTT username (default: None)')
	parser.add_argument('--mqtt-password', action='store', dest='mqttPassword', default=None, required='--mqttUsername' in sys.argv, metavar='<password>',  help='MQTT password (default: None)')
	parser.add_argument('--mqtt-logging', action='store_true', dest='mqttLogging', default=False, help='MQTT enable logging (default: disabled)')
	parser.add_argument('--mqtt-useTLS', action='store_true', dest='mqtts', default=False, help='Enable MQTTS (default: disabled)')
	parser.add_argument('--mqtt-caFile', action='store', metavar='<cafile>', dest='caFile', default=None, help='CA Certficiate ca.crt file (default: None)')
	parser.add_argument('--mqtt-certfile', action='store', metavar='<certfile>', dest='mqttCert', default=None, help='Certificate file *.crt for MQTTS (default: None)')
	parser.add_argument('--mqtt-keyfile', action='store', metavar='<keyfile>', dest='mqttKey', default=None, help='Key file *.key for MQTTS (default: None)')

	# Generic
	parser.add_argument('--fail-verification', action='store_true', dest='failVerification', default=False, help='Fail verification requests (default: false)')



	args = parser.parse_args()

	# Generic arguments
	failVerification = args.failVerification

	# run http(s) server
	httpd = HTTPServer(('', args.port), SimpleHTTPRequestHandler)
	
	if args.usehttps:
		# init ssl socket
		context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)					# Create a SSL Context
		context.load_cert_chain(args.certfile, args.keyfile)				# Load the certificate and private key
		httpd.socket = context.wrap_socket(httpd.socket, server_side=True)	# wrap the original http server socket as an SSL/TLS socket
	
	console.print(f'[{messageColor}]Notification server started.')
	try:
		# run mqtt client
		mqttClient = None
		if args.mqtt:
			mqttClient = MQTTClient(args)
			mqttClient.run()
		# run http server
		console.print(f'[{messageColor}]Listening for http(s) connections on port {args.port}.')
		httpd.serve_forever()
	except KeyboardInterrupt as e:
		if mqttClient:
			mqttClient.shutdown()
		# The http server is stopped implicitly
	except ExitCommand:
		pass
	except Exception:
		console.print()
		console.print_exception()
	finally:
		console.print(f'[{messageColor}]Notification server stopped.')

MQTTConnection.py

Python
ACME Helper File "MQTTConnection.py" with added MQTTS Support.
Credits to Andreas Kraft: The original file is part of the ACME-oneM2M-CSE
Must be added to: /opt/ACME-oneM2M-CSE/acme/helpers (/var/lib/docker/volumes/acme_cseVolume/_data/acme/helpers)
#
#	MQTTConnection.py
#
#	(c) 2021 by Andreas Kraft
#	License: BSD 3-Clause License. See the LICENSE file for further details.
#
#	Implementation of an MQTT Client helper class.
#

from __future__ import annotations
import ssl, time
from dataclasses import dataclass
from typing import Callable, Any, Tuple
import logging

from .BackgroundWorker import BackgroundWorkerPool, BackgroundWorker
from .TextTools import simpleMatch

import paho.mqtt.client as mqtt

@dataclass
class MQTTTopic:
	"""	Structure that represents a subscribed-to topic.
	"""
	topic:str				= None
	mid:int					= None
	isSubscribed:bool		= False
	callback:MQTTCallback	= None
	callbackArgs:dict 		= None


class MQTTHandler(object):
	"""	This base class defines the interface for an MQTT handler class. 
		The abstract methods defined here must be implemented by the implementing class.

		The implementing class acts as a handler for various callbacks when dealing with
		the MQTT handler. To receive messages a client implementation must register topics
		and the callbacks for them in the `onConnect()` method.
	"""

	def onConnect(self, connection:MQTTConnection) -> bool:
		"""	This method is called after the MQTT client connected to the MQTT broker. 
			Usually, an MQTT client should subscribe to topics and register the callback
			methods here.
		"""
		return True

	def onDisconnect(self, connection:MQTTConnection) -> bool:
		"""	This method is called after the MQTT client disconnected from the MQTT broker. 
		"""
		return True

	def onSubscribed(self, connection:MQTTConnection, topic:str) -> bool:
		"""	This method is called after the MQTT client successfully subsribed to a topic. 
		"""
		connection.subscribedCount += 1
		return True

	def onUnsubscribed(self, connection:MQTTConnection, topic:str) -> bool:
		"""	This method is called after the MQTT client successfully unsubsribed from a topic. 
		"""
		connection.subscribedCount -= 1
		return True

	def onError(self, connection:MQTTConnection, rc:int) -> bool:
		"""	This method is called when receiving an error when communicating with the MQTT broker. 
		"""
		return True

	def logging(self, connection:MQTTConnection, level:int, message:str) -> bool:
		"""	This method is called when a log message should be handled. 
		"""
		return True
	
	def onShutdown(self, connection:MQTTConnection) -> None:
		"""	This method is called after the ```connection``` was shut down.
		"""


##############################################################################


class MQTTConnection(object):

	#
	#	Runtime methods
	#

	def __init__(self, address:str, port:int=None, keepalive:int=60, interface:str='0.0.0.0', 
					clientID:str=None, username:str=None, password:str=None,
					useTLS:bool=False, caFile:str=None, verifyCertificate:bool=False, certfile: str = None, keyfile: str = None,
					lowLevelLogging:bool=True,
					messageHandler:MQTTHandler=None
				) -> None:
		self.address								= address
		self.port									= port if port else 8883 if useTLS else 1883
		self.keepalive								= keepalive
		self.bindIF									= interface
		self.username:str							= username
		self.password:str 							= password
		self.useTLS:bool							= useTLS
		self.verifyCertificate						= verifyCertificate
		self.caFile									= caFile
		self.mqttsCertfile 							= certfile
		self.mqttsKeyfile 							= keyfile
		self.clientID								= clientID
		self.lowLevelLogging						= lowLevelLogging

		self.isStopped								= True
		self.isConnected							= False
		self.subscribedCount 						= 0


		self.mqttClient:mqtt.Client 				= None
		self.messageHandler:MQTTHandler				= messageHandler
		self.actor:BackgroundWorker 				= None
		self.subscribedTopics:dict[str, MQTTTopic]	= {}

	
	def shutdown(self) -> bool:
		"""	Shutting down the MQTT client.
		"""

		self.isStopped = True
		if self.mqttClient:
		# if self.mqttClient and self.isConnected:
			# Unsubscribe from all topics
			for t in list(self.subscribedTopics.values()):
				self.unsubscribeTopic(t)
			# wait a moment for all unsubscribe ACKs to arrive
			while len(self.subscribedTopics) > 0:
				time.sleep(0.1)
			# Then disconnect. The actor is stoped implicitly
			self.mqttClient.disconnect()
			self.actor = None

		self.messageHandler and self.messageHandler.logging(self.mqttClient, logging.INFO, 'MQTT client shut down')
		return True


	def run(self) -> None:
		"""	Initialize and run the MQTT client as a BackgroundWorker/Actor.
		"""
		self.messageHandler and self.messageHandler.logging(self.mqttClient, logging.DEBUG, f'MQTT: client name: {self.clientID}')
		self.mqttClient = mqtt.Client(client_id=self.clientID, clean_session=False if self.clientID else True)	# clean_session=False is defined by TS-0010

		# Enable SSL see: https://pypi.org/project/paho-mqtt/
		if self.useTLS:
			self.mqttClient.tls_set(ca_certs=self.caFile, certfile=self.mqttsCertfile, keyfile=self.mqttsKeyfile, cert_reqs=ssl.CERT_REQUIRED, tls_version=ssl.PROTOCOL_TLS, ciphers=None)
			# If tls_insecure_set is set to True, it is impossible to guarantee that the host you are connecting to is not impersonating your server. This can be useful in initial server testing, but makes it possible for a malicious third party to impersonate your server through DNS spoofing, for example.
			self.mqttClient.tls_insecure_set(True)

		# Set username/password
		if self.username and self.password:
			self.mqttClient.username_pw_set(self.username, self.password)
		
		self.mqttClient.on_connect 		= self._onConnect
		self.mqttClient.on_disconnect	= self._onDisconnect
		self.mqttClient.on_log			= self._onLog
		self.mqttClient.on_subscribe	= self._onSubscribe
		self.mqttClient.on_unsubscribe	= self._onUnsubscribe
		self.mqttClient.on_message		= self._onMessage

		try:
			self.messageHandler and self.messageHandler.logging(self.mqttClient, logging.DEBUG, f'MQTT: connecting to host:{self.address}, port:{self.port}, keepalive: {self.keepalive}, bind: {self.bindIF}')
			self.mqttClient.connect(host=self.address, port=self.port, keepalive=self.keepalive, bind_address=self.bindIF)
		except Exception as e:
			if self.messageHandler:
				self.messageHandler.logging(self.mqttClient, logging.ERROR, f'MQTT: cannot connect to broker: {e}')
				self.messageHandler.onError(self, -1)

		# Actually start the actor to run the MQTT client as a thread
		self.actor = BackgroundWorkerPool.newActor(self._mqttActor, name='MQTTClient').start()


	def _mqttActor(self) -> bool:
		"""	Backgroundworker callback to run the actuall MQTT loop.
		"""
		self.isStopped = False
		self.messageHandler and self.messageHandler.logging(self.mqttClient, logging.INFO, 'MQTT: client started')
		while not self.isStopped:
			self.mqttClient.loop_forever()	# Will return when disconnect() is called
		if self.messageHandler:
			self.messageHandler.onShutdown(self)
		return True
	
	
	#
	#	MQTT/paho callbacks
	#

	def _onConnect(self, client:mqtt.Client, userdata:Any, flags:dict, rc:int) -> None:
		"""	Callback when the MQTT client connected to the broker.
		"""
		self.messageHandler and self.messageHandler.logging(self, logging.DEBUG, f'MQTT: Connected with result code: {rc} ({mqtt.error_string(rc)})')
		if rc == 0:
			self.isConnected = True
			self.messageHandler and self.messageHandler.onConnect(self)
		else:
			self.isConnected = False
			if self.messageHandler:
				self.messageHandler.logging(self, logging.ERROR, f'MQTT: Cannot connect to broker. Result code: {rc} ({mqtt.error_string(rc)})')
				self.messageHandler.onError(self, rc)


	def _onDisconnect(self, client:mqtt.Client, userdata:Any, rc:int) -> None:
		"""	Callback when the MQTT client disconnected from the broker.
		"""
		self.messageHandler and self.messageHandler.logging(self, logging.DEBUG, f'MQTT: Disconnected with result code: {rc} ({mqtt.error_string(rc)})')
		self.subscribedTopics.clear()
		if rc == 0:
			self.isConnected = False
			self.messageHandler and	self.messageHandler.onDisconnect(self)
		elif rc == 7:
			self.isConnected = False
			self.messageHandler.logging(self, logging.ERROR, f'MQTT: Cannot disconnect from broker. Result code: {rc} ({mqtt.error_string(rc)})')
			self.messageHandler.logging(self, logging.ERROR, f'MQTT: Did another client connected with the same ID ({self.clientID})?')
			self.messageHandler and	self.messageHandler.onDisconnect(self)
		else:
			self.isConnected = False
			if self.messageHandler:
				self.messageHandler.logging(self, logging.ERROR, f'MQTT: Cannot disconnect from broker. Result code: {rc} ({mqtt.error_string(rc)})')
				self.messageHandler.onDisconnect(self)
				self.messageHandler.onError(self, rc)


	def _onLog(self, client:mqtt.Client, userdata:Any, level:int, buf:str) -> None:
		"""	Mapping of the paho MQTT client's log to the logging system. Also handles different log-level scheme.
		"""
		self.lowLevelLogging and self.messageHandler and self.messageHandler.logging(self, mqtt.LOGGING_LEVEL[level], f'MQTT: {buf}')
	

	def _onSubscribe(self, client:mqtt.Client, userdata:Any, mid:int, granted_qos:int) -> None:
		# TODO doc, error check when not connected, not subscribed
		for t in self.subscribedTopics.values():
			if t.mid == mid:
				t.isSubscribed = True
				self.messageHandler and self.messageHandler.onSubscribed(self, t.topic)
				break
	

	def _onUnsubscribe(self, client:mqtt.Client, userdata:Any, mid:int) -> None:
		# TODO doc, error check when not connected, not subscribed
		"""	Callback when the client successfulle unsubscribed from a topic. The topic
			is also removed from the internal list.
		"""
		for t in self.subscribedTopics.values():
			if t.mid == mid:
				del self.subscribedTopics[t.topic]
				self.messageHandler and self.messageHandler.onUnsubscribed(self, t.topic)
				break


	def _onMessage(self, client:mqtt.Client, userdata:Any, message:mqtt.MQTTMessage) -> None:
		"""	Handle a received message. Forward it to the apropriate handler callback (in a Thread)
		"""
		self.lowLevelLogging and self.messageHandler and self.messageHandler.logging(self, logging.DEBUG, f'MQTT: received topic:{message.topic}, payload:{message.payload}')
		for t in self.subscribedTopics.keys():
			if simpleMatch(message.topic, t, star='#'):
				if (topic := self.subscribedTopics[t]).callback:
					# Run actual request handling in a thread
					# For some reasons mid is not initialized in the on on_message callback, so we use the timestamp for the actor name
					BackgroundWorkerPool.newActor(topic.callback, name=f'mid_{message.timestamp}').start(	connection=self,
																											topic=message.topic,
																											data=message.payload, 
																											**topic.callbackArgs)
					break	# break at first occurence


	#
	#	MQTT messaging methods
	#

	def subscribeTopic(self, topic:str|list[str], callback:MQTTCallback=None, **kwargs:Any) -> None:
		"""	Add one or more MQTT topics to subscribe to. Add the topic(s) afterwards
			to the list of subscribed-to topics.
		"""
		def _subscribe(topic:str) -> None:
			"""	Handle subscription of a single topic.
			"""
			if topic in self.subscribedTopics:
				self.messageHandler and self.messageHandler.logging(self.mqttClient, logging.WARNING, f'MQTT: topic already subscribed: {topic}')
				return
			if (r := self.mqttClient.subscribe(topic))[0] == 0:
				t = MQTTTopic(topic = topic, mid=r[1], callback=callback, callbackArgs=kwargs)
				self.subscribedTopics[topic] = t
			else:
				self.messageHandler and self.messageHandler.logging(self.mqttClient, logging.ERROR, f'MQTT: cannot subscribe: {r[0]}')

		if not self.mqttClient or not self.isConnected:
			self.messageHandler and self.messageHandler.logging(self.mqttClient, logging.ERROR, 'MQTT: Client missing or not initialized')
			return

		# either subscribe a list of topics or a single topic
		list(map(_subscribe, topic if isinstance(topic, list) else [topic]))


	def unsubscribeTopic(self, topic:str|MQTTTopic) -> None:
		"""	Unsubscribe from a topic. `topic` is either an MQTTTopic structure with
			a previously subscribed to topic, or a topic name, in which case
			it is searched for in the list of MQTTTopics.
		"""
		if isinstance(topic, MQTTTopic):
			if topic.topic not in self.subscribedTopics:
				self.messageHandler and self.messageHandler.logging(self.mqttClient, logging.WARNING, f'MQTT: unknown topic: {topic.topic}')
				return
			if (r := self.mqttClient.unsubscribe(topic.topic))[0] == 0:
				topic.mid = r[1]
			else:
				self.messageHandler and self.messageHandler.logging(self.mqttClient, logging.ERROR, f'MQTT: cannot unsubscribe: {r[0]}')
				return

		else:	# if topic is just the name we need to subscribe to
			if topic not in self.subscribedTopics:
				self.messageHandler and self.messageHandler.logging(self.mqttClient, logging.WARNING, f'MQTT: unknown topic: {topic}')
				return
			t = self.subscribedTopics[topic]
			if t.isSubscribed:
				if (r := self.mqttClient.unsubscribe(t.topic))[0] == 0:
					t.mid = r[1]
				else:
					self.messageHandler and self.messageHandler.logging(self.mqttClient, logging.ERROR, f'MQTT: cannot unsubscribe: {r[0]}')
					return
			else:
				self.messageHandler and self.messageHandler.logging(self.mqttClient, logging.WARNING, f'MQTT: topic not subscribed: {topic}')

		# topic is removed in _onUnsubscribe() callback


	def isFullySubscribed(self) -> bool:
		"""	Check whether the number managed subscriptions matches the number of
			currently subscribed-to topics.
		"""
		return self.subscribedCount == len(self.subscribedTopics)



	def publish(self, topic:str, data:bytes) -> None:
		"""	Publish the message `data` with the topic `topic` with the MQTT broker.
		"""
		self.mqttClient.publish(topic, data)



##############################################################################
#
#	Utility functions
#

def idToMQTT(id:str) -> str:
	"""	Convert a oneM2M ID to an MQTT compatible path element.
	"""
	return f'{id.lstrip("/").replace("/", ":")}'


def idToMQTTClientID(id:str, isCSE:bool=True) -> str:
	"""	Convert a oneM2M ID to an MQTT client ID.
	"""
	return f'{"C::" if isCSE else "A::"}{id.lstrip("/")}'

def mqttToId(mqttId:str, isCSE:bool=True) -> Tuple[str, bool]:
	"""	Convert an MQTT compatible path element to an ID.
	"""
	if mqttId.startswith('A:'):
		isCSE = False
	elif mqttId.startswith('C:'):
		isCSE = True
	else:
		return None, False
	return mqttId[2:].replace(':', '/'), isCSE


# Type for an MQTT Callback
MQTTCallback = Callable[[MQTTConnection, str, bytes], None]

mio_flex.fcp

JSON
ACME-oneM2M-CSE flexcontainer file. This file creates the specific flexcontainers at startup of the CSE.
The file must be added to the directory: /opt/ACME-oneM2M-CSE/init (/var/lib/docker/volumes/acme_cseVolume/_data/init)
[
    // ModuleClass: mioAirqualitySensor (aiQSr)
    {
        "type"      : "mio:aiQSr",
        "lname"     : "mioAirqualitySensor",
        "cnd"       : "org.fhtwmio.common.moduleclass.mioAirqualitySensor",
        "attributes": [
            // DataPoint: dataGenerationTime
            { 
                "sname" : "dgt",
                "lname" : "dataGenerationTime", 
                "type" : "timestamp", 
                "car" : "01" 
            }, 
            // DataPoint: co2
            { 
                "sname" : "co2", 
                "lname" : "co2Value", 
                "type" : "number",
                "car" : "01" 
            },
            // DataPoint: temperature
            { 
                "sname" : "temp", 
                "lname" : "temperatureValue", 
                "type" : "number",
                "car" : "01" 
            },
            // DataPoint: humidity
            { 
                "sname" : "hum", 
                "lname" : "humidityValue", 
                "type" : "number",
                "car" : "01" 
            }
        ]
    },

    // ModuleClass: mioColorSmartLed (coSLd)
    {
        "type"      : "mio:coSLd",
        "lname"     : "mioColorSmartLed",
        "cnd"       : "org.fhtwmio.common.moduleclass.mioColorSmartLed",
        "attributes": [
            // DataPoint: dataGenerationTime
            { 
                "sname" : "dgt",
                "lname" : "dataGenerationTime", 
                "type" : "timestamp", 
                "car" : "01" 
            },            
            // DataPoint: hue
            { 
                "sname" : "hue", 
                "lname" : "hueValue", 
                "type" : "nonNegInteger",
                "car" : "1" 
            },
            // DataPoint: saturation
            { 
                "sname" : "sat", 
                "lname" : "saturationValue", 
                "type" : "nonNegInteger",
                "car" : "1" 
            },
            // DataPoint: colorX
            { 
                "sname" : "x", 
                "lname" : "xValue", 
                "type" : "number",
                "car" : "1"
            },
            // DataPoint: colorY
            { 
                "sname" : "y", 
                "lname" : "yValue", 
                "type" : "number",
                "car" : "1" 
            },
            // DataPoint: color temperature
            { 
                "sname" : "colT", 
                "lname" : "colorTemperatureValue", 
                "type" : "nonNegInteger",
                "car" : "1" 
            }        
        ]
    },
    
    // DeviceClass: deviceSmartLed
    {
        "type"      : "mio:devSd",
        "lname"     : "mioDeviceSmartLed",
        "cnd"       : "org.fhtwmio.common.device.mioDeviceSmartLed",
        "children"  : [
            "cod:fauDn", 
            "cod:binSh",
            "cod:runSe",
            "cod:sigSh",
            "cod:brigs",
            "mio:coSLd"
        ]
    },

    // DeviceClass: deviceAirQualitySensor
    {
        "type"      : "mio:devAir",
        "lname"     : "mioDeviceAirQualitySensor",
        "cnd"       : "org.fhtwmio.common.device.mioDeviceAirQualitySensor",
        "children"  : [
            "cod:fauDn", 
            "mio:aiQSr"
        ]
    },

    // DeviceClass: deviceActuator
    {
        "type"      : "mio:devAct",
        "lname"     : "mioDeviceActuator",
        "cnd"       : "org.fhtwmio.common.device.mioDeviceActuator",
        "children"  : [
            "cod:fauDn", 
            "cod:binSh",
            "cod:sigSh"
        ]
    }
]

mosquitto.conf

Plain text
Configuration file for Mosquitto MQTT Broker with TLS-Support.
Must be added to: mosquitto/config (/var/lib/docker/volumes/acme_mosquittoConfigVolume/_data)
# Config file for mosquitto
#
# See mosquitto.conf(5) for more information.
#
# Default values are shown, uncomment to change.
#
# Use the # character to indicate a comment, but only if it is the
# very first character on the line.

# =================================================================
# General configuration
# =================================================================

# Use per listener security settings.
#
# It is recommended this option be set before any other options.
#
# If this option is set to true, then all authentication and access control
# options are controlled on a per listener basis. The following options are
# affected:
#
# password_file acl_file psk_file auth_plugin auth_opt_* allow_anonymous
# auto_id_prefix allow_zero_length_clientid
#
# Note that if set to true, then a durable client (i.e. with clean session set
# to false) that has disconnected will use the ACL settings defined for the
# listener that it was most recently connected to.
#
# The default behaviour is for this to be set to false, which maintains the
# setting behaviour from previous versions of mosquitto.
#per_listener_settings false


# If a client is subscribed to multiple subscriptions that overlap, e.g. foo/#
# and foo/+/baz , then MQTT expects that when the broker receives a message on
# a topic that matches both subscriptions, such as foo/bar/baz, then the client
# should only receive the message once.
# Mosquitto keeps track of which clients a message has been sent to in order to
# meet this requirement. The allow_duplicate_messages option allows this
# behaviour to be disabled, which may be useful if you have a large number of
# clients subscribed to the same set of topics and are very concerned about
# minimising memory usage.
# It can be safely set to true if you know in advance that your clients will
# never have overlapping subscriptions, otherwise your clients must be able to
# correctly deal with duplicate messages even when then have QoS=2.
#allow_duplicate_messages false

# This option controls whether a client is allowed to connect with a zero
# length client id or not. This option only affects clients using MQTT v3.1.1
# and later. If set to false, clients connecting with a zero length client id
# are disconnected. If set to true, clients will be allocated a client id by
# the broker. This means it is only useful for clients with clean session set
# to true.
#allow_zero_length_clientid true

# If allow_zero_length_clientid is true, this option allows you to set a prefix
# to automatically generated client ids to aid visibility in logs.
# Defaults to 'auto-'
#auto_id_prefix auto-

# This option affects the scenario when a client subscribes to a topic that has
# retained messages. It is possible that the client that published the retained
# message to the topic had access at the time they published, but that access
# has been subsequently removed. If check_retain_source is set to true, the
# default, the source of a retained message will be checked for access rights
# before it is republished. When set to false, no check will be made and the
# retained message will always be published. This affects all listeners.
#check_retain_source true

# QoS 1 and 2 messages will be allowed inflight per client until this limit
# is exceeded.  Defaults to 0. (No maximum)
# See also max_inflight_messages
#max_inflight_bytes 0

# The maximum number of QoS 1 and 2 messages currently inflight per
# client.
# This includes messages that are partway through handshakes and
# those that are being retried. Defaults to 20. Set to 0 for no
# maximum. Setting to 1 will guarantee in-order delivery of QoS 1
# and 2 messages.
#max_inflight_messages 20

# For MQTT v5 clients, it is possible to have the server send a "server
# keepalive" value that will override the keepalive value set by the client.
# This is intended to be used as a mechanism to say that the server will
# disconnect the client earlier than it anticipated, and that the client should
# use the new keepalive value. The max_keepalive option allows you to specify
# that clients may only connect with keepalive less than or equal to this
# value, otherwise they will be sent a server keepalive telling them to use
# max_keepalive. This only applies to MQTT v5 clients. The maximum value
# allowable is 65535. Do not set below 10.
#max_keepalive 65535

# For MQTT v5 clients, it is possible to have the server send a "maximum packet
# size" value that will instruct the client it will not accept MQTT packets
# with size greater than max_packet_size bytes. This applies to the full MQTT
# packet, not just the payload. Setting this option to a positive value will
# set the maximum packet size to that number of bytes. If a client sends a
# packet which is larger than this value, it will be disconnected. This applies
# to all clients regardless of the protocol version they are using, but v3.1.1
# and earlier clients will of course not have received the maximum packet size
# information. Defaults to no limit. Setting below 20 bytes is forbidden
# because it is likely to interfere with ordinary client operation, even with
# very small payloads.
#max_packet_size 0

# QoS 1 and 2 messages above those currently in-flight will be queued per
# client until this limit is exceeded.  Defaults to 0. (No maximum)
# See also max_queued_messages.
# If both max_queued_messages and max_queued_bytes are specified, packets will
# be queued until the first limit is reached.
#max_queued_bytes 0

# The maximum number of QoS 1 and 2 messages to hold in a queue per client
# above those that are currently in-flight.  Defaults to 100. Set
# to 0 for no maximum (not recommended).
# See also queue_qos0_messages.
# See also max_queued_bytes.
#max_queued_messages 100
#
# This option sets the maximum number of heap memory bytes that the broker will
# allocate, and hence sets a hard limit on memory use by the broker.  Memory
# requests that exceed this value will be denied. The effect will vary
# depending on what has been denied. If an incoming message is being processed,
# then the message will be dropped and the publishing client will be
# disconnected. If an outgoing message is being sent, then the individual
# message will be dropped and the receiving client will be disconnected.
# Defaults to no limit.
#memory_limit 0

# This option sets the maximum publish payload size that the broker will allow.
# Received messages that exceed this size will not be accepted by the broker.
# The default value is 0, which means that all valid MQTT messages are
# accepted. MQTT imposes a maximum payload size of 268435455 bytes.
#message_size_limit 0

# This option allows persistent clients (those with clean session set to false)
# to be removed if they do not reconnect within a certain time frame.
#
# This is a non-standard option in MQTT V3.1 but allowed in MQTT v3.1.1.
#
# Badly designed clients may set clean session to false whilst using a randomly
# generated client id. This leads to persistent clients that will never
# reconnect. This option allows these clients to be removed.
#
# The expiration period should be an integer followed by one of h d w m y for
# hour, day, week, month and year respectively. For example
#
# persistent_client_expiration 2m
# persistent_client_expiration 14d
# persistent_client_expiration 1y
#
# The default if not set is to never expire persistent clients.
#persistent_client_expiration

# Write process id to a file. Default is a blank string which means
# a pid file shouldn't be written.
# This should be set to /var/run/mosquitto.pid if mosquitto is
# being run automatically on boot with an init script and
# start-stop-daemon or similar.
#pid_file

# Set to true to queue messages with QoS 0 when a persistent client is
# disconnected. These messages are included in the limit imposed by
# max_queued_messages and max_queued_bytes
# Defaults to false.
# This is a non-standard option for the MQTT v3.1 spec but is allowed in
# v3.1.1.
#queue_qos0_messages false

# Set to false to disable retained message support. If a client publishes a
# message with the retain bit set, it will be disconnected if this is set to
# false.
#retain_available true

# Disable Nagle's algorithm on client sockets. This has the effect of reducing
# latency of individual messages at the potential cost of increasing the number
# of packets being sent.
#set_tcp_nodelay false

# Time in seconds between updates of the $SYS tree.
# Set to 0 to disable the publishing of the $SYS tree.
#sys_interval 10

# The MQTT specification requires that the QoS of a message delivered to a
# subscriber is never upgraded to match the QoS of the subscription. Enabling
# this option changes this behaviour. If upgrade_outgoing_qos is set true,
# messages sent to a subscriber will always match the QoS of its subscription.
# This is a non-standard option explicitly disallowed by the spec.
#upgrade_outgoing_qos false

# When run as root, drop privileges to this user and its primary
# group.
# Set to root to stay as root, but this is not recommended.
# If run as a non-root user, this setting has no effect.
# Note that on Windows this has no effect and so mosquitto should
# be started by the user you wish it to run as.
#user mosquitto

# =================================================================
# Default listener
# =================================================================

# IP address/hostname to bind the default listener to. If not
# given, the default listener will not be bound to a specific
# address and so will be accessible to all network interfaces.
# bind_address ip-address/host name
#bind_address

# Port to use for the default listener.
#port 1883

# Bind the listener to a specific interface. This is similar to
# bind_address above but is useful when an interface has multiple addresses or
# the address may change. It is valid to use this with the bind_address option,
# but take care that the interface you are binding to contains the address you
# are binding to, otherwise you will not be able to connect.
# Example: bind_interface eth0
#bind_interface

# When a listener is using the websockets protocol, it is possible to serve
# http data as well. Set http_dir to a directory which contains the files you
# wish to serve. If this option is not specified, then no normal http
# connections will be possible.
#http_dir

# The maximum number of client connections to allow. This is
# a per listener setting.
# Default is -1, which means unlimited connections.
# Note that other process limits mean that unlimited connections
# are not really possible. Typically the default maximum number of
# connections possible is around 1024.
#max_connections -1

# Choose the protocol to use when listening.
# This can be either mqtt or websockets.
# Websockets support is currently disabled by default at compile time.
# Certificate based TLS may be used with websockets, except that
# only the cafile, certfile, keyfile and ciphers options are supported.
#protocol mqtt

# Set use_username_as_clientid to true to replace the clientid that a client
# connected with with its username. This allows authentication to be tied to
# the clientid, which means that it is possible to prevent one client
# disconnecting another by using the same clientid.
# If a client connects with no username it will be disconnected as not
# authorised when this option is set to true.
# Do not use in conjunction with clientid_prefixes.
# See also use_identity_as_username.
#use_username_as_clientid

# -----------------------------------------------------------------
# Certificate based SSL/TLS support
# -----------------------------------------------------------------
# The following options can be used to enable SSL/TLS support for
# this listener. Note that the recommended port for MQTT over TLS
# is 8883, but this must be set manually.
#
# See also the mosquitto-tls man page.

# At least one of cafile or capath must be defined. They both
# define methods of accessing the PEM encoded Certificate
# Authority certificates that have signed your server certificate
# and that you wish to trust.
# cafile defines the path to a file containing the CA certificates.
# capath defines a directory that will be searched for files
# containing the CA certificates. For capath to work correctly, the
# certificate files must have ".crt" as the file ending and you must run
# "openssl rehash <path to capath>" each time you add/remove a certificate.
listener 8883
cafile /mosquitto/config/ca.crt
#capath

# Path to the PEM encoded server certificate.
certfile /mosquitto/config/mio_aid.crt


# Path to the PEM encoded keyfile.
keyfile /mosquitto/config/mio_aid.key


# If you have require_certificate set to true, you can create a certificate
# revocation list file to revoke access to particular client certificates. If
# you have done this, use crlfile to point to the PEM encoded revocation file.
#crlfile

# If you wish to control which encryption ciphers are used, use the ciphers
# option. The list of available ciphers can be obtained using the "openssl
# ciphers" command and should be provided in the same format as the output of
# that command.
# If unset defaults to DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:@STRENGTH
#ciphers DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:@STRENGTH

# To allow the use of ephemeral DH key exchange, which provides forward
# security, the listener must load DH parameters. This can be specified with
# the dhparamfile option. The dhparamfile can be generated with the command
# e.g. "openssl dhparam -out dhparam.pem 2048"
#dhparamfile

# By default a TLS enabled listener will operate in a similar fashion to a
# https enabled web server, in that the server has a certificate signed by a CA
# and the client will verify that it is a trusted certificate. The overall aim
# is encryption of the network traffic. By setting require_certificate to true,
# the client must provide a valid certificate in order for the network
# connection to proceed. This allows access to the broker to be controlled
# outside of the mechanisms provided by MQTT.
#require_certificate false

# This option defines the version of the TLS protocol to use for this listener.
# The default value allows all of v1.3, v1.2 and v1.1. The valid values are
# tlsv1.3 tlsv1.2 and tlsv1.1.
#tls_version

# If require_certificate is true, you may set use_identity_as_username to true
# to use the CN value from the client certificate as a username. If this is
# true, the password_file option will not be used for this listener.
# This takes priority over use_subject_as_username.
# See also use_subject_as_username.
#use_identity_as_username false

# If require_certificate is true, you may set use_subject_as_username to true
# to use the complete subject value from the client certificate as a username.
# If this is true, the password_file option will not be used for this listener.
# See also use_identity_as_username
#use_subject_as_username false

# -----------------------------------------------------------------
# Pre-shared-key based SSL/TLS support
# -----------------------------------------------------------------
# The following options can be used to enable PSK based SSL/TLS support for
# this listener. Note that the recommended port for MQTT over TLS is 8883, but
# this must be set manually.
#
# See also the mosquitto-tls man page and the "Certificate based SSL/TLS
# support" section. Only one of certificate or PSK encryption support can be
# enabled for any listener.

# The psk_hint option enables pre-shared-key support for this listener and also
# acts as an identifier for this listener. The hint is sent to clients and may
# be used locally to aid authentication. The hint is a free form string that
# doesn't have much meaning in itself, so feel free to be creative.
# If this option is provided, see psk_file to define the pre-shared keys to be
# used or create a security plugin to handle them.
#psk_hint

# When using PSK, the encryption ciphers used will be chosen from the list of
# available PSK ciphers. If you want to control which ciphers are available,
# use the "ciphers" option.  The list of available ciphers can be obtained
# using the "openssl ciphers" command and should be provided in the same format
# as the output of that command.
#ciphers

# Set use_identity_as_username to have the psk identity sent by the client used
# as its username. Authentication will be carried out using the PSK rather than
# the MQTT username/password and so password_file will not be used for this
# listener.
#use_identity_as_username false


# =================================================================
# Extra listeners
# =================================================================

# Listen on a port/ip address combination. By using this variable
# multiple times, mosquitto can listen on more than one port. If
# this variable is used and neither bind_address nor port given,
# then the default listener will not be started.
# The port number to listen on must be given. Optionally, an ip
# address or host name may be supplied as a second argument. In
# this case, mosquitto will attempt to bind the listener to that
# address and so restrict access to the associated network and
# interface. By default, mosquitto will listen on all interfaces.
# Note that for a websockets listener it is not possible to bind to a host
# name.
# listener port-number [ip address/host name]
#listener

# Bind the listener to a specific interface. This is similar to
# the [ip address/host name] part of the listener definition, but is useful
# when an interface has multiple addresses or the address may change. It is
# valid to use this with the [ip address/host name] part of the listener
# definition, but take care that the interface you are binding to contains the
# address you are binding to, otherwise you will not be able to connect.
# Only available on Linux and requires elevated privileges.
#
# Example: bind_interface eth0
#bind_interface

# When a listener is using the websockets protocol, it is possible to serve
# http data as well. Set http_dir to a directory which contains the files you
# wish to serve. If this option is not specified, then no normal http
# connections will be possible.
#http_dir

# The maximum number of client connections to allow. This is
# a per listener setting.
# Default is -1, which means unlimited connections.
# Note that other process limits mean that unlimited connections
# are not really possible. Typically the default maximum number of
# connections possible is around 1024.
#max_connections -1

# The listener can be restricted to operating within a topic hierarchy using
# the mount_point option. This is achieved be prefixing the mount_point string
# to all topics for any clients connected to this listener. This prefixing only
# happens internally to the broker; the client will not see the prefix.
#mount_point

# Choose the protocol to use when listening.
# This can be either mqtt or websockets.
# Certificate based TLS may be used with websockets, except that only the
# cafile, certfile, keyfile and ciphers options are supported.
#protocol mqtt

# Set use_username_as_clientid to true to replace the clientid that a client
# connected with with its username. This allows authentication to be tied to
# the clientid, which means that it is possible to prevent one client
# disconnecting another by using the same clientid.
# If a client connects with no username it will be disconnected as not
# authorised when this option is set to true.
# Do not use in conjunction with clientid_prefixes.
# See also use_identity_as_username.
#use_username_as_clientid

# Change the websockets headers size. This is a global option, it is not
# possible to set per listener. This option sets the size of the buffer used in
# the libwebsockets library when reading HTTP headers. If you are passing large
# header data such as cookies then you may need to increase this value. If left
# unset, or set to 0, then the default of 1024 bytes will be used.
#websockets_headers_size

# -----------------------------------------------------------------
# Certificate based SSL/TLS support
# -----------------------------------------------------------------
# The following options can be used to enable certificate based SSL/TLS support
# for this listener. Note that the recommended port for MQTT over TLS is 8883,
# but this must be set manually.
#
# See also the mosquitto-tls man page and the "Pre-shared-key based SSL/TLS
# support" section. Only one of certificate or PSK encryption support can be
# enabled for any listener.

# At least one of cafile or capath must be defined to enable certificate based
# TLS encryption. They both define methods of accessing the PEM encoded
# Certificate Authority certificates that have signed your server certificate
# and that you wish to trust.
# cafile defines the path to a file containing the CA certificates.
# capath defines a directory that will be searched for files
# containing the CA certificates. For capath to work correctly, the
# certificate files must have ".crt" as the file ending and you must run
# "openssl rehash <path to capath>" each time you add/remove a certificate.
#cafile
#capath

# Path to the PEM encoded server certificate.
#certfile

# Path to the PEM encoded keyfile.
#keyfile


# If you wish to control which encryption ciphers are used, use the ciphers
# option. The list of available ciphers can be optained using the "openssl
# ciphers" command and should be provided in the same format as the output of
# that command.
#ciphers

# If you have require_certificate set to true, you can create a certificate
# revocation list file to revoke access to particular client certificates. If
# you have done this, use crlfile to point to the PEM encoded revocation file.
#crlfile

# To allow the use of ephemeral DH key exchange, which provides forward
# security, the listener must load DH parameters. This can be specified with
# the dhparamfile option. The dhparamfile can be generated with the command
# e.g. "openssl dhparam -out dhparam.pem 2048"
#dhparamfile

# By default an TLS enabled listener will operate in a similar fashion to a
# https enabled web server, in that the server has a certificate signed by a CA
# and the client will verify that it is a trusted certificate. The overall aim
# is encryption of the network traffic. By setting require_certificate to true,
# the client must provide a valid certificate in order for the network
# connection to proceed. This allows access to the broker to be controlled
# outside of the mechanisms provided by MQTT.
#require_certificate false

# If require_certificate is true, you may set use_identity_as_username to true
# to use the CN value from the client certificate as a username. If this is
# true, the password_file option will not be used for this listener.
#use_identity_as_username false

# -----------------------------------------------------------------
# Pre-shared-key based SSL/TLS support
# -----------------------------------------------------------------
# The following options can be used to enable PSK based SSL/TLS support for
# this listener. Note that the recommended port for MQTT over TLS is 8883, but
# this must be set manually.
#
# See also the mosquitto-tls man page and the "Certificate based SSL/TLS
# support" section. Only one of certificate or PSK encryption support can be
# enabled for any listener.

# The psk_hint option enables pre-shared-key support for this listener and also
# acts as an identifier for this listener. The hint is sent to clients and may
# be used locally to aid authentication. The hint is a free form string that
# doesn't have much meaning in itself, so feel free to be creative.
# If this option is provided, see psk_file to define the pre-shared keys to be
# used or create a security plugin to handle them.
#psk_hint

# When using PSK, the encryption ciphers used will be chosen from the list of
# available PSK ciphers. If you want to control which ciphers are available,
# use the "ciphers" option.  The list of available ciphers can be optained
# using the "openssl ciphers" command and should be provided in the same format
# as the output of that command.
#ciphers

# Set use_identity_as_username to have the psk identity sent by the client used
# as its username. Authentication will be carried out using the PSK rather than
# the MQTT username/password and so password_file will not be used for this
# listener.
#use_identity_as_username false


# =================================================================
# Persistence
# =================================================================

# If persistence is enabled, save the in-memory database to disk
# every autosave_interval seconds. If set to 0, the persistence
# database will only be written when mosquitto exits. See also
# autosave_on_changes.
# Note that writing of the persistence database can be forced by
# sending mosquitto a SIGUSR1 signal.
#autosave_interval 1800

# If true, mosquitto will count the number of subscription changes, retained
# messages received and queued messages and if the total exceeds
# autosave_interval then the in-memory database will be saved to disk.
# If false, mosquitto will save the in-memory database to disk by treating
# autosave_interval as a time in seconds.
#autosave_on_changes false

# Save persistent message data to disk (true/false).
# This saves information about all messages, including
# subscriptions, currently in-flight messages and retained
# messages.
# retained_persistence is a synonym for this option.
#persistence false

# The filename to use for the persistent database, not including
# the path.
#persistence_file mosquitto.db

# Location for persistent database. Must include trailing /
# Default is an empty string (current directory).
# Set to e.g. /var/lib/mosquitto/ if running as a proper service on Linux or
# similar.
#persistence_location


# =================================================================
# Logging
# =================================================================

# Places to log to. Use multiple log_dest lines for multiple
# logging destinations.
# Possible destinations are: stdout stderr syslog topic file
#
# stdout and stderr log to the console on the named output.
#
# syslog uses the userspace syslog facility which usually ends up
# in /var/log/messages or similar.
#
# topic logs to the broker topic '$SYS/broker/log/<severity>',
# where severity is one of D, E, W, N, I, M which are debug, error,
# warning, notice, information and message. Message type severity is used by
# the subscribe/unsubscribe log_types and publishes log messages to
# $SYS/broker/log/M/susbcribe or $SYS/broker/log/M/unsubscribe.
#
# The file destination requires an additional parameter which is the file to be
# logged to, e.g. "log_dest file /var/log/mosquitto.log". The file will be
# closed and reopened when the broker receives a HUP signal. Only a single file
# destination may be configured.
#
# Note that if the broker is running as a Windows service it will default to
# "log_dest none" and neither stdout nor stderr logging is available.
# Use "log_dest none" if you wish to disable logging.
#log_dest stderr

# Types of messages to log. Use multiple log_type lines for logging
# multiple types of messages.
# Possible types are: debug, error, warning, notice, information,
# none, subscribe, unsubscribe, websockets, all.
# Note that debug type messages are for decoding the incoming/outgoing
# network packets. They are not logged in "topics".
#log_type error
#log_type warning
#log_type notice
#log_type information


# If set to true, client connection and disconnection messages will be included
# in the log.
#connection_messages true

# If using syslog logging (not on Windows), messages will be logged to the
# "daemon" facility by default. Use the log_facility option to choose which of
# local0 to local7 to log to instead. The option value should be an integer
# value, e.g. "log_facility 5" to use local5.
#log_facility

# If set to true, add a timestamp value to each log message.
#log_timestamp true

# Set the format of the log timestamp. If left unset, this is the number of
# seconds since the Unix epoch.
# This is a free text string which will be passed to the strftime function. To
# get an ISO 8601 datetime, for example:
# log_timestamp_format %Y-%m-%dT%H:%M:%S
#log_timestamp_format

# Change the websockets logging level. This is a global option, it is not
# possible to set per listener. This is an integer that is interpreted by
# libwebsockets as a bit mask for its lws_log_levels enum. See the
# libwebsockets documentation for more details. "log_type websockets" must also
# be enabled.
#websockets_log_level 0


# =================================================================
# Security
# =================================================================

# If set, only clients that have a matching prefix on their
# clientid will be allowed to connect to the broker. By default,
# all clients may connect.
# For example, setting "secure-" here would mean a client "secure-
# client" could connect but another with clientid "mqtt" couldn't.
#clientid_prefixes

# Boolean value that determines whether clients that connect
# without providing a username are allowed to connect. If set to
# false then a password file should be created (see the
# password_file option) to control authenticated client access.
#
# Defaults to true if no other security options are set. If `password_file` or
# `psk_file` is set, or if an authentication plugin is loaded which implements
# username/password or TLS-PSK checks, then `allow_anonymous` defaults to
# false.
#
#allow_anonymous true

# -----------------------------------------------------------------
# Default authentication and topic access control
# -----------------------------------------------------------------

# Control access to the broker using a password file. This file can be
# generated using the mosquitto_passwd utility. If TLS support is not compiled
# into mosquitto (it is recommended that TLS support should be included) then
# plain text passwords are used, in which case the file should be a text file
# with lines in the format:
# username:password
# The password (and colon) may be omitted if desired, although this
# offers very little in the way of security.
#
# See the TLS client require_certificate and use_identity_as_username options
# for alternative authentication options. If an auth_plugin is used as well as
# password_file, the auth_plugin check will be made first.
#password_file

# Access may also be controlled using a pre-shared-key file. This requires
# TLS-PSK support and a listener configured to use it. The file should be text
# lines in the format:
# identity:key
# The key should be in hexadecimal format without a leading "0x".
# If an auth_plugin is used as well, the auth_plugin check will be made first.
#psk_file

# Control access to topics on the broker using an access control list
# file. If this parameter is defined then only the topics listed will
# have access.
# If the first character of a line of the ACL file is a # it is treated as a
# comment.
# Topic access is added with lines of the format:
#
# topic [read|write|readwrite] <topic>
#
# The access type is controlled using "read", "write" or "readwrite". This
# parameter is optional (unless <topic> contains a space character) - if not
# given then the access is read/write.  <topic> can contain the + or #
# wildcards as in subscriptions.
#
# The first set of topics are applied to anonymous clients, assuming
# allow_anonymous is true. User specific topic ACLs are added after a
# user line as follows:
#
# user <username>
#
# The username referred to here is the same as in password_file. It is
# not the clientid.
#
#
# If is also possible to define ACLs based on pattern substitution within the
# topic. The patterns available for substition are:
#
# %c to match the client id of the client
# %u to match the username of the client
#
# The substitution pattern must be the only text for that level of hierarchy.
#
# The form is the same as for the topic keyword, but using pattern as the
# keyword.
# Pattern ACLs apply to all users even if the "user" keyword has previously
# been given.
#
# If using bridges with usernames and ACLs, connection messages can be allowed
# with the following pattern:
# pattern write $SYS/broker/connection/%c/state
#
# pattern [read|write|readwrite] <topic>
#
# Example:
#
# pattern write sensor/%u/data
#
# If an auth_plugin is used as well as acl_file, the auth_plugin check will be
# made first.
#acl_file

# -----------------------------------------------------------------
# External authentication and topic access plugin options
# -----------------------------------------------------------------

# External authentication and access control can be supported with the
# auth_plugin option. This is a path to a loadable plugin. See also the
# auth_opt_* options described below.
#
# The auth_plugin option can be specified multiple times to load multiple
# plugins. The plugins will be processed in the order that they are specified
# here. If the auth_plugin option is specified alongside either of
# password_file or acl_file then the plugin checks will be made first.
#
#auth_plugin

# If the auth_plugin option above is used, define options to pass to the
# plugin here as described by the plugin instructions. All options named
# using the format auth_opt_* will be passed to the plugin, for example:
#
# auth_opt_db_host
# auth_opt_db_port
# auth_opt_db_username
# auth_opt_db_password


# =================================================================
# Bridges
# =================================================================

# A bridge is a way of connecting multiple MQTT brokers together.
# Create a new bridge using the "connection" option as described below. Set
# options for the bridges using the remaining parameters. You must specify the
# address and at least one topic to subscribe to.
#
# Each connection must have a unique name.
#
# The address line may have multiple host address and ports specified. See
# below in the round_robin description for more details on bridge behaviour if
# multiple addresses are used. Note that if you use an IPv6 address, then you
# are required to specify a port.
#
# The direction that the topic will be shared can be chosen by
# specifying out, in or both, where the default value is out.
# The QoS level of the bridged communication can be specified with the next
# topic option. The default QoS level is 0, to change the QoS the topic
# direction must also be given.
#
# The local and remote prefix options allow a topic to be remapped when it is
# bridged to/from the remote broker. This provides the ability to place a topic
# tree in an appropriate location.
#
# For more details see the mosquitto.conf man page.
#
# Multiple topics can be specified per connection, but be careful
# not to create any loops.
#
# If you are using bridges with cleansession set to false (the default), then
# you may get unexpected behaviour from incoming topics if you change what
# topics you are subscribing to. This is because the remote broker keeps the
# subscription for the old topic. If you have this problem, connect your bridge
# with cleansession set to true, then reconnect with cleansession set to false
# as normal.
#connection <name>
#address <host>[:<port>] [<host>[:<port>]]
#topic <topic> [[[out | in | both] qos-level] local-prefix remote-prefix]


# If a bridge has topics that have "out" direction, the default behaviour is to
# send an unsubscribe request to the remote broker on that topic. This means
# that changing a topic direction from "in" to "out" will not keep receiving
# incoming messages. Sending these unsubscribe requests is not always
# desirable, setting bridge_attempt_unsubscribe to false will disable sending
# the unsubscribe request.
#bridge_attempt_unsubscribe true

# Set the version of the MQTT protocol to use with for this bridge. Can be one
# of mqttv311 or mqttv11. Defaults to mqttv311.
#bridge_protocol_version mqttv311

# Set the clean session variable for this bridge.
# When set to true, when the bridge disconnects for any reason, all
# messages and subscriptions will be cleaned up on the remote
# broker. Note that with cleansession set to true, there may be a
# significant amount of retained messages sent when the bridge
# reconnects after losing its connection.
# When set to false, the subscriptions and messages are kept on the
# remote broker, and delivered when the bridge reconnects.
#cleansession false

# Set the amount of time a bridge using the lazy start type must be idle before
# it will be stopped. Defaults to 60 seconds.
#idle_timeout 60

# Set the keepalive interval for this bridge connection, in
# seconds.
#keepalive_interval 60

# Set the clientid to use on the local broker. If not defined, this defaults to
# 'local.<clientid>'. If you are bridging a broker to itself, it is important
# that local_clientid and clientid do not match.
#local_clientid

# If set to true, publish notification messages to the local and remote brokers
# giving information about the state of the bridge connection. Retained
# messages are published to the topic $SYS/broker/connection/<clientid>/state
# unless the notification_topic option is used.
# If the message is 1 then the connection is active, or 0 if the connection has
# failed.
# This uses the last will and testament feature.
#notifications true

# Choose the topic on which notification messages for this bridge are
# published. If not set, messages are published on the topic
# $SYS/broker/connection/<clientid>/state
#notification_topic

# Set the client id to use on the remote end of this bridge connection. If not
# defined, this defaults to 'name.hostname' where name is the connection name
# and hostname is the hostname of this computer.
# This replaces the old "clientid" option to avoid confusion. "clientid"
# remains valid for the time being.
#remote_clientid

# Set the password to use when connecting to a broker that requires
# authentication. This option is only used if remote_username is also set.
# This replaces the old "password" option to avoid confusion. "password"
# remains valid for the time being.
#remote_password

# Set the username to use when connecting to a broker that requires
# authentication.
# This replaces the old "username" option to avoid confusion. "username"
# remains valid for the time being.
#remote_username

# Set the amount of time a bridge using the automatic start type will wait
# until attempting to reconnect.
# This option can be configured to use a constant delay time in seconds, or to
# use a backoff mechanism based on "Decorrelated Jitter", which adds a degree
# of randomness to when the restart occurs.
#
# Set a constant timeout of 20 seconds:
# restart_timeout 20
#
# Set backoff with a base (start value) of 10 seconds and a cap (upper limit) of
# 60 seconds:
# restart_timeout 10 30
#
# Defaults to jitter with a base of 5 and cap of 30
#restart_timeout 5 30

# If the bridge has more than one address given in the address/addresses
# configuration, the round_robin option defines the behaviour of the bridge on
# a failure of the bridge connection. If round_robin is false, the default
# value, then the first address is treated as the main bridge connection. If
# the connection fails, the other secondary addresses will be attempted in
# turn. Whilst connected to a secondary bridge, the bridge will periodically
# attempt to reconnect to the main bridge until successful.
# If round_robin is true, then all addresses are treated as equals. If a
# connection fails, the next address will be tried and if successful will
# remain connected until it fails
#round_robin false

# Set the start type of the bridge. This controls how the bridge starts and
# can be one of three types: automatic, lazy and once. Note that RSMB provides
# a fourth start type "manual" which isn't currently supported by mosquitto.
#
# "automatic" is the default start type and means that the bridge connection
# will be started automatically when the broker starts and also restarted
# after a short delay (30 seconds) if the connection fails.
#
# Bridges using the "lazy" start type will be started automatically when the
# number of queued messages exceeds the number set with the "threshold"
# parameter. It will be stopped automatically after the time set by the
# "idle_timeout" parameter. Use this start type if you wish the connection to
# only be active when it is needed.
#
# A bridge using the "once" start type will be started automatically when the
# broker starts but will not be restarted if the connection fails.
#start_type automatic

# Set the number of messages that need to be queued for a bridge with lazy
# start type to be restarted. Defaults to 10 messages.
# Must be less than max_queued_messages.
#threshold 10

# If try_private is set to true, the bridge will attempt to indicate to the
# remote broker that it is a bridge not an ordinary client. If successful, this
# means that loop detection will be more effective and that retained messages
# will be propagated correctly. Not all brokers support this feature so it may
# be necessary to set try_private to false if your bridge does not connect
# properly.
#try_private true

# -----------------------------------------------------------------
# Certificate based SSL/TLS support
# -----------------------------------------------------------------
# Either bridge_cafile or bridge_capath must be defined to enable TLS support
# for this bridge.
# bridge_cafile defines the path to a file containing the
# Certificate Authority certificates that have signed the remote broker
# certificate.
# bridge_capath defines a directory that will be searched for files containing
# the CA certificates. For bridge_capath to work correctly, the certificate
# files must have ".crt" as the file ending and you must run "openssl rehash
# <path to capath>" each time you add/remove a certificate.
#bridge_cafile
#bridge_capath


# If the remote broker has more than one protocol available on its port, e.g.
# MQTT and WebSockets, then use bridge_alpn to configure which protocol is
# requested. Note that WebSockets support for bridges is not yet available.
#bridge_alpn

# When using certificate based encryption, bridge_insecure disables
# verification of the server hostname in the server certificate. This can be
# useful when testing initial server configurations, but makes it possible for
# a malicious third party to impersonate your server through DNS spoofing, for
# example. Use this option in testing only. If you need to resort to using this
# option in a production environment, your setup is at fault and there is no
# point using encryption.
#bridge_insecure false

# Path to the PEM encoded client certificate, if required by the remote broker.
#bridge_certfile

# Path to the PEM encoded client private key, if required by the remote broker.
#bridge_keyfile

# -----------------------------------------------------------------
# PSK based SSL/TLS support
# -----------------------------------------------------------------
# Pre-shared-key encryption provides an alternative to certificate based
# encryption. A bridge can be configured to use PSK with the bridge_identity
# and bridge_psk options. These are the client PSK identity, and pre-shared-key
# in hexadecimal format with no "0x". Only one of certificate and PSK based
# encryption can be used on one
# bridge at once.
#bridge_identity
#bridge_psk


# =================================================================
# External config files
# =================================================================

# External configuration files may be included by using the
# include_dir option. This defines a directory that will be searched
# for config files. All files that end in '.conf' will be loaded as
# a configuration file. It is best to have this as the last option
# in the main file. This option will only be processed from the main
# configuration file. The directory specified must not contain the
# main configuration file.
# Files within include_dir will be loaded sorted in case-sensitive
# alphabetical order, with capital letters ordered first. If this option is
# given multiple times, all of the files from the first instance will be
# processed before the next instance. See the man page for examples.
#include_dir

configuration.yaml

Plain text
Configuration File for Zigbee2MQTT with TLS-Support
Must be added to: app/data (/var/lib/docker/volumes/acme_zigbee2mqttVolume/_data)
homeassistant: false
permit_join: true
mqtt:
  base_topic: zigbee2mqtt
  server: mqtt://mosquitto:8883
  ca: /app/data/ca.crt
  key: /app/data/mio_aid.key
  cert: /app/data/mio_aid.crt
serial:
  port: /dev/ttyACM0
advanced:
  homeassistant_legacy_entity_attributes: false
  legacy_api: false
  legacy_availability_payload: false
device_options:
  legacy: false
frontend: true

Create Room 1 CSE.json

JSON
JSON flows for Node Red import.
- Creates ressources for Room 1 via MQTT in ACME-oneM2M-CSE.
- Updates ressources for testing purposes
[
    {
        "id": "2f3571e7cf8bcd73",
        "type": "tab",
        "label": "Create CSE Room1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "7a8867c371ae969a",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "name": "Create container \"room\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "a1efa1ada970ee06",
            "4256e02df7e6e017",
            "b953ed0e89e14f69",
            "43dfe68a15920889",
            "c488df3db6bdb305"
        ],
        "x": 74,
        "y": 139,
        "w": 912,
        "h": 142
    },
    {
        "id": "2ba52b9c31117af5",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "name": "Create acp \"acr_room1\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "4e6e3c7f23ef87f9",
            "c19ff3b210427e4b",
            "0cc49c9edc60702b",
            "12f80edf6b09b031",
            "8f42051c88ee8086"
        ],
        "x": 74,
        "y": -1,
        "w": 912,
        "h": 122
    },
    {
        "id": "f5e78fbfcd07fc36",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "name": "Create acp \"acr_room\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "4f57cba19408e93d",
            "b09c025c07da7695",
            "36d63048afe93cbc",
            "c69dab92a281bdfd",
            "46434e1728016558"
        ],
        "x": 1014,
        "y": -1,
        "w": 812,
        "h": 122
    },
    {
        "id": "0d67f51c981ff192",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "name": "Actuator \"mio:devAct\"",
        "style": {
            "label": true
        },
        "nodes": [
            "5acf96981e44587f",
            "f022d804c04f91a9",
            "37c214641babe7ab",
            "4218165ed0ace9ef",
            "eafd93e2430414ed",
            "cf49042e3cd3a8db",
            "fb5a3867f66d1c4b"
        ],
        "x": 88,
        "y": 299,
        "w": 1324,
        "h": 368
    },
    {
        "id": "a89eac57bf33b627",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "name": "Sensor \"mio:devAir\"",
        "style": {
            "label": true
        },
        "nodes": [
            "88b7d4325940ca08",
            "e92a95542ebc57f3",
            "5a5076c06bbee044",
            "8df2be8e8cead86a",
            "1f9d8519e21e7592",
            "cc48b97fd14589b9"
        ],
        "x": 88,
        "y": 679,
        "w": 1504,
        "h": 268
    },
    {
        "id": "7060ab874651a4cb",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "name": "Smart LED \"mio:devSd\"",
        "style": {
            "label": true
        },
        "nodes": [
            "d862a93f911ddf79",
            "e1b93bbf0e873ac8"
        ],
        "x": 82,
        "y": 967,
        "w": 1976,
        "h": 586
    },
    {
        "id": "4c1ac8bb60b0f2ce",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "name": "Create groups \"grLed\", \"grActuator\"",
        "style": {
            "label": true
        },
        "nodes": [
            "bc720da80899c653",
            "f5a9d0b51701f859"
        ],
        "x": 88,
        "y": 1593,
        "w": 764,
        "h": 234
    },
    {
        "id": "d862a93f911ddf79",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "7060ab874651a4cb",
        "name": "Create \"mio:devSd\"",
        "style": {
            "label": true
        },
        "nodes": [
            "61af6396b091a52f",
            "1c6d1e2d3a7c35aa",
            "9f47fa546e60a27c",
            "b8ed9755d127165f",
            "1dece6d442b75f7d"
        ],
        "x": 108,
        "y": 993,
        "w": 764,
        "h": 534
    },
    {
        "id": "e1b93bbf0e873ac8",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "7060ab874651a4cb",
        "name": "Update \"mio:devSd\"",
        "style": {
            "label": true
        },
        "nodes": [
            "e0d40f3d1fc49b44",
            "f4128d90f0cd3040",
            "f3df62b8167a1162",
            "f55c06a340179ec0",
            "c1e98d3db10cb6dd",
            "135844c41c349739",
            "a6c1a4e8557b4cf2"
        ],
        "x": 888,
        "y": 993,
        "w": 1144,
        "h": 434
    },
    {
        "id": "bc720da80899c653",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "4c1ac8bb60b0f2ce",
        "name": "Create group gractuator",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "832340a6aeeed870",
            "9ed3f9914785d1e5",
            "1d28ecc48bea3fa0"
        ],
        "x": 114,
        "y": 1619,
        "w": 712,
        "h": 82
    },
    {
        "id": "5a5076c06bbee044",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "a89eac57bf33b627",
        "name": "Update values: flexcontainer \"devAir/aiQSr\"",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "2b41c3069a173bde",
            "bac40525ca3bf133",
            "3f2a5f44a683c1fe"
        ],
        "x": 854,
        "y": 839,
        "w": 532,
        "h": 82
    },
    {
        "id": "8df2be8e8cead86a",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "a89eac57bf33b627",
        "name": "Retrieve flexcontainer \"aiQSr\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "6af10f7ca0a89501",
            "763a875e12b9d8d3",
            "49508e14c4a8020b"
        ],
        "x": 854,
        "y": 739,
        "w": 712,
        "h": 82
    },
    {
        "id": "37c214641babe7ab",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "0d67f51c981ff192",
        "name": "Create flexcontainer \"actuator\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "6a049d3fbf543529",
            "49b82f584ec7e08f",
            "eb535d636e66268d"
        ],
        "x": 114,
        "y": 359,
        "w": 712,
        "h": 82
    },
    {
        "id": "4218165ed0ace9ef",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "0d67f51c981ff192",
        "name": "Create flexcontainer \"actuator/binSh\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "3da0339147aca879",
            "c153cfeb790e9858",
            "fa999e8362c3de8a"
        ],
        "x": 114,
        "y": 459,
        "w": 712,
        "h": 82
    },
    {
        "id": "eafd93e2430414ed",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "0d67f51c981ff192",
        "name": "Create flexcontainer \"actuator/sigSh\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "58c93bb8472726ad",
            "ef823671482b94b0",
            "faed4de5c00b5ded"
        ],
        "x": 114,
        "y": 559,
        "w": 712,
        "h": 82
    },
    {
        "id": "1f9d8519e21e7592",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "a89eac57bf33b627",
        "name": "Create flexcontainer \"devAir\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "0c4ca7885dc56ccf",
            "6d9896e6ab49bb27",
            "2e4fc8d9ed57ccf6"
        ],
        "x": 114,
        "y": 739,
        "w": 712,
        "h": 82
    },
    {
        "id": "cc48b97fd14589b9",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "a89eac57bf33b627",
        "name": "Create flexcontainer \"devAir/aiQSr\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "52a4d498a86123c7",
            "134daf5135f77d66",
            "3bf9f7c905907c4e"
        ],
        "x": 114,
        "y": 839,
        "w": 712,
        "h": 82
    },
    {
        "id": "cf49042e3cd3a8db",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "0d67f51c981ff192",
        "name": "Update flexcontainer \"actuator/binSh\" OFF",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "e20d44e744593fe7",
            "292a3eaa59eb46dd",
            "aa6a74c73ed1377b"
        ],
        "x": 854,
        "y": 359,
        "w": 532,
        "h": 82
    },
    {
        "id": "fb5a3867f66d1c4b",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "0d67f51c981ff192",
        "name": "Update flexcontainer \"actuator/binSh\" ON",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "9b3de641e47a2d33",
            "aacf89ce32322f88",
            "e49e456d5ee51b87"
        ],
        "x": 854,
        "y": 459,
        "w": 532,
        "h": 82
    },
    {
        "id": "f5a9d0b51701f859",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "4c1ac8bb60b0f2ce",
        "name": "Create group grled",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "7b670ba359102fd3",
            "b2c117b174436f4e",
            "d16b6de6b190e1be"
        ],
        "x": 114,
        "y": 1719,
        "w": 712,
        "h": 82
    },
    {
        "id": "61af6396b091a52f",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "d862a93f911ddf79",
        "name": "Create flexcontainer \"devSd\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "c9ccaa92a99257a8",
            "3b8aeec5fe156789",
            "07e54bed862c813a"
        ],
        "x": 134,
        "y": 1019,
        "w": 712,
        "h": 82
    },
    {
        "id": "1c6d1e2d3a7c35aa",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "d862a93f911ddf79",
        "name": "Create flexcontainer \"devSd/coSLd\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "d41e2820160d44db",
            "d945c48a43cb8cf6",
            "83f25f6a41324d03"
        ],
        "x": 134,
        "y": 1119,
        "w": 712,
        "h": 82
    },
    {
        "id": "9f47fa546e60a27c",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "d862a93f911ddf79",
        "name": "Create flexcontainer \"devSd/binSh\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "67202e46a27daf27",
            "4fe9d6af1783bbc5",
            "a5990f48fde4b8a9"
        ],
        "x": 134,
        "y": 1219,
        "w": 712,
        "h": 82
    },
    {
        "id": "b8ed9755d127165f",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "d862a93f911ddf79",
        "name": "Create flexcontainer \"devSd/brigs\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "76413230496c2b3b",
            "2e7d1af9e8b10f1c",
            "5bd17559d830a9d0"
        ],
        "x": 134,
        "y": 1319,
        "w": 712,
        "h": 82
    },
    {
        "id": "1dece6d442b75f7d",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "d862a93f911ddf79",
        "name": "Create flexcontainer \"devSd/sigSh\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "85e689641ca90df2",
            "d00c60b54c8e77e6",
            "defcd94ee1a0db2c"
        ],
        "x": 134,
        "y": 1419,
        "w": 712,
        "h": 82
    },
    {
        "id": "e0d40f3d1fc49b44",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "e1b93bbf0e873ac8",
        "name": "Update color: flexcontainer \"devSd/coSLd\" to RED",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "e165f869e6e1c515",
            "4aa3e5cad9b2c5c6",
            "67214a8851ff6bc4"
        ],
        "x": 914,
        "y": 1019,
        "w": 532,
        "h": 82
    },
    {
        "id": "f4128d90f0cd3040",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "e1b93bbf0e873ac8",
        "name": "Update color: flexcontainer \"devSd/coSLd\" to ORANGE",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "363b8aac21844286",
            "91ebb02d801c842b",
            "86fbfdf41ebe10a0"
        ],
        "x": 1474,
        "y": 1019,
        "w": 532,
        "h": 82
    },
    {
        "id": "f3df62b8167a1162",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "e1b93bbf0e873ac8",
        "name": "Update color: flexcontainer \"devSd/coSLd\" to YELLOW",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "f4fbadb733534102",
            "a278722969a51bfa",
            "8eb4f60c06580caf"
        ],
        "x": 914,
        "y": 1119,
        "w": 532,
        "h": 82
    },
    {
        "id": "f55c06a340179ec0",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "e1b93bbf0e873ac8",
        "name": "Update color: flexcontainer \"devSd/coSLd\" to LIGHT GREEN",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "9b3683d44cc75bef",
            "34b6e0e72bcb6146",
            "b84785249b5d4e01"
        ],
        "x": 1474,
        "y": 1119,
        "w": 532,
        "h": 82
    },
    {
        "id": "c1e98d3db10cb6dd",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "e1b93bbf0e873ac8",
        "name": "Update color: flexcontainer \"devSd/coSLd\" to DARK GREEN",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "06615bfab1eba6ae",
            "6b781e5a1373afae",
            "fb570b20923d370c"
        ],
        "x": 914,
        "y": 1219,
        "w": 532,
        "h": 82
    },
    {
        "id": "135844c41c349739",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "e1b93bbf0e873ac8",
        "name": "Update flexcontainer \"devSd/binSh\" OFF",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "4329efb4263126e4",
            "4e8663f0211ccff9",
            "0315c2aef142f15a"
        ],
        "x": 914,
        "y": 1319,
        "w": 532,
        "h": 82
    },
    {
        "id": "a6c1a4e8557b4cf2",
        "type": "group",
        "z": "2f3571e7cf8bcd73",
        "g": "e1b93bbf0e873ac8",
        "name": "Update flexcontainer \"devSd/binSh\" ON",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "7487365d3b803c59",
            "299aa578b61c2a73",
            "1a76753446dd3aa2"
        ],
        "x": 1474,
        "y": 1319,
        "w": 532,
        "h": 82
    },
    {
        "id": "a1efa1ada970ee06",
        "type": "inject",
        "z": "2f3571e7cf8bcd73",
        "g": "7a8867c371ae969a",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 300,
        "y": 180,
        "wires": [
            [
                "4256e02df7e6e017"
            ]
        ]
    },
    {
        "id": "4256e02df7e6e017",
        "type": "change",
        "z": "2f3571e7cf8bcd73",
        "g": "7a8867c371ae969a",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"fr\":\"aid\",\"to\":\"cse-in/airQualityMonitoring\",\"op\":1,\"rvi\":\"3\",\"rqi\":\"123456789\",\"id\":\"ab\",\"srn\":\"as\",\"pc\":{\"m2m:cnt\":{\"acpi\":[\"cse-in/acr_room1\"],\"rn\":\"room1\"}},\"ty\":3}",
                "tot": "json"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "/oneM2M/req/aqm/id-in/json",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 560,
        "y": 180,
        "wires": [
            [
                "b953ed0e89e14f69",
                "43dfe68a15920889"
            ]
        ]
    },
    {
        "id": "b953ed0e89e14f69",
        "type": "mqtt out",
        "z": "2f3571e7cf8bcd73",
        "g": "7a8867c371ae969a",
        "name": "",
        "topic": "",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "7d109e158f357676",
        "x": 830,
        "y": 180,
        "wires": []
    },
    {
        "id": "43dfe68a15920889",
        "type": "debug",
        "z": "2f3571e7cf8bcd73",
        "g": "7a8867c371ae969a",
        "name": "create container",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 860,
        "y": 240,
        "wires": []
    },
    {
        "id": "6a049d3fbf543529",
        "type": "inject",
        "z": "2f3571e7cf8bcd73",
        "g": "37c214641babe7ab",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 220,
        "y": 400,
        "wires": [
            [
                "49b82f584ec7e08f"
            ]
        ]
    },
    {
        "id": "49b82f584ec7e08f",
        "type": "change",
        "z": "2f3571e7cf8bcd73",
        "g": "37c214641babe7ab",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"fr\":\"room1\",\"to\":\"cse-in/airQualityMonitoring/room1\",\"op\":1,\"rvi\":\"3\",\"rqi\":\"123456789\",\"pc\":{\"mio:devAct\":{\"acpi\":[\"cse-in/acr_admin\",\"cse-in/acr_room1\"],\"cnd\":\"org.fhtwmio.common.device.mioDeviceActuator\",\"rn\":\"actuator\"}},\"ty\":28}",
                "tot": "json"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "/oneM2M/req/aqm/id-in/json",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 480,
        "y": 400,
        "wires": [
            [
                "eb535d636e66268d"
            ]
        ]
    },
    {
        "id": "eb535d636e66268d",
        "type": "mqtt out",
        "z": "2f3571e7cf8bcd73",
        "g": "37c214641babe7ab",
        "name": "",
        "topic": "",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "7d109e158f357676",
        "x": 750,
        "y": 400,
        "wires": []
    },
    {
        "id": "3da0339147aca879",
        "type": "inject",
        "z": "2f3571e7cf8bcd73",
        "g": "4218165ed0ace9ef",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 220,
        "y": 500,
        "wires": [
            [
                "c153cfeb790e9858"
            ]
        ]
    },
    {
        "id": "c153cfeb790e9858",
        "type": "change",
        "z": "2f3571e7cf8bcd73",
        "g": "4218165ed0ace9ef",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"fr\":\"room1\",\"to\":\"cse-in/airQualityMonitoring/room1/actuator\",\"op\":1,\"rvi\":\"3\",\"rqi\":\"123456789\",\"pc\":{\"cod:binSh\":{\"acpi\":[\"cse-in/acr_admin\",\"cse-in/acr_room1\"],\"cnd\":\"org.onem2m.common.moduleclass.binarySwitch\",\"rn\":\"status\",\"powSe\":false}},\"ty\":28}",
                "tot": "json"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "/oneM2M/req/aqm/id-in/json",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 480,
        "y": 500,
        "wires": [
            [
                "fa999e8362c3de8a"
            ]
        ]
    },
    {
        "id": "fa999e8362c3de8a",
        "type": "mqtt out",
        "z": "2f3571e7cf8bcd73",
        "g": "4218165ed0ace9ef",
        "name": "",
        "topic": "",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "7d109e158f357676",
        "x": 750,
        "y": 500,
        "wires": []
    },
    {
        "id": "58c93bb8472726ad",
        "type": "inject",
        "z": "2f3571e7cf8bcd73",
        "g": "eafd93e2430414ed",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 220,
        "y": 600,
        "wires": [
            [
                "ef823671482b94b0"
            ]
        ]
    },
    {
        "id": "ef823671482b94b0",
        "type": "change",
        "z": "2f3571e7cf8bcd73",
        "g": "eafd93e2430414ed",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"fr\":\"room1\",\"to\":\"cse-in/airQualityMonitoring/room1/actuator\",\"op\":1,\"rvi\":\"3\",\"rqi\":\"123456789\",\"pc\":{\"cod:sigSh\":{\"acpi\":[\"cse-in/acr_admin\",\"cse-in/acr_room1\"],\"cnd\":\"org.onem2m.common.moduleclass.signalStrength\",\"rn\":\"lqi\",\"lqi\":0}},\"ty\":28}",
                "tot": "json"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "/oneM2M/req/aqm/id-in/json",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 480,
        "y": 600,
        "wires": [
            [
                "faed4de5c00b5ded"
            ]
        ]
    },
    {
...

This file has been truncated, please download it to see its full contents.

Create Room 2 CSE.json

JSON
JSON flows for Node Red import.
- Creates ressources for Room 2 via MQTT in ACME-oneM2M-CSE.
- Updates ressources for testing purposes
[
    {
        "id": "84d3a3bdd5ef48a2",
        "type": "tab",
        "label": "Create CSE Room 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "b60e63bcbe37bb9a",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "name": "Create container \"room\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "9cd66e697d5bae09",
            "a12bceaf660e4764",
            "4f80537ea6fa5557",
            "89203616399e8e95",
            "a697d8cb583db0b8"
        ],
        "x": 54,
        "y": 159,
        "w": 912,
        "h": 142
    },
    {
        "id": "a7895eb2acf147e6",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "name": "Create acp \"acr_room\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "5d99a7b25afad7e5",
            "518d5de47fe8da8c",
            "616e45a81af2d777",
            "99246263ddba2f8d",
            "226893d68e499f62"
        ],
        "x": 54,
        "y": 19,
        "w": 912,
        "h": 122
    },
    {
        "id": "1a874f6c20c716da",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "name": "Create acp \"acr_room\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "534bf67526a8f01d",
            "83aa6be5891e6831",
            "79f3852eac9354af",
            "381b2a9cd8b35a4d",
            "3a884b0f1aad038a"
        ],
        "x": 994,
        "y": 19,
        "w": 812,
        "h": 122
    },
    {
        "id": "132846ca6cac59c3",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "name": "Actuator \"mio:devAct\"",
        "style": {
            "label": true
        },
        "nodes": [
            "1f60106a4a22a1fa",
            "d93e3995a9f6d0bb",
            "70405feae9718e62",
            "584c145cc6a3d2ca",
            "de68179f13cdb9ab",
            "448c97b1fefd558e",
            "65c68bf23a2ccbf7"
        ],
        "x": 68,
        "y": 319,
        "w": 1324,
        "h": 368
    },
    {
        "id": "8cf51cc639bf2290",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "name": "Sensor \"mio:devAir\"",
        "style": {
            "label": true
        },
        "nodes": [
            "fa7093517c53457e",
            "7649d8280991664b",
            "b0ccba9f07888bf2",
            "f1f9cfcbf869f139",
            "0a9794b6fb9527d2",
            "d14c27c30a39fb26"
        ],
        "x": 68,
        "y": 699,
        "w": 1504,
        "h": 268
    },
    {
        "id": "3fbc29b7b7972322",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "name": "Smart LED \"mio:devSd\"",
        "style": {
            "label": true
        },
        "nodes": [
            "738d3e69d7bdb5f0",
            "ccbc7156143561da"
        ],
        "x": 62,
        "y": 987,
        "w": 1976,
        "h": 586
    },
    {
        "id": "18a99facefa3c556",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "name": "Create groups \"grLed\", \"grActuator\"",
        "style": {
            "label": true
        },
        "nodes": [
            "ff05c975338f5e69",
            "459ac83ab028dd55"
        ],
        "x": 68,
        "y": 1613,
        "w": 764,
        "h": 234
    },
    {
        "id": "70405feae9718e62",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "132846ca6cac59c3",
        "name": "Create flexcontainer \"actuator\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "5639ed290cb537a4",
            "31e9e5c6109d00f1",
            "8cebf3918d4102f7"
        ],
        "x": 94,
        "y": 379,
        "w": 712,
        "h": 82
    },
    {
        "id": "584c145cc6a3d2ca",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "132846ca6cac59c3",
        "name": "Create flexcontainer \"actuator/binSh\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "32c367269d955846",
            "8699460bef83c598",
            "3331b75519d0f7a7"
        ],
        "x": 94,
        "y": 479,
        "w": 712,
        "h": 82
    },
    {
        "id": "de68179f13cdb9ab",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "132846ca6cac59c3",
        "name": "Create flexcontainer \"actuator/sigSh\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "a99297a502568c71",
            "39eb86aed7371e9a",
            "6fcb4c443572b8fa"
        ],
        "x": 94,
        "y": 579,
        "w": 712,
        "h": 82
    },
    {
        "id": "448c97b1fefd558e",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "132846ca6cac59c3",
        "name": "Update flexcontainer \"actuator/binSh\" OFF",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "23b95c1b6c9a6be4",
            "4ae279a1ff80fb24",
            "9ba43a70bae78f27"
        ],
        "x": 834,
        "y": 379,
        "w": 532,
        "h": 82
    },
    {
        "id": "65c68bf23a2ccbf7",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "132846ca6cac59c3",
        "name": "Update flexcontainer \"actuator/binSh\" ON",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "4105155a2ecc6e1e",
            "4f0aac2ca8b84805",
            "935cf3858d1bcf8d"
        ],
        "x": 834,
        "y": 479,
        "w": 532,
        "h": 82
    },
    {
        "id": "b0ccba9f07888bf2",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "8cf51cc639bf2290",
        "name": "Update values: flexcontainer \"devAir/aiQSr\"",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "06dee08d739c751c",
            "1f374f493e58437b",
            "0b10095065419d2b"
        ],
        "x": 834,
        "y": 859,
        "w": 532,
        "h": 82
    },
    {
        "id": "f1f9cfcbf869f139",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "8cf51cc639bf2290",
        "name": "Retrieve flexcontainer \"aiQSr\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "bb025e44b4825e93",
            "0dc80ed936af3bd1",
            "632cf57cbd2e0535"
        ],
        "x": 834,
        "y": 759,
        "w": 712,
        "h": 82
    },
    {
        "id": "0a9794b6fb9527d2",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "8cf51cc639bf2290",
        "name": "Create flexcontainer \"devAir\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "8fe5508d25a1c739",
            "6cacf0a964ee36ae",
            "540b53ce7ed4a2b7"
        ],
        "x": 94,
        "y": 759,
        "w": 712,
        "h": 82
    },
    {
        "id": "d14c27c30a39fb26",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "8cf51cc639bf2290",
        "name": "Create flexcontainer \"devAir/aiQSr\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "5f26de999ca8fb85",
            "4c4451292e38f540",
            "6b1dc7620de36e87"
        ],
        "x": 94,
        "y": 859,
        "w": 712,
        "h": 82
    },
    {
        "id": "738d3e69d7bdb5f0",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "3fbc29b7b7972322",
        "name": "Create \"mio:devSd\"",
        "style": {
            "label": true
        },
        "nodes": [
            "43aecea5637c9aba",
            "571ee81d338b7b13",
            "1d0d74345ed12a9e",
            "7707a8239c4db7e4",
            "eb9d4990f6473f4c"
        ],
        "x": 88,
        "y": 1013,
        "w": 764,
        "h": 534
    },
    {
        "id": "ccbc7156143561da",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "3fbc29b7b7972322",
        "name": "Update \"mio:devSd\"",
        "style": {
            "label": true
        },
        "nodes": [
            "c7590eac062e7ddd",
            "7c2d364dbf92778a",
            "20770a26e35870e7",
            "854a307d6f03d495",
            "c3d5345e1150397b",
            "48cb8486f19ecdd0",
            "d3f465ffaa242cec"
        ],
        "x": 868,
        "y": 1013,
        "w": 1144,
        "h": 434
    },
    {
        "id": "ff05c975338f5e69",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "18a99facefa3c556",
        "name": "Create group gractuator",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "311714b8fb7d4ae8",
            "99ef0a21993169d6",
            "4ff59da9fcec5036"
        ],
        "x": 94,
        "y": 1639,
        "w": 712,
        "h": 82
    },
    {
        "id": "459ac83ab028dd55",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "18a99facefa3c556",
        "name": "Create group grled",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "ad271ef667516339",
            "b95d94035ceabc8d",
            "5f7a124494be8676"
        ],
        "x": 94,
        "y": 1739,
        "w": 712,
        "h": 82
    },
    {
        "id": "43aecea5637c9aba",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "738d3e69d7bdb5f0",
        "name": "Create flexcontainer \"devSd\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "40ffcdfbeaf8eb4b",
            "225edc875c777c56",
            "59909721395393b1"
        ],
        "x": 114,
        "y": 1039,
        "w": 712,
        "h": 82
    },
    {
        "id": "571ee81d338b7b13",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "738d3e69d7bdb5f0",
        "name": "Create flexcontainer \"devSd/coSLd\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "c42c1a11782c0ce0",
            "0fa4ee2dbdfb9077",
            "0e5fa703282ec322"
        ],
        "x": 114,
        "y": 1139,
        "w": 712,
        "h": 82
    },
    {
        "id": "1d0d74345ed12a9e",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "738d3e69d7bdb5f0",
        "name": "Create flexcontainer \"devSd/binSh\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "c765f3cc5c553b2f",
            "b3eef14b725261cf",
            "d477260dbdee3f86"
        ],
        "x": 114,
        "y": 1239,
        "w": 712,
        "h": 82
    },
    {
        "id": "7707a8239c4db7e4",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "738d3e69d7bdb5f0",
        "name": "Create flexcontainer \"devSd/brigs\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "7d1f888f1e9a3ac5",
            "0db4750de7a1609d",
            "142709961f998c1b"
        ],
        "x": 114,
        "y": 1339,
        "w": 712,
        "h": 82
    },
    {
        "id": "eb9d4990f6473f4c",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "738d3e69d7bdb5f0",
        "name": "Create flexcontainer \"devSd/sigSh\"",
        "style": {
            "fill": "#ffffbf",
            "label": true
        },
        "nodes": [
            "a82e31f7dde21cb8",
            "c495e0e6c01a4612",
            "960366801ce85a8c"
        ],
        "x": 114,
        "y": 1439,
        "w": 712,
        "h": 82
    },
    {
        "id": "c7590eac062e7ddd",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "ccbc7156143561da",
        "name": "Update color: flexcontainer \"devSd/coSLd\" to RED",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "222a6795adf96d8b",
            "36eed8f7c07f1b37",
            "0bb1b8efc6479fcb"
        ],
        "x": 894,
        "y": 1039,
        "w": 532,
        "h": 82
    },
    {
        "id": "7c2d364dbf92778a",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "ccbc7156143561da",
        "name": "Update color: flexcontainer \"devSd/coSLd\" to ORANGE",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "0fdd0053bfef7bb9",
            "f38c987d3662b62f",
            "c2a77f6710b3e1ee"
        ],
        "x": 1454,
        "y": 1039,
        "w": 532,
        "h": 82
    },
    {
        "id": "20770a26e35870e7",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "ccbc7156143561da",
        "name": "Update color: flexcontainer \"devSd/coSLd\" to YELLOW",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "7c87be6f5d41f6e4",
            "07cba735a30e6c99",
            "971e90a665b70b7e"
        ],
        "x": 894,
        "y": 1139,
        "w": 532,
        "h": 82
    },
    {
        "id": "854a307d6f03d495",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "ccbc7156143561da",
        "name": "Update color: flexcontainer \"devSd/coSLd\" to LIGHT GREEN",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "4938898ed98e6b2f",
            "f3e460c49c547ded",
            "64503aa62aa55396"
        ],
        "x": 1454,
        "y": 1139,
        "w": 532,
        "h": 82
    },
    {
        "id": "c3d5345e1150397b",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "ccbc7156143561da",
        "name": "Update color: flexcontainer \"devSd/coSLd\" to DARK GREEN",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "8028558aa88ac705",
            "9ff910c397ce10d0",
            "20b0b0fe5db7a805"
        ],
        "x": 894,
        "y": 1239,
        "w": 532,
        "h": 82
    },
    {
        "id": "48cb8486f19ecdd0",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "ccbc7156143561da",
        "name": "Update flexcontainer \"devSd/binSh\" OFF",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "3e5710183ceb00db",
            "9887f3ddae64e1b9",
            "c6f31f9b7ac22de8"
        ],
        "x": 894,
        "y": 1339,
        "w": 532,
        "h": 82
    },
    {
        "id": "d3f465ffaa242cec",
        "type": "group",
        "z": "84d3a3bdd5ef48a2",
        "g": "ccbc7156143561da",
        "name": "Update flexcontainer \"devSd/binSh\" ON",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "18139eb564ed6436",
            "40633fb99113733e",
            "533f81db8f8c1dd5"
        ],
        "x": 1454,
        "y": 1339,
        "w": 532,
        "h": 82
    },
    {
        "id": "6601b17e911f7ae5",
        "type": "inject",
        "z": "84d3a3bdd5ef48a2",
        "name": "",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "17",
        "payloadType": "num",
        "x": 510,
        "y": 4720,
        "wires": [
            [
                "3423daa9115a361d"
            ]
        ]
    },
    {
        "id": "3423daa9115a361d",
        "type": "function",
        "z": "84d3a3bdd5ef48a2",
        "name": "Fan control",
        "func": "const Temp = msg.payload;\nconst override = global.get(\"AutoManual_switch\") || 0;\nconst fanstate = global.get(\"FanState\");\nif (override != 1) {\n    if (Temp <= 24 && fanstate !== 0) {\n        msg.payload = 0;\n        global.set(\"FanState\", msg.payload);\n        return msg;\n    } else if (Temp >= 27 && fanstate != 1) {\n        msg.payload = 1;\n        global.set(\"FanState\", msg.payload);\n        return msg;\n    } else {\n        return null;\n    }\n}",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 830,
        "y": 4760,
        "wires": [
            [
                "771f9b153c045f67",
                "d26e72e37b2271d2"
            ]
        ]
    },
    {
        "id": "3028104b040ea98e",
        "type": "change",
        "z": "84d3a3bdd5ef48a2",
        "name": "",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "0",
                "fromt": "num",
                "to": "Auto",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "1",
                "fromt": "num",
                "to": "Manual",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1120,
        "y": 4480,
        "wires": [
            [
                "c5b288138dafb602"
            ]
        ]
    },
    {
        "id": "b79568696c91aebe",
        "type": "change",
        "z": "84d3a3bdd5ef48a2",
        "name": "Auto/Manual var",
        "rules": [
            {
                "t": "set",
                "p": "AutoManual_switch",
                "pt": "global",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1320,
        "y": 4520,
        "wires": [
            []
        ]
    },
    {
        "id": "df19dbd8a999e68a",
        "type": "change",
        "z": "84d3a3bdd5ef48a2",
        "name": "FanState var",
        "rules": [
            {
                "t": "set",
                "p": "FanState",
                "pt": "global",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1110,
        "y": 4720,
        "wires": [
            []
        ]
    },
    {
        "id": "d26e72e37b2271d2",
        "type": "change",
        "z": "84d3a3bdd5ef48a2",
        "name": "",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "0",
                "fromt": "num",
                "to": "Off",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "1",
                "fromt": "num",
                "to": "On",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1120,
        "y": 4660,
        "wires": [
            [
                "b6b4cd8febfbb4ab"
            ]
        ]
    },
    {
        "id": "b6b4cd8febfbb4ab",
        "type": "ui_text",
        "z": "84d3a3bdd5ef48a2",
        "group": "ad3e78a9.60d328",
        "order": 3,
        "width": "0",
        "height": "0",
        "name": "OnOFF Text",
        "label": "",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "x": 1310,
        "y": 4660,
        "wires": []
    },
    {
        "id": "c5b288138dafb602",
        "type": "ui_text",
        "z": "84d3a3bdd5ef48a2",
        "group": "ad3e78a9.60d328",
        "order": 2,
        "width": "0",
        "height": "0",
        "name": "manualText",
        "label": "",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "x": 1310,
        "y": 4480,
        "wires": []
    },
    {
        "id": "771f9b153c045f67",
        "type": "debug",
        "z": "84d3a3bdd5ef48a2",
        "name": "Output to GPIO",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "x": 1120,
        "y": 4840,
        "wires": []
    },
    {
        "id": "9adcd31d5b778347",
        "type": "inject",
        "z": "84d3a3bdd5ef48a2",
        "name": "",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "28",
        "payloadType": "num",
        "x": 510,
        "y": 4800,
        "wires": [
            [
                "3423daa9115a361d"
            ]
        ]
    },
    {
        "id": "499a4796ff975208",
        "type": "function",
        "z": "84d3a3bdd5ef48a2",
        "name": "turn on override",
        "func": "const override = global.get(\"AutoManual_switch\") || 0;\nif(override === 0){\n    msg.payload = 1;\n    return msg;\n} else {\n    return null;\n}",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1120,
        "y": 4580,
        "wires": [
            [
                "3028104b040ea98e",
                "b79568696c91aebe"
            ]
        ]
    },
    {
        "id": "bbf67f2b77ccb647",
        "type": "ui_dropdown",
        "z": "84d3a3bdd5ef48a2",
        "name": "",
        "label": "",
        "tooltip": "",
        "place": "Select option",
        "group": "ad3e78a9.60d328",
        "order": 1,
        "width": 0,
        "height": 0,
        "passthru": true,
        "multiple": false,
        "options": [
            {
                "label": "ON",
                "value": 1,
                "type": "num"
            },
            {
                "label": "OFF",
                "value": 0,
                "type": "num"
            },
            {
                "label": "AUTO",
                "value": "auto",
                "type": "str"
            }
        ],
        "payload": "",
        "topic": "",
        "topicType": "str",
        "className": "",
        "x": 690,
        "y": 4600,
        "wires": [
            [
                "95562695f73cc1a0"
            ]
        ]
    },
    {
        "id": "95562695f73cc1a0",
        "type": "switch",
        "z": "84d3a3bdd5ef48a2",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "auto",
                "vt": "str"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 850,
        "y": 4600,
        "wires": [
            [
                "3028104b040ea98e",
                "c0c97cbd71e89186"
            ],
            [
                "499a4796ff975208",
                "d26e72e37b2271d2",
                "771f9b153c045f67",
                "df19dbd8a999e68a"
            ]
        ]
    },
    {
        "id": "8ddbda1c758e28ee",
        "type": "comment",
        "z": "84d3a3bdd5ef48a2",
        "name": "Temp input",
        "info": "",
...

This file has been truncated, please download it to see its full contents.

Dashboards and Automations.json

JSON
JSON flows for Node Red import.
- Creates Dashboards
- Creates Automations
- Creates Requests via MQTT to oneM2M CSE
- Listens to oneM2M CSE Responses via MQTT
- Controls Smart LEDs and Actuators via Zigbee2MQTT
[
    {
        "id": "adb7fb22534e4439",
        "type": "tab",
        "label": "Dashboards and Automations",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "7191b96f3309a930",
        "type": "group",
        "z": "adb7fb22534e4439",
        "name": "Dashboard Room 1",
        "style": {
            "label": true
        },
        "nodes": [
            "0fa8a5697424de98",
            "f4c81fefd53c0a27"
        ],
        "x": -12,
        "y": 1453,
        "w": 1644,
        "h": 914
    },
    {
        "id": "c855cba684e501fb",
        "type": "group",
        "z": "adb7fb22534e4439",
        "name": "Update Sensor Room1",
        "style": {
            "label": true
        },
        "nodes": [
            "9b06968f8161baf3",
            "6cb378afc014070b",
            "b9544e6f52273a7b",
            "0f158d04be66d709",
            "646fb28d833ad604"
        ],
        "x": 1808,
        "y": 993,
        "w": 584,
        "h": 534
    },
    {
        "id": "8ee6bd0d54880ec9",
        "type": "group",
        "z": "adb7fb22534e4439",
        "name": "Dashboard",
        "style": {
            "label": true
        },
        "nodes": [
            "4cd136f6c52bf6d3",
            "21ea2cc2eb982885"
        ],
        "x": 48,
        "y": 13,
        "w": 1604,
        "h": 954
    },
    {
        "id": "ba33bcd3f1f3cf79",
        "type": "group",
        "z": "adb7fb22534e4439",
        "name": "Update Sensor Room2",
        "style": {
            "label": true
        },
        "nodes": [
            "7854d1503cf578b5",
            "15a1aa7476b81e9c",
            "88dd1bbdf072ed03",
            "006789abb71a3bf8",
            "a3adaf35bc8fedf7"
        ],
        "x": 2428,
        "y": 993,
        "w": 584,
        "h": 534
    },
    {
        "id": "81ab399a042a65b1",
        "type": "group",
        "z": "adb7fb22534e4439",
        "name": "MQTT and Zigbee2MQTT",
        "style": {
            "label": true
        },
        "nodes": [
            "fc33cabcdb7dfa04",
            "da69a740e7835831"
        ],
        "x": 88,
        "y": 973,
        "w": 1684,
        "h": 394
    },
    {
        "id": "0fa8a5697424de98",
        "type": "group",
        "z": "adb7fb22534e4439",
        "g": "7191b96f3309a930",
        "name": "Visualization AirQualitySensor",
        "style": {
            "fill": "#e3f3d3",
            "label": true
        },
        "nodes": [
            "facded4119190ca7",
            "7e1da9b6079a8472",
            "34e3ba89eeea0298",
            "035560a785e10471",
            "f4ba36b2fc40b078",
            "94f0ac3346a3cc5b",
            "dd0b9d7f5792c2a8",
            "02587be9c5cb7884",
            "87ca8679be419b91"
        ],
        "x": 34,
        "y": 1979,
        "w": 992,
        "h": 362
    },
    {
        "id": "f4c81fefd53c0a27",
        "type": "group",
        "z": "adb7fb22534e4439",
        "g": "7191b96f3309a930",
        "name": "Control LED and Actuator",
        "style": {
            "fill": "#e3f3d3",
            "label": true
        },
        "nodes": [
            "61dd47430c5c33f5",
            "6d2c05e03a82c210",
            "6ef5d159e10807ce",
            "8581c87186e29380",
            "9c4b8ea9a0c10f10",
            "c67ce9f9eecd46f3",
            "c67225cec1d996b8",
            "f5b3f3065dae3457",
            "7497103e458540e1",
            "868573f76128a4f8",
            "519daf216781857e",
            "ddb655349eed3e60",
            "cfd2f206bfa929e0",
            "91ec0bd7451c3d47",
            "6ff606062947f5d5",
            "2d347aa9140d3b8b",
            "213b80b4fe98db8b",
            "74e8bd282dd045ef",
            "c9928c2988309950",
            "bf5b199c7db02375",
            "37db16d755d03586",
            "21b84655316d84f0",
            "bc319655b7295675",
            "38d2e6431c1ba4ef",
            "a9b4d1ed3a755968",
            "80d10f28b63314d8",
            "ed684faed23f5aba",
            "91bf0e7b25a5b1aa",
            "93f1ee223aa51c2c",
            "253195880067be83"
        ],
        "x": 14,
        "y": 1479,
        "w": 1592,
        "h": 442
    },
    {
        "id": "9b06968f8161baf3",
        "type": "group",
        "z": "adb7fb22534e4439",
        "g": "c855cba684e501fb",
        "name": "Update values: flexcontainer \"devAir/aiQSr\" 600",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "9e1bf6f4cf5de874",
            "6287dd841f7b498c",
            "e7db036fed0434e3"
        ],
        "x": 1834,
        "y": 1019,
        "w": 532,
        "h": 82
    },
    {
        "id": "6cb378afc014070b",
        "type": "group",
        "z": "adb7fb22534e4439",
        "g": "c855cba684e501fb",
        "name": "Update values: flexcontainer \"devAir/aiQSr\" 1100",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "895c5ce06e17f4cd",
            "eb6951052239fcad",
            "f0cd36ea1dd6f738"
        ],
        "x": 1834,
        "y": 1119,
        "w": 532,
        "h": 82
    },
    {
        "id": "b9544e6f52273a7b",
        "type": "group",
        "z": "adb7fb22534e4439",
        "g": "c855cba684e501fb",
        "name": "Update values: flexcontainer \"devAir/aiQSr\" 1600",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "b66e96214271aa6b",
            "db1afbb10a76cb30",
            "f77c531029a70ae8"
        ],
        "x": 1834,
        "y": 1219,
        "w": 532,
        "h": 82
    },
    {
        "id": "0f158d04be66d709",
        "type": "group",
        "z": "adb7fb22534e4439",
        "g": "c855cba684e501fb",
        "name": "Update values: flexcontainer \"devAir/aiQSr\" 2100",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "6bed69492ccc86d7",
            "9a57be56d926f8b4",
            "50b6d661f78430ba"
        ],
        "x": 1834,
        "y": 1319,
        "w": 532,
        "h": 82
    },
    {
        "id": "646fb28d833ad604",
        "type": "group",
        "z": "adb7fb22534e4439",
        "g": "c855cba684e501fb",
        "name": "Update values: flexcontainer \"devAir/aiQSr\" 2600",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "eaf4d939108bbccb",
            "8a2a7af6efd10c06",
            "ce34dcd1a65010fa"
        ],
        "x": 1834,
        "y": 1419,
        "w": 532,
        "h": 82
    },
    {
        "id": "4cd136f6c52bf6d3",
        "type": "group",
        "z": "adb7fb22534e4439",
        "g": "8ee6bd0d54880ec9",
        "name": "Visualization AirQualitySensor Room 2",
        "style": {
            "fill": "#e3f3d3",
            "label": true
        },
        "nodes": [
            "f1e539b7a1ccea75",
            "59e370ff9a8683f6",
            "76419526aebf7ce7",
            "4d1e0abced184505",
            "15765efa94604f65",
            "aef54415a6ea16ea",
            "58a8f771c827c935",
            "408f4282a6601820",
            "f2542c52894cb9bc",
            "8eb52922bdb9e62b",
            "963bb9c07f5bb78a",
            "6fc2d521c3ad96fe"
        ],
        "x": 74,
        "y": 499,
        "w": 992,
        "h": 442
    },
    {
        "id": "21ea2cc2eb982885",
        "type": "group",
        "z": "adb7fb22534e4439",
        "g": "8ee6bd0d54880ec9",
        "name": "Control LED and Actuator",
        "style": {
            "fill": "#e3f3d3",
            "label": true
        },
        "nodes": [
            "3e19728b7a566f26",
            "e4fe556576311089",
            "507fbde120c286d9",
            "1c6b098c86db2c1b",
            "a7508fea409c0d52",
            "d2c7e5bba4f100c0",
            "247e452789302403",
            "4c31f76c9f975351",
            "37abfdc14d158498",
            "67401344b6597d93",
            "8ed96e7d0538d826",
            "ccfa4662ea49d73b",
            "845c26c8035ff2eb",
            "ad64e52359b21d9c",
            "c7ed2a40a8061428",
            "674e585616c6555c",
            "fddd3abb4d181fcf",
            "b5ce15302c197fb5",
            "26b258796af555c1",
            "16af3387f0447fe0",
            "d9bbfaa1bc34f43d",
            "ced1b73c5a27e4f0",
            "d6e5e95726e0808e",
            "2217e01845d6dae9",
            "b7f1b461eb0b9748",
            "1f77092d20cdd6e5",
            "66718cb51c7d1b44"
        ],
        "x": 74,
        "y": 39,
        "w": 1552,
        "h": 442
    },
    {
        "id": "7854d1503cf578b5",
        "type": "group",
        "z": "adb7fb22534e4439",
        "g": "ba33bcd3f1f3cf79",
        "name": "Update values: flexcontainer \"devAir/aiQSr\" 600",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "68148bac95b0944a",
            "6187d1b5fba09ad1",
            "8b187753c04fe5ae"
        ],
        "x": 2454,
        "y": 1019,
        "w": 532,
        "h": 82
    },
    {
        "id": "15a1aa7476b81e9c",
        "type": "group",
        "z": "adb7fb22534e4439",
        "g": "ba33bcd3f1f3cf79",
        "name": "Update values: flexcontainer \"devAir/aiQSr\" 1100",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "b77ca7836ad75d95",
            "09b7632c01f68947",
            "0a7f3531f68487f8"
        ],
        "x": 2454,
        "y": 1119,
        "w": 532,
        "h": 82
    },
    {
        "id": "88dd1bbdf072ed03",
        "type": "group",
        "z": "adb7fb22534e4439",
        "g": "ba33bcd3f1f3cf79",
        "name": "Update values: flexcontainer \"devAir/aiQSr\" 1600",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "44306f135f445f44",
            "52f77040298bc1b5",
            "6bf306e2bcdefa14"
        ],
        "x": 2454,
        "y": 1219,
        "w": 532,
        "h": 82
    },
    {
        "id": "006789abb71a3bf8",
        "type": "group",
        "z": "adb7fb22534e4439",
        "g": "ba33bcd3f1f3cf79",
        "name": "Update values: flexcontainer \"devAir/aiQSr\" 2100",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "b6143c8f3dce1b61",
            "079c0c27a1ea5ddd",
            "80e24f3b9cf2b9a3"
        ],
        "x": 2454,
        "y": 1319,
        "w": 532,
        "h": 82
    },
    {
        "id": "a3adaf35bc8fedf7",
        "type": "group",
        "z": "adb7fb22534e4439",
        "g": "ba33bcd3f1f3cf79",
        "name": "Update values: flexcontainer \"devAir/aiQSr\" 2600",
        "style": {
            "fill": "#92d04f",
            "label": true,
            "color": "#ff0000"
        },
        "nodes": [
            "c7b0ed69573a0837",
            "3221661c425d0455",
            "d3d16189e4c8e6cf"
        ],
        "x": 2454,
        "y": 1419,
        "w": 532,
        "h": 82
    },
    {
        "id": "fc33cabcdb7dfa04",
        "type": "group",
        "z": "adb7fb22534e4439",
        "g": "81ab399a042a65b1",
        "name": "MQTT req/resp",
        "style": {
            "fill": "#b797cf",
            "label": true,
            "color": "#ffff00"
        },
        "nodes": [
            "e33670e49b117f28",
            "979465ab33b38484",
            "25671ad80423b8fa",
            "56d0e2f4e80c10a6"
        ],
        "x": 114,
        "y": 1179,
        "w": 552,
        "h": 162
    },
    {
        "id": "da69a740e7835831",
        "type": "group",
        "z": "adb7fb22534e4439",
        "g": "81ab399a042a65b1",
        "name": "Translation oneM2M to Zigbee",
        "style": {
            "fill": "#ffbfbf",
            "label": true
        },
        "nodes": [
            "e6467968421e3f9f",
            "6358a55a7dcbb0ef",
            "f305a893a1f8185d",
            "d785feebad77dddd",
            "0b0d1d2f841046d6",
            "b83d30f8ae4fc80e",
            "dc022fc52657814f",
            "73f6b83722b0711b",
            "4e0dac236fe22d20",
            "5fc2752331f890e6",
            "c19864df4ba94d3b",
            "073a17e84e933346",
            "1301bfe577fbb2fd",
            "c0064ba57ba05533",
            "fe7927bf6794fb7b",
            "17065ccc0b4f3bf4",
            "61a1ac0f9f5bc39c",
            "8dc864e9c7fac78c",
            "0f01b7f224117448"
        ],
        "x": 694,
        "y": 999,
        "w": 1052,
        "h": 342
    },
    {
        "id": "facded4119190ca7",
        "type": "ui_chart",
        "z": "adb7fb22534e4439",
        "g": "0fa8a5697424de98",
        "name": "CO2 Chart",
        "group": "3b12fb47e5fca120",
        "order": 1,
        "width": 10,
        "height": 5,
        "label": "CO2",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "no data",
        "dot": false,
        "ymin": "400",
        "ymax": "5000",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "3600",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 890,
        "y": 2060,
        "wires": [
            []
        ]
    },
    {
        "id": "7e1da9b6079a8472",
        "type": "ui_chart",
        "z": "adb7fb22534e4439",
        "g": "0fa8a5697424de98",
        "name": "Humidity Chart",
        "group": "3b12fb47e5fca120",
        "order": 2,
        "width": 10,
        "height": 5,
        "label": "Humidity",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "no data",
        "dot": false,
        "ymin": "0",
        "ymax": "100",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "3600",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 900,
        "y": 2300,
        "wires": [
            []
        ]
    },
    {
        "id": "34e3ba89eeea0298",
        "type": "ui_chart",
        "z": "adb7fb22534e4439",
        "g": "0fa8a5697424de98",
        "name": "Temperature Chart",
        "group": "3b12fb47e5fca120",
        "order": 3,
        "width": 10,
        "height": 5,
        "label": "Temperature",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "no data",
        "dot": false,
        "ymin": "0",
        "ymax": "35",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "3600",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 910,
        "y": 2180,
        "wires": [
            []
        ]
    },
    {
        "id": "035560a785e10471",
        "type": "mqtt in",
        "z": "adb7fb22534e4439",
        "g": "0fa8a5697424de98",
        "name": "",
        "topic": "/oneM2M/resp/aqm/id-in/json",
        "qos": "2",
        "datatype": "auto-detect",
        "broker": "7d109e158f357676",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 180,
        "y": 2160,
        "wires": [
            [
                "94f0ac3346a3cc5b"
            ]
        ]
    },
    {
        "id": "f4ba36b2fc40b078",
        "type": "function",
        "z": "adb7fb22534e4439",
        "g": "0fa8a5697424de98",
        "name": "function aiQSr",
        "func": "var aiQSr = msg.payload.aiQSr;\nvar aiQSr_ri_sensor1 = \"aiQSr4766745724786120822\";\nvar aiQSr_ri_sensor2 = \"aiQSr5053486536049796747\";\n\nvar co2;\nvar temp;\nvar hum;\n\nif (aiQSr) {\n    if (aiQSr.ri === aiQSr_ri_sensor1) {\n        co2 = { payload: msg.payload.aiQSr.co2.toFixed(2) };\n        temp = { payload: msg.payload.aiQSr.temp.toFixed(2) };\n        hum = { payload: msg.payload.aiQSr.hum.toFixed(2) };\n        return [co2, temp, hum];\n    }\n}",
        "outputs": 3,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 620,
        "y": 2160,
        "wires": [
            [
                "dd0b9d7f5792c2a8",
                "facded4119190ca7"
            ],
            [
                "34e3ba89eeea0298",
                "02587be9c5cb7884"
            ],
            [
                "7e1da9b6079a8472",
                "87ca8679be419b91"
            ]
        ]
    },
    {
        "id": "94f0ac3346a3cc5b",
        "type": "change",
        "z": "adb7fb22534e4439",
        "g": "0fa8a5697424de98",
        "name": "",
        "rules": [
            {
                "t": "move",
                "p": "payload.pc.cod:binSh",
                "pt": "msg",
                "to": "payload.binSh",
                "tot": "msg"
            },
            {
                "t": "move",
                "p": "payload.pc.mio:coSLd",
                "pt": "msg",
                "to": "payload.coSLd",
                "tot": "msg"
            },
            {
                "t": "move",
                "p": "payload.pc.mio:aiQSr",
                "pt": "msg",
                "to": "payload.aiQSr",
                "tot": "msg"
            },
            {
                "t": "delete",
                "p": "payload.pc",
                "pt": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 420,
        "y": 2160,
        "wires": [
            [
                "f4ba36b2fc40b078"
            ]
        ]
    },
    {
        "id": "dd0b9d7f5792c2a8",
        "type": "ui_gauge",
        "z": "adb7fb22534e4439",
        "g": "0fa8a5697424de98",
        "name": "sensor1_co2",
        "group": "34cacb610d5ce59a",
        "order": 1,
        "width": 10,
        "height": 5,
        "gtype": "gage",
        "title": "CO2",
        "label": "ppm",
        "format": "{{msg.payload}}",
        "min": "400",
        "max": "5000",
        "colors": [
            "#00ff00",
            "#ffff00",
            "#ff0000"
        ],
        "seg1": "1000",
        "seg2": "2000",
        "className": "",
        "x": 890,
        "y": 2020,
        "wires": []
    },
    {
        "id": "02587be9c5cb7884",
        "type": "ui_gauge",
        "z": "adb7fb22534e4439",
        "g": "0fa8a5697424de98",
        "name": "sensor1_temp",
        "group": "34cacb610d5ce59a",
        "order": 3,
        "width": 10,
        "height": 5,
        "gtype": "gage",
        "title": "Temperature",
        "label": "C",
        "format": "{{msg.payload}}",
        "min": "0",
        "max": "35",
        "colors": [
            "#0000ff",
            "#00ff00",
            "#ff0000"
        ],
        "seg1": "18",
        "seg2": "25",
        "className": "",
        "x": 900,
        "y": 2140,
        "wires": []
    },
    {
        "id": "87ca8679be419b91",
        "type": "ui_gauge",
        "z": "adb7fb22534e4439",
        "g": "0fa8a5697424de98",
        "name": "sensor1_hum",
        "group": "34cacb610d5ce59a",
        "order": 2,
        "width": 10,
        "height": 5,
        "gtype": "gage",
        "title": "Humidity",
        "label": "% r.H.",
        "format": "{{msg.payload}}",
        "min": "0",
        "max": "100",
        "colors": [
            "#ff0000",
            "#3de600",
            "#ff0000"
        ],
        "seg1": "35",
        "seg2": "65",
        "className": "",
        "x": 900,
        "y": 2260,
        "wires": []
    },
    {
        "id": "61dd47430c5c33f5",
        "type": "ui_button",
        "z": "adb7fb22534e4439",
        "g": "f4c81fefd53c0a27",
        "name": "led_green",
        "group": "0d4624da7b163895",
        "order": 5,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "LED green",
        "tooltip": "",
        "color": "white",
        "bgcolor": "green",
        "className": "",
        "icon": "lightbulb_outline",
        "payload": "",
        "payloadType": "str",
        "topic": "topic",
        "topicType": "msg",
        "x": 800,
        "y": 1620,
        "wires": [
            [
                "6ff606062947f5d5"
            ]
        ]
    },
    {
        "id": "6d2c05e03a82c210",
        "type": "ui_switch",
        "z": "adb7fb22534e4439",
        "g": "f4c81fefd53c0a27",
        "name": "led_switch",
        "label": "LED on/off",
        "tooltip": "",
        "group": "0d4624da7b163895",
        "order": 3,
        "width": 0,
        "height": 0,
        "passthru": true,
        "decouple": "false",
        "topic": "topic",
        "topicType": "msg",
        "style": "",
        "onvalue": "true",
        "onvalueType": "bool",
        "onicon": "",
        "oncolor": "",
        "offvalue": "false",
        "offvalueType": "bool",
        "officon": "",
        "offcolor": "",
        "animate": false,
        "className": "",
        "x": 810,
        "y": 1540,
        "wires": [
            [
                "74e8bd282dd045ef"
            ]
        ]
    },
    {
        "id": "6ef5d159e10807ce",
        "type": "ui_button",
        "z": "adb7fb22534e4439",
        "g": "f4c81fefd53c0a27",
        "name": "led_light green",
        "group": "0d4624da7b163895",
        "order": 6,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "LED lightgreen",
        "tooltip": "",
        "color": "white",
        "bgcolor": "lightgreen",
        "className": "",
        "icon": "lightbulb_outline",
        "payload": "",
        "payloadType": "str",
        "topic": "topic",
        "topicType": "msg",
        "x": 820,
        "y": 1660,
        "wires": [
            [
                "91ec0bd7451c3d47"
            ]
        ]
    },
    {
        "id": "8581c87186e29380",
        "type": "ui_button",
        "z": "adb7fb22534e4439",
        "g": "f4c81fefd53c0a27",
        "name": "led_yellow",
        "group": "0d4624da7b163895",
        "order": 7,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "LED yellow",
        "tooltip": "",
        "color": "black",
        "bgcolor": "yellow",
        "className": "",
        "icon": "lightbulb_outline",
        "payload": "",
        "payloadType": "str",
        "topic": "topic",
        "topicType": "msg",
        "x": 810,
        "y": 1700,
        "wires": [
            [
                "cfd2f206bfa929e0"
            ]
        ]
    },
    {
        "id": "9c4b8ea9a0c10f10",
        "type": "ui_button",
        "z": "adb7fb22534e4439",
        "g": "f4c81fefd53c0a27",
        "name": "led_orange",
        "group": "0d4624da7b163895",
        "order": 8,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "LED orange",
        "tooltip": "",
        "color": "white",
        "bgcolor": "orange",
        "className": "",
        "icon": "lightbulb_outline",
        "payload": "",
        "payloadType": "str",
        "topic": "topic",
        "topicType": "msg",
        "x": 810,
        "y": 1740,
        "wires": [
            [
                "ddb655349eed3e60"
            ]
        ]
    },
    {
        "id": "c67ce9f9eecd46f3",
        "type": "ui_button",
        "z": "adb7fb22534e4439",
        "g": "f4c81fefd53c0a27",
        "name": "led_red",
        "group": "0d4624da7b163895",
        "order": 9,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "LED red",
        "tooltip": "",
        "color": "white",
        "bgcolor": "red",
        "className": "",
        "icon": "lightbulb_outline",
        "payload": "",
...

This file has been truncated, please download it to see its full contents.

Sensornode Code

C/C++
#define ASYNC_TCP_SSL_ENABLED 1
#include <WiFi.h>
#include <Ticker.h>
#include <Adafruit_SCD30.h>
#include <string.h>
#include <AsyncMqtt_Generic.h>

extern "C"
{
  #include "freertos/FreeRTOS.h"
  #include "freertos/timers.h"
}

#define ms_to_min 60000
//##################################################################################
//##################################################################################
// Change Change Change >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#define send_interval_in_min 1

#define WIFI_SSID "<your SSID>"
#define WIFI_PASSWORD "<your Password>"

#define ASYNC_TCP_SSL_ENABLED true

#define MQTT_HOST "<your Host>"     

//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Change Change Change
//##################################################################################
//##################################################################################

#if ASYNC_TCP_SSL_ENABLED

  #define MQTT_SECURE true
                // Fingerprint of provided crt if you use custom crts you have to change the fingerprint
  const uint8_t MQTT_SERVER_FINGERPRINT[] = {0xBD,0x0F,0x36,0xDC,0x1C,0x05,0xB8,0xBB,0xD1,0x6C,0xA5,0xC1,0x99,0xD9,0xFA,0xE8,0x0B,0xCD,0x8E,0x85,0xF8,0xF4,0xA5,0x7C,0x3E,0x98,0x1D,0x5E,0x82,0x3D,0xD2,0xB5};
  const char *PubTopic  = "async-mqtt/ESP32_SSL_Pub";               // Test Topic to publish
  
  #define MQTT_PORT 8883 //default port change if other ise used
  
#else

  const char *PubTopic  = "async-mqtt/ESP32_Pub";                   // Test Topic to publish
  
  #define MQTT_PORT 1883 //default port change if other ise used
  
#endif

AsyncMqttClient mqttClient;
TimerHandle_t mqttReconnectTimer;
TimerHandle_t wifiReconnectTimer;

//#########################################################################
//OneM2M MQTT Default mgf

#define NEW_ROOM_MSG "{\"fr\": \"aid\",\"to\": \"cse-in/airQualityMonitoring\",\"op\": 1,\"rvi\": \"3\",\"rqi\": \"1234562\",\"id\": \"ab\",\"srn\": \"as\",\"pc\": {\"m2m:cnt\":\"acpi\":[\"cse-in/acr_admin\",\"cse-in/acr_room1\"],{\"rn\": \"room%i\"}},\"ty\": 3}"
#define NEW_FlexContainer_devAir  "{\"fr\":\"room%i\",\"to\":\"cse-in/airQualityMonitoring/room%i\",\"op\":1,\"rvi\":\"3\",\"rqi\":\"1234562\",\"pc\":{\"mio:devAir\":{\"acpi\":[\"cse-in/acr_admin\",\"cse-in/acr_room%i\"],\"cnd\":\"org.fhtwmio.common.device.mioDeviceAirQualitySensor\",\"rn\":\"sensor\"}},\"ty\":28}"
#define NEW_FlexContainer_mio_aiQSr "{\"fr\":\"room%i\",\"to\":\"cse-in/airQualityMonitoring/room%i/sensor\",\"op\":1,\"rvi\":\"3\",\"rqi\":\"1234562\",\"pc\":{\"mio:aiQSr\":{\"acpi\":[\"cse-in/acr_admin\",\"cse-in/acr_room%i\"],\"cnd\":\"org.fhtwmio.common.moduleclass.mioAirqualitySensor\",\"rn\":\"value\",\"co2\":0,\"temp\":0,\"hum\":0}},\"ty\":28}"
#define UPDATE_SENSOR "{\"fr\":\"room%i\",\"to\":\"cse-in/airQualityMonitoring/room%i/sensor/value\",\"op\":3,\"rvi\":\"3\",\"rqi\":\"1234562\",\"pc\":{\"mio:aiQSr\":{\"co2\":%lf,\"temp\":%lf,\"hum\":%lf}},\"ty\":28}"

#define dip0 25
#define dip1 33
#define dip2 32
#define dip3 35
uint8_t roomnr = 0b0;

//##################################################################################
//##################################################################################

Adafruit_SCD30  scd30;

// MQTT ##############################################################
void connectToWifi()
{
  Serial.println("Connecting to Wi-Fi...");
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
}

void connectToMqtt()
{
  Serial.println("Connecting to MQTT...");
  mqttClient.connect();
}

void WiFiEvent(WiFiEvent_t event)
{
  switch (event)
  {
#if USING_CORE_ESP32_CORE_V200_PLUS
    case ARDUINO_EVENT_WIFI_READY:
      Serial.println("WiFi ready");
      break;
    case ARDUINO_EVENT_WIFI_STA_START:
      Serial.println("WiFi STA starting");
      break;
    case ARDUINO_EVENT_WIFI_STA_CONNECTED:
      Serial.println("WiFi STA connected");
      break;
    case ARDUINO_EVENT_WIFI_STA_GOT_IP6:
    case ARDUINO_EVENT_WIFI_STA_GOT_IP:
      Serial.println("WiFi connected");
      Serial.print("IP address: "); Serial.println(WiFi.localIP());
      connectToMqtt();
      break;
    case ARDUINO_EVENT_WIFI_STA_LOST_IP:
      Serial.println("WiFi lost IP");
      break;
    case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
      Serial.println("WiFi lost connection");
      xTimerStop(mqttReconnectTimer, 0); // ensure we don't reconnect to MQTT while reconnecting to Wi-Fi
      xTimerStart(wifiReconnectTimer, 0);
      break;
#else
    case SYSTEM_EVENT_STA_GOT_IP:
      Serial.println("WiFi connected");
      Serial.println("IP address: "); Serial.println(WiFi.localIP());
      connectToMqtt();
      break;
    case SYSTEM_EVENT_STA_DISCONNECTED:
      Serial.println("WiFi lost connection");
      xTimerStop(mqttReconnectTimer, 0); // ensure we don't reconnect to MQTT while reconnecting to Wi-Fi
      xTimerStart(wifiReconnectTimer, 0);
      break;
#endif
      default:
      break;
  }
}

void printSeparationLine()
{
  Serial.println("************************************************");
}

void onMqttConnect(bool sessionPresent) 
{
  Serial.print("Connected to MQTT broker: "); Serial.print(MQTT_HOST);
  Serial.print(", port: "); Serial.println(MQTT_PORT);
  Serial.print("PubTopic: "); Serial.println(PubTopic);
  
  printSeparationLine();
  Serial.print("Session present: "); Serial.println(sessionPresent);
  
  uint16_t packetIdSub = mqttClient.subscribe(PubTopic, 2);
  Serial.print("Subscribing at QoS 2, packetId: "); Serial.println(packetIdSub);

  
  mqttClient.publish(PubTopic, 0, true, "ESP32 Test");
  Serial.println("Publishing at QoS 0");
  
  uint16_t packetIdPub1 = mqttClient.publish(PubTopic, 1, true, "test 2");
  Serial.print("Publishing at QoS 1, packetId: "); Serial.println(packetIdPub1);
  
  uint16_t packetIdPub2 = mqttClient.publish(PubTopic, 2, true, "test 3");
  Serial.print("Publishing at QoS 2, packetId: "); Serial.println(packetIdPub2);

  create_room();

  printSeparationLine();
}

void onMqttDisconnect(AsyncMqttClientDisconnectReason reason)
{
  (void) reason;
  
  Serial.println("Disconnected from MQTT.");

  if (WiFi.isConnected())
  {
    xTimerStart(mqttReconnectTimer, 0);
  }
}

void onMqttSubscribe(const uint16_t& packetId, const uint8_t& qos)
{
  Serial.println("Subscribe acknowledged.");
  Serial.print("  packetId: "); Serial.println(packetId);
  Serial.print("  qos: ");      Serial.println(qos);
}

void onMqttUnsubscribe(const uint16_t& packetId)
{
  Serial.println("Unsubscribe acknowledged.");
  Serial.print("  packetId: "); Serial.println(packetId);
}

void onMqttMessage(char* topic, char* payload, const AsyncMqttClientMessageProperties& properties, 
                   const size_t& len, const size_t& index, const size_t& total)
{
  (void) payload;
  
  Serial.println("Publish received.");
  Serial.print("  topic: ");  Serial.println(topic);
  Serial.print("  qos: ");    Serial.println(properties.qos);
  Serial.print("  dup: ");    Serial.println(properties.dup);
  Serial.print("  retain: "); Serial.println(properties.retain);
  Serial.print("  len: ");    Serial.println(len);
  Serial.print("  index: ");  Serial.println(index);
  Serial.print("  total: ");  Serial.println(total);

}

void onMqttPublish(const uint16_t& packetId)
{
  Serial.println("Publish acknowledged");
  Serial.print("  packetId: "); Serial.println(packetId);
}// MQTT ##############################################################


void create_room(){

  char msg [350]; 

  sprintf(msg,NEW_ROOM_MSG,roomnr);                
  mqttClient.publish("/oneM2M/req/aqm/id-in/json",1,true,msg);

  delay(500);

  sprintf(msg,NEW_FlexContainer_devAir,roomnr,roomnr,roomnr);                
  mqttClient.publish("/oneM2M/req/aqm/id-in/json",1,true,msg);

  delay(500);

  sprintf(msg,NEW_FlexContainer_mio_aiQSr,roomnr,roomnr,roomnr);                
  mqttClient.publish("/oneM2M/req/aqm/id-in/json",1,true,msg);

}


void setup() {
  Serial.begin(115200);
  while (!Serial && millis() < 5000);

  Serial.print("\nStarting Sensornode"); Serial.println(ARDUINO_BOARD);  

    // Try to initialize!
  if (!scd30.begin()) {
    Serial.println("Failed to find SCD30 chip");
    while (1) { delay(10); }
  }

  pinMode(dip0, INPUT_PULLUP);
  pinMode(dip1, INPUT_PULLUP);
  pinMode(dip2, INPUT_PULLUP);
  pinMode(dip3, INPUT_PULLUP);

  if (digitalRead(dip0))  roomnr |= 1 ;
  if (digitalRead(dip1))  roomnr |= 2 ; 
  if (digitalRead(dip2))  roomnr |= 4 ; 
  if (digitalRead(dip3))  roomnr |= 8 ;

  Serial.print("Room nr: "); Serial.println(roomnr); 
  Serial.println(digitalRead(dip0));
  Serial.println(digitalRead(dip1));
  Serial.println(digitalRead(dip2));
  Serial.println(digitalRead(dip3));

  Serial.println("SCD30 Found!");

  mqttReconnectTimer = xTimerCreate("mqttTimer", pdMS_TO_TICKS(2000), pdFALSE, (void*)0, reinterpret_cast<TimerCallbackFunction_t>(connectToMqtt));
  wifiReconnectTimer = xTimerCreate("wifiTimer", pdMS_TO_TICKS(2000), pdFALSE, (void*)0, reinterpret_cast<TimerCallbackFunction_t>(connectToWifi));

  WiFi.onEvent(WiFiEvent);

  mqttClient.onConnect(onMqttConnect);
  mqttClient.onDisconnect(onMqttDisconnect);
  mqttClient.onSubscribe(onMqttSubscribe);
  mqttClient.onUnsubscribe(onMqttUnsubscribe);
  mqttClient.onMessage(onMqttMessage);
  mqttClient.onPublish(onMqttPublish);

  mqttClient.setServer(MQTT_HOST, MQTT_PORT);

#if ASYNC_TCP_SSL_ENABLED
  mqttClient.setSecure(MQTT_SECURE);
  
  if (MQTT_SECURE) 
  {
    //mqttClient.addServerFingerprint((const uint8_t[])MQTT_SERVER_FINGERPRINT);
    mqttClient.addServerFingerprint((const uint8_t *)MQTT_SERVER_FINGERPRINT);
  }
#endif

  connectToWifi();

}

void readSCD30(){

    if (scd30.dataReady()){
    Serial.println("Data available!");

    if (!scd30.read()){ Serial.println("Error reading sensor data"); return; }

    Serial.print("Temperature: ");
    Serial.print(scd30.temperature);
    Serial.println(" degrees C");
    
    Serial.print("Relative Humidity: ");
    Serial.print(scd30.relative_humidity);
    Serial.println(" %");
    
    Serial.print("CO2: ");
    Serial.print(scd30.CO2, 3);
    Serial.println(" ppm");
    Serial.println("");

    char msg[350];
    sprintf(msg,UPDATE_SENSOR,roomnr,roomnr,scd30.CO2,scd30.temperature,scd30.relative_humidity);
    mqttClient.publish("/oneM2M/req/aqm/id-in/json",1,true,msg);
    Serial.print(msg);
  
  } else {
    //Serial.println("No data");
  }
  
}


void loop() {   
 
      readSCD30();
      delay(ms_to_min * send_interval_in_min);
 
}

mio_aid.conf

Plain text
Configuration file for the certificate creation
# The main section is named req because the command we are using is req
# (openssl req ...)
[ req ]
# This specifies the default key size in bits. If not specified then 512 is
# used. It is used if the -new option is used. It can be overridden by using
# the -newkey option. 
default_bits = 4096

# This is the default filename to write a private key to. If not specified the
# key is written to standard output. This can be overridden by the -keyout
# option.
default_keyfile = mio_aid.key

# If this is set to no then if a private key is generated it is not encrypted.
# This is equivalent to the -nodes command line option. For compatibility
# encrypt_rsa_key is an equivalent option. 
encrypt_key = no

# This option specifies the digest algorithm to use. Possible values include
# md5 sha1 mdc2. If not present then MD5 is used. This option can be overridden
# on the command line.
default_md = sha512

# if set to the value no this disables prompting of certificate fields and just
# takes values from the config file directly. It also changes the expected
# format of the distinguished_name and attributes sections.
prompt = no

# if set to the value yes then field values to be interpreted as UTF8 strings,
# by default they are interpreted as ASCII. This means that the field values,
# whether prompted from a terminal or obtained from a configuration file, must
# be valid UTF8 strings.
utf8 = yes

# This specifies the section containing the distinguished name fields to
# prompt for when generating a certificate or certificate request.
distinguished_name = my_req_distinguished_name


# this specifies the configuration file section containing a list of extensions
# to add to the certificate request. It can be overridden by the -reqexts
# command line switch. See the x509v3_config(5) manual page for details of the
# extension section format.
req_extensions = my_extensions

[ my_req_distinguished_name ]
C = AT
ST = Vienna
L = Vienna
O  = MIO_AID
CN = localhost

[ my_extensions ]
basicConstraints=CA:FALSE
subjectAltName=@my_subject_alt_names
subjectKeyIdentifier = hash

[ my_subject_alt_names ]
DNS.1 = mosquitto
DNS.2 = cse
DNS.3 = zigbeem2qtt
DNS.4 = nodered
DNS.5 = grafana
DNS.6 = portainer

ca.conf

Plain text
Configuration file for the CA creation
# we use 'ca' as the default section because we're usign the ca command
# we use 'ca' as the default section because we're usign the ca command
[ ca ]
default_ca = my_ca

[ my_ca ]
#  a text file containing the next serial number to use in hex. Mandatory.
#  This file must be present and contain a valid serial number.
serial = ./serial

# the text database file to use. Mandatory. This file must be present though
# initially it will be empty.
database = ./index.txt

# specifies the directory where new certificates will be placed. Mandatory.
new_certs_dir = ./newcerts

# the file containing the CA certificate. Mandatory
certificate = ./ca.crt

# the file contaning the CA private key. Mandatory
private_key = ./ca.key

# the message digest algorithm. Remember to not use MD5
default_md = sha1

# for how many days will the signed certificate be valid
default_days = 365

# a section with a set of variables corresponding to DN fields
policy = my_policy

[ my_policy ]
# if the value is "match" then the field value must match the same field in the
# CA certificate. If the value is "supplied" then it must be present.
# Optional means it may be present. Any fields not mentioned are silently
# deleted.
countryName = match
stateOrProvinceName = supplied
organizationName = supplied
commonName = supplied
organizationalUnitName = optional
commonName = supplied

[ ca ]
default_ca = my_ca

[ my_ca ]
#  a text file containing the next serial number to use in hex. Mandatory.
#  This file must be present and contain a valid serial number.
serial = ./serial

# the text database file to use. Mandatory. This file must be present though
# initially it will be empty.
database = ./index.txt

# specifies the directory where new certificates will be placed. Mandatory.
new_certs_dir = ./newcerts

# the file containing the CA certificate. Mandatory
certificate = ./ca.crt

# the file contaning the CA private key. Mandatory
private_key = ./ca.key

# the message digest algorithm. Remember to not use MD5
default_md = sha512

# for how many days will the signed certificate be valid
default_days = 365

# a section with a set of variables corresponding to DN fields
policy = my_policy

[ my_policy ]
# if the value is "match" then the field value must match the same field in the
# CA certificate. If the value is "supplied" then it must be present.
# Optional means it may be present. Any fields not mentioned are silently
# deleted.
countryName = match
stateOrProvinceName = supplied
organizationName = supplied
commonName = supplied
organizationalUnitName = optional
commonName = supplied

mio_aid.extensions.conf

Plain text
Configuration file for x509 extensions to mio_aid.crt certificate
basicConstraints=CA:FALSE
subjectAltName=@my_subject_alt_names
subjectKeyIdentifier = hash

[ my_subject_alt_names ]
DNS.1 = mosquitto
DNS.2 = cse
DNS.3 = zigbee2mqtt
DNS.4 = nodered
DNS.5 = portainer
DNS.6 = grafana

automations.py

Python
Automation File for Notification Server
from __future__ import annotations
from automations import *
from http.client import HTTPMessage
from typing import cast
from http.server import HTTPServer, BaseHTTPRequestHandler
import email.parser
import json, argparse, sys, ssl, signal
import cbor2
from rich.console import Console
from rich.syntax import Syntax
import paho.mqtt.client as mqtt
import pathlib, os
parent = pathlib.Path(os.path.abspath(os.path.dirname(__file__))).parent.parent
sys.path.append(f'{parent}')
from acme.helpers.MQTTConnection import *
from acme.helpers.TextTools import toHex
from acme.etc.RequestUtils import serializeData
from acme.etc.DateUtils import getResourceDate
from acme.etc.Types import ContentSerializationType
from acme.etc.Constants import Constants as C

###MQTT Data to publish
topic = "/oneM2M/req/aqm/id-in/json"

actuatorStatusTrue={"fr":"room1","to":"cse-in/airQualityMonitoring/room1/actuator/status","op":3,"rvi":"3","rqi":"1234562","pc":{"cod:binSh":{"powSe":True}},"ty":28}
actuatorStatusFalse={"fr": "room1","to": "cse-in/airQualityMonitoring/room1/actuator/status","op": 3,"rvi": "3","rqi": "1234562","pc": {"cod:binSh": {"powSe": False}},"ty": 28}
colorLedRed={"fr":"room1","to":"cse-in/airQualityMonitoring/room1/led/color","op":"3","rvi":3,"rqi":"1234562","pc":{"mio:coSLd":{"hue":3,"sat":96,"x":0.6307692307692307,"y":0.3230769230769231,"colT":319}},"ty":28}
colorLedOrange={"fr":"room1","to":"cse-in/airQualityMonitoring/room1/led/color","op":"3","rvi":3,"rqi":"1234562", "pc": {"mio:coSLd": {"hue": 12,"sat": 97,"x": 0.5945945945945946,"y": 0.36486486486486486,"colT": 454}},"ty":28}
colorLedYellow={"fr":"room1","to":"cse-in/airQualityMonitoring/room1/led/color","op":"3","rvi":3,"rqi":"1234562","pc":{"mio:coSLd":{"hue":66,"sat":93,"x":0.41847826086956524,"y":0.5054347826086957,"colT":255}},"ty":28}
colorLedLightGreen={"fr":"room1","to":"cse-in/airQualityMonitoring/room1/led/color","op":"3","rvi":3,"rqi":"1234562","pc":{"mio:coSLd":{"hue":98,"sat":93,"x":0.3203125,"y":0.578125,"colT":250}},"ty":28}
colorLedDarkGreen={"fr":"room1","to":"cse-in/airQualityMonitoring/room1/led/color","op":"3","rvi":3,"rqi":"1234562","pc":{"mio:coSLd":{"hue":104,"sat":93,"x":0.2962962962962963,"y":0.5925925925925926,"colT":250}},"ty":28}
colorLedOff={"fr":"room1","to":"cse-in/airQualityMonitoring/room1/led/color","op":"3","rvi":3,"rqi":"1234562","pc":{"mio:coSLd":{"powSe":False}},"ty":28}
###threshold values
ledDarkGreen = 1000
ledLightGreen = 1500
ledYellow = 2000
ledOrange = 3000
actuatorOnTh = 2000
actuatorOffTh = 1000
###automation code ###
def automation(mqttClient,post_data):### function needs MQTT Client and received Sensor data from ACME
    ###retrieve CO2,Temperature and Humidity values
    y = json.loads(post_data)
    sensorCo2=float(y["m2m:sgn"]["nev"]["rep"]["mio:aiQSr"]["co2"])
    sensorHum=float(y["m2m:sgn"]["nev"]["rep"]["mio:aiQSr"]["hum"])
    sensorTemp=float(y["m2m:sgn"]["nev"]["rep"]["mio:aiQSr"]["temp"])

    ###automation States
    green=sensorCo2 < ledDarkGreen
    lightGreen= ledDarkGreen <= sensorCo2 <ledLightGreen
    yellow = ledLightGreen <= sensorCo2 <ledYellow
    orange = ledYellow <= sensorCo2 < ledOrange
    red = sensorCo2>ledOrange
    aktuatorOn = sensorCo2>actuatorOnTh
    actuatorOff =sensorCo2<actuatorOffTh

    ###automation process
    if red:
        print("Luft Qualitt sehr schlecht: " + "Co2: " +str(sensorCo2)+"ppm " +"Temp: "+str(sensorTemp )+" " +"Hum: "+str(sensorHum)+"%")
        mqttClient.publish(topic,json.dumps(colorLedRed))
    if orange:
        print("Luft Qualitt schlecht: " + "Co2: " +str(sensorCo2)+"ppm " +"Temp: "+str(sensorTemp )+" " +"Hum: "+str(sensorHum)+"%")
        mqttClient.publish(topic,json.dumps(colorLedOrange))
    if yellow:
        print("Luft Qualitt mittelmig: " + "Co2: " +str(sensorCo2)+"ppm " +"Temp: "+str(sensorTemp )+" " +"Hum: "+str(sensorHum)+"%")
        mqttClient.publish(topic,json.dumps(colorLedYellow))
    if lightGreen:
        print("Luft Qualitt gut: " + "Co2: " +str(sensorCo2)+"ppm " +"Temp: "+str(sensorTemp )+" " +"Hum: "+str(sensorHum)+"%")
        mqttClient.publish(topic,json.dumps(colorLedLightGreen))
    if green:
        print("Luft Qualitt sehr gut: " + "Co2: " +str(sensorCo2)+"ppm " +"Temp: "+str(sensorTemp )+" " +"Hum: "+str(sensorHum)+"%")
        mqttClient.publish(topic,json.dumps(colorLedDarkGreen))
    if aktuatorOn:
        mqttClient.publish(topic,json.dumps(actuatorStatusTrue))
    if actuatorOff:
        mqttClient.publish(topic,json.dumps(actuatorStatusFalse))

Credits

Jiri Dockal

Jiri Dockal

1 project • 2 followers
stohamart

stohamart

1 project • 1 follower
Matthias Wirthmann

Matthias Wirthmann

1 project • 1 follower
Philipp Grießer

Philipp Grießer

1 project • 1 follower
Ahmed Mohamed

Ahmed Mohamed

1 project • 1 follower
Andreas Kraft

Andreas Kraft

34 projects • 12 followers
IoT & connected home architect and developer. Ask me about oneM2M.
Miguel Angel Reina Ortega

Miguel Angel Reina Ortega

35 projects • 7 followers
Wonbae Son

Wonbae Son

32 projects • 5 followers
SeungMyeong Jeong

SeungMyeong Jeong

34 projects • 12 followers
Xavier Piednoir

Xavier Piednoir

26 projects • 6 followers
Bob Flynn

Bob Flynn

32 projects • 13 followers

Comments