1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-02 03:12:20 +01:00

Add MQTT publish JSON action and subscribe JSON trigger (#193)

* Add MQTT publish JSON action and subscribe JSON trigger

* Lint
This commit is contained in:
Otto Winter
2018-10-20 12:41:00 +02:00
committed by GitHub
parent 81bc400340
commit 629f2b128e
11 changed files with 233 additions and 140 deletions

View File

@@ -73,6 +73,24 @@ mqtt:
then:
- deep_sleep.enter:
id: deep_sleep_1
on_json_message:
topic: the/topic
then:
- lambda: |-
int data = x["my_data"];
ESP_LOGD("main", "The data is: %d", data);
- light.turn_on:
id: living_room_lights
transition_length: !lambda |-
int length = 1000;
if (x.containsKey("length"))
length = x["length"];
return length;
effect: !lambda |-
const char *effect = "None";
if (x.containsKey("effect"))
effect = x["effect"];
return effect;
i2c:
sda: 21
@@ -599,6 +617,7 @@ light:
state = 0;
- platform: rgb
name: "Living Room Lights"
id: living_room_lights
red: pca_0
green: pca_1
blue: pca_2

View File

@@ -76,7 +76,14 @@ sensor:
- platform: mqtt_subscribe
name: "MQTT Subscribe Sensor 1"
topic: "mqtt/topic"
id: the_sensor
qos: 2
on_value:
- mqtt.publish_json:
topic: the/topic
payload: |-
root["key"] = id(the_sensor).value;
root["greeting"] = "Hello World";
- platform: cse7766
voltage:
name: "CSE7766 Voltage"