- Hardware: Raspberry Pi 3 Model B Rev 1.2
- OS: Raspbian GNU/Linux 10 (buster)
- Java Runtime Environment: zulu
- openHAB version: 2.5.10-1
- Working MQTT environment that has sensors publishing data and recording onto a SQLite database
Hi,
I’ve successfully manage to program an ESP8622 HUZZAH board to wake up from deep sleep, and then posting the following to my MQTT listening on the OH2 platform. I’ve successfully verified this by connecting MQTTfx to the server and subscribing to the following topic (line in the Arduino sketch):
client.publish("Home/Ground Floor/Front Door Bell", "Ring");
when the button is pressed. That is great but now I’m wondering what the next step is. I guess I need to create a thing
and item
and once these are create, I need to create a rule
that activates a relay or something similar on another ESP that play a tune and/or switches on a little LED to notify my family that someone is at the door. I see that this topic is similar although quite old.
What I don’t quite understand is whether I should be treating this as a switch
so that my thing
would look like the following:
Thing mqtt:topic:frontdoorbell “Door Bell” {
Channels:
Type switch : doorbell “Door Bell” [ stateTopic=“Home/Ground Floor/Front Door/Bell” ]
}
I would then create an item like so:
Switch FrontDoorBell “Front Door Bell” {channel=“mqtt:broker:topic:frontdoorbell:doorbell”}
I’m not quite sure but I guess the next step would be that when the MQTT broker receives the above message, OH2 would then have to have a rule that reacts to the above message? The reaction would be (in my idea) to activate another ESP device, (or even better a pi zero?) that is listening for this message and commands to play a tune. Any thoughts on how I go about from here?
I guess my two next big challenges are:
a) creating the rule upon which OH2 enacts to the pressing of the button (at the end of this post, which I copied below for convenience, a possible solution is proposed … do you think this will work?)
b) how I choose to build the listening device; looks like ESP or Pi zero wouldn’t be good options if they are sitting there waiting for a message … they would just be using lots of battery power.
rule “mechanical door bell pressed”
when
//Item MechanicalDoorBell received command or
//Item MechanicalDoorBell changed
Item MechanicalDoorBell received update
then
var msg = “The mechanical door bell was pushed.”
sendBroadcastNotification(msg)
playSound(“doorbell.mp3”)
logInfo(“SAH”, msg)
//say(msg, “voicerss:enUS”, “chromecast:audiogroup:PublicSpeakers”, new PercentType(100))
end