Skip to content

Commit

Permalink
Push plug state to MQTT
Browse files Browse the repository at this point in the history
* all events are pushed to /service/plug/$plugname
* plug state is sent as retained status message
  • Loading branch information
elsbrock committed Jun 6, 2014
1 parent d76765d commit 8052604
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion fhem-appendix.cfg
@@ -1,4 +1,4 @@
define jeelink JeeLink /dev/ttyUSB0@57600
define jeelink JeeLink /dev/rfm12b-nano@57600

define PCA301_0FA4E4 PCA301 0FA4E4 01
attr PCA301_0FA4E4 alias drucker
Expand Down Expand Up @@ -59,3 +59,19 @@ attr PCA301_05540D webCmd on:off:toggle:statusRequest
define FileLog_PCA301_05540D FileLog ./log/PCA301_05540D-%Y.log PCA301_05540D
attr FileLog_PCA301_05540D logtype text
attr FileLog_PCA301_05540D room PCA301

# MQTT push
define mqttPush notify PCA301.* {\
my $alias = $attr{$NAME}{'alias'};;\
my ($evname, $val) = split(':', $EVENT);;\
my $retain = '';;\
\
if ($evname eq 'off' || $evname eq 'on') {\
$val = $evname;;\
$evname = 'state';;\
$retain = '-r';;\
}\
\
system("mosquitto_pub $retain -t /service/plug/$alias/$evname -m $val");;\
return 0;;\
}

0 comments on commit 8052604

Please sign in to comment.