-
Notifications
You must be signed in to change notification settings - Fork 7
/
mmqt.h
179 lines (146 loc) · 4.04 KB
/
mmqt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#ifndef _MMQT_h
#define _MMQT_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
#endif
#include "config_TPM.h"
/*
Home Assistant config
configuration.yaml
light:
- platform: mqtt
name: "WZ gate"
state_topic: "TinyPixelMapperWZ/device/status"
command_topic: "TinyPixelMapperWZ/device/set"
#brightness_state_topic: 'TinyPixelMapperWZ/bri/status'
#brightness_command_topic: 'TinyPixelMapperWZ/bri/set'
qos: 0
payload_on: "on"
payload_off: "off"
optimistic: false
input_select:
tinxpixelmapper:
name: TinxPixelMapper
options:
- '0 Startup'
- '1'
- '2'
- '3'
input_number:
tinypixelmapper_fps:
name: TinyPixelMapper FPS
min: 1
max: 90
step: 1
unit_of_measurement: fps
icon: mdi:target
tinypixelmapper_bri:
name: TinyPixelMapper Bri
min: 0
max: 255
step: 1
#unit_of_measurement: fps
#icon: mdi:target
automation.yaml
- id: tpm_play_select
alias: Set Play mode
description: ''
trigger:
- entity_id: input_select.tinxpixelmapper
platform: state
condition: []
action:
service: mqtt.publish
data:
topic: TinyPixelMapperWZ/play/set
payload_template: "{% if is_state(\"input_select.TinxPixelmapper\", \"0 Startup\"\
) %}\n 0 \n{% elif is_state(\"input_select.TinxPixelmapper\", \"\
1\") %}\n 1\n{% elif is_state(\"input_select.TinxPixelmapper\", \"2\") %}\n\
\ 2\n{% elif is_state(\"input_select.TinxPixelmapper\", \"3\") %}\n 3\n\
{% endif %}"
- id: tpm_get_fps
alias: Set FPS slider
trigger:
platform: mqtt
topic: TinyPixelMapperWZ/fps/status
action:
service: input_number.set_value
data_template:
entity_id: input_number.tinypixelmapper_fps
value: '{{ trigger.payload }}'
- id: tpm_set_fps
alias: FPS slider moved
trigger:
- entity_id: input_number.tinypixelmapper_fps
platform: state
action:
- data:
payload_template: '{{ states(''input_number.tinypixelmapper_fps'') | int }}'
topic: TinyPixelMapperWZ/fps/set
service: mqtt.publish
- id: tpm_get_bri
alias: Set bri slider
trigger:
platform: mqtt
topic: TinyPixelMapperWZ/bri/status
action:
service: input_number.set_value
data_template:
entity_id: input_number.tinypixelmapper_bri
value: '{{ trigger.payload }}'
- id: tpm_set_bri
alias: bri slider moved
trigger:
- entity_id: input_number.tinypixelmapper_bri
platform: state
action:
- data:
payload_template: '{{ states(''input_number.tinypixelmapper_bri'') | int }}'
topic: TinyPixelMapperWZ/bri/set
service: mqtt.publish
*/
// MMQT Topics
//
// The topics are automatically generated
// deviceName/Function/action
//
// device: APname / deviceName
// Action: /set = subsribe topic to set something in the TPM
// /status = publish the status of the Function
// Functions : /device = Is it on or off
// /bri = Master fader
// /play = Play nummer / config
// /fps = Speed
//
// try 2
#define MMQT_TOPIC_SEND "/status"
#define MMQT_TOPIC_RECIVE "/set"
#define MMQT_TOPIC_FUNCTION_PLAY "/play"
#define MMQT_TOPIC_FUNCTION_BRI "/bri"
#define MMQT_TOPIC_FUNCTION_DEVICE "/device"
#define MMQT_TOPIC_FUNCTION_FPS "/fps"
#define MMQT_TOPIC_FUNCTION_TEMP "/temp"
//#define MMQT_DEF_NAME "TPM-WZ"
#define MMQT_DEF_USER "lights"
#define MMQT_DEF_PASSWORD "lights123"
#define MQTT_DEF_PORT 1883
#define MQTT_DEF_PUBLISH_TIMEOUT 60 // in seconds
//#define MMQT_ENABLED false
void MMQT_setup();
void MMQT_loop() ;
struct MMQT_config_struct
{
boolean enabled;
};
struct mqtt_Struct
{
char username[16]; // The mqtt username
char password[16]; // The mqtt password
uint8_t mqttIP[4]; // mqtt ip address
//uint8_t mqttIP2;
//uint8_t mqttIP3;
//uint8_t mqttIP4;
uint16_t mqttPort; // mqtt port
uint16_t publishSec;
};
#endif