2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-12 22:56:34 +00:00

introduced readingsBulkUpdate, readingsSingleUpdate

introduced GPLv2

git-svn-id: https://svn.fhem.de/fhem/trunk@2099 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
borisneubert 2012-11-08 20:56:21 +00:00
parent 6ea70d394e
commit bf3d1a0700
24 changed files with 399 additions and 244 deletions

View File

@ -8,6 +8,8 @@
- feature: autoloading commands, XmlList/etc renamed from 99 to 98.
- feature: FHEMWEB returns external files in chunks to save memory
- feature: commandref.html splitted: documentation is now appended to the modules.
- change: introduced readingsBulkUpdate, readingsSingleUpdate
- change: added GPLv2 licensing information
- 2012-10-28 (5.3)
- feature: added functions trim, ltrim, rtrim, UntoggleDirect, UntoggleIndirect

View File

@ -1,5 +1,5 @@
##############################################
# $Id: 00_ZWDongle.pm 1721 2012-07-11 14:48:24Z rudolfkoenig $
# $Id$
# TODO:
# - routing commands
# - one command to create a fhem device for all nodeList entries

View File

@ -5,7 +5,7 @@
# e-mail: omega at online dot de
#
##############################################
# $Id $
# $Id$
package main;
use strict;
@ -619,7 +619,7 @@ RSS_CGI(){
is loaded from the URL <arg>. You can use
<code>{ <a href="#perl">&lt;perl special&gt;</a> }</code> for &lt;arg&gt. See below for example.
Notice: do not load the image from URL that is served by fhem as it leads to a deadlock.<br></li>
</li><br>
<br>
</ul>
This is how a layout definition might look like:<p>

View File

@ -1,5 +1,26 @@
#############################################
# $Id$
##############################################################################
#
# 11_FHT.pm
# Copyright by
# e-mail:
#
# This file is part of fhem.
#
# Fhem is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Foobar is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with fhem. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
package main;
use strict;
@ -522,16 +543,16 @@ FHT_Parse($$)
$val = $nVal? $nVal : "none";
# set additional warnings and trigger notify
readingsUpdate($def, "battery", $valBattery);
readingsBulkUpdate($def, "battery", $valBattery);
Log $ll4, "FHT $name battery: $valBattery";
readingsUpdate($def, "lowtemp", $valLowTemp);
readingsBulkUpdate($def, "lowtemp", $valLowTemp);
Log $ll4, "FHT $name lowtemp: $valLowTemp";
readingsUpdate($def, "window", $valWindow);
readingsBulkUpdate($def, "window", $valWindow);
Log $ll4, "FHT $name window: $valWindow";
readingsUpdate($def, "windowsensor", $valSensor);
readingsBulkUpdate($def, "windowsensor", $valSensor);
Log $ll4, "FHT $name windowsensor: $valSensor";
}
@ -539,10 +560,10 @@ FHT_Parse($$)
$cmd = "FHZ:$cmd";
} else {
readingsUpdate($def, $cmd, $val);
readingsBulkUpdate($def, $cmd, $val);
if($cmd eq "measured-temp") {
$def->{STATE} = "$cmd: $val";
readingsUpdate($def, "temperature", $val);
readingsBulkUpdate($def, "temperature", $val);
}
}

View File

@ -1,30 +1,31 @@
#################################################################################
# 46_TRX_LIGHT.pm
# $Id$
##############################################################################
#
# FHEM module for lighting protocols:
# X10 lighting, ARC, ELRO AB400D, Waveman, Chacon EMW200,
# IMPULS, AC (KlikAanKlikUit, NEXA, CHACON, HomeEasy UK),
# HomeEasy EU, ANSLUT, Ikea Koppla
# 46_TRX_LIGHT.pm
# FHEM module for lighting protocols:
# X10 lighting, ARC, ELRO AB400D, Waveman, Chacon EMW200,
# IMPULS, AC (KlikAanKlikUit, NEXA, CHACON, HomeEasy UK),
# HomeEasy EU, ANSLUT, Ikea Koppla
# Copyright by Willi Herzig
# e-mail:
#
# Copyright (C) 2012 Willi Herzig
# This file is part of fhem.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# Fhem is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# Fhem is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# The GNU General Public License may also be found at http://www.gnu.org/licenses/gpl-2.0.html .
# You should have received a copy of the GNU General Public License
# along with fhem. If not, see <http://www.gnu.org/licenses/>.
#
##################################
##############################################################################
#
# values for "set global verbose"
# 4: log unknown protocols
@ -489,7 +490,7 @@ sub TRX_LIGHT_parse_X10 {
$sensor = $firstdevice == 1 ? $def->{TRX_LIGHT_devicelog} : $def->{TRX_LIGHT_devicelog2};
$val .= $current;
readingsUpdate($def, $sensor, $current);
readingsBulkUpdate($def, $sensor, $current);
} else {
$error = sprintf "TRX_LIGHT: error unknown sensor type=%x device_type=%s devn=%s first=%d command=%s", $type, $device_type, $device_name, $firstdevice, $command;
Log 1, $error;
@ -498,7 +499,7 @@ sub TRX_LIGHT_parse_X10 {
if (($firstdevice == 1) && $val) {
$def->{STATE} = $val;
readingsUpdate($def, "state", $val);
readingsBulkUpdate($def, "state", $val);
}
readingsEndUpdate($def, 1);

View File

@ -1,27 +1,29 @@
#################################################################################
# 46_TRX_SECURITY.pm
# $Id$
##############################################################################
#
# FHEM module for X10, KD101, Visonic
# 46_TRX_LIGHT.pm
# FHEM module for X10, KD101, Visonic
# Copyright by Willi Herzig
# e-mail:
#
# Copyright (C) 2012 Willi Herzig
# This file is part of fhem.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# Fhem is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# Fhem is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# The GNU General Public License may also be found at http://www.gnu.org/licenses/gpl-2.0.html .
# You should have received a copy of the GNU General Public License
# along with fhem. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
#
##################################
#
# values for "set global verbose"
# 4: log unknown protocols
@ -284,12 +286,12 @@ sub TRX_SECURITY_parse_X10Sec {
if ($firstdevice == 1) {
$val .= $current;
}
readingsUpdate($def, $sensor, $current);
readingsBulkUpdate($def, $sensor, $current);
# KD101 does not show normal, so statechange does not make sense
if (($def->{STATE} ne $val) && ($device_type ne "KD101")) {
$sensor = "statechange";
readingsUpdate($def, $sensor, $current);
readingsBulkUpdate($def, $sensor, $current);
}
} else {
# kr18 remote control or VISONIC_REMOTE
@ -297,12 +299,12 @@ sub TRX_SECURITY_parse_X10Sec {
#$sensor = $def->{TRX_SECURITY_devicelog};
$val = $current;
readingsUpdate($def, $sensor, $current);
readingsBulkUpdate($def, $sensor, $current);
my @cmd_split = split(/-/, $command);
$sensor = $cmd_split[0];
$current = $cmd_split[1];
readingsUpdate($def, $sensor, $current);
readingsBulkUpdate($def, $sensor, $current);
}
if ($battery ne "") {
@ -310,7 +312,7 @@ sub TRX_SECURITY_parse_X10Sec {
$current = "Error";
$current = "ok" if ($battery eq "batt_ok");
$current = "low" if ($battery eq "batt_low");
readingsUpdate($def, $sensor, $current);
readingsBulkUpdate($def, $sensor, $current);
}
if ($delay ne '') {
@ -318,12 +320,12 @@ sub TRX_SECURITY_parse_X10Sec {
$current = "Error";
$current = "min" if ($delay eq "min_delay");
$current = "max" if ($delay eq "max_delay");
readingsUpdate($def, $sensor, $current);
readingsBulkUpdate($def, $sensor, $current);
}
if (($firstdevice == 1) && $val) {
$def->{STATE} = $val;
readingsUpdate($def, "state", $val);
readingsBulkUpdate($def, "state", $val);
}
readingsEndUpdate($def, 1);

View File

@ -1,4 +1,6 @@
#################################################################################
# $Id$
##############################################################################
#
# 46_TRX_WEATHER.pm
# FHEM module to decode weather sensor messages for RFXtrx
#
@ -803,21 +805,21 @@ TRX_WEATHER_Parse($$)
$val .= "T: ".$i->{current}." ";
$sensor = "temperature";
readingsUpdate($def, $sensor, $i->{current});
readingsBulkUpdate($def, $sensor, $i->{current});
}
elsif ($i->{type} eq "chilltemp") {
#printf "Temperatur %2.1f %s ; ",$i->{current},$i->{units};
$val .= "CT: ".$i->{current}." ";
$sensor = "windchill";
readingsUpdate($def, $sensor, $i->{current});
readingsBulkUpdate($def, $sensor, $i->{current});
}
elsif ($i->{type} eq "humidity") {
#printf "Luftfeuchtigkeit %d%s, %s ;",$i->{current},$i->{units},$i->{string};
$val .= "H: ".$i->{current}." ";
$sensor = "humidity";
readingsUpdate($def, $sensor, $i->{current});
readingsBulkUpdate($def, $sensor, $i->{current});
}
elsif ($i->{type} eq "battery") {
#printf "Batterie %d%s; ",$i->{current},$i->{units};
@ -826,7 +828,7 @@ TRX_WEATHER_Parse($$)
$val .= "BAT: ".$words[0]." "; #use only first word
$sensor = "battery";
readingsUpdate($def, $sensor, $i->{current});
readingsBulkUpdate($def, $sensor, $i->{current});
}
elsif ($i->{type} eq "pressure") {
#printf "Luftdruck %d %s, Vorhersage=%s ; ",$i->{current},$i->{units},$i->{forecast};
@ -834,65 +836,65 @@ TRX_WEATHER_Parse($$)
$val .= "P: ".$i->{current}." ";
$sensor = "pressure";
readingsUpdate($def, $sensor, $i->{current});
readingsBulkUpdate($def, $sensor, $i->{current});
$sensor = "forecast";
readingsUpdate($def, $sensor, $i->{forecast});
readingsBulkUpdate($def, $sensor, $i->{forecast});
}
elsif ($i->{type} eq "speed") {
$val .= "W: ".$i->{current}." ";
$val .= "WA: ".$i->{average}." ";
$sensor = "wind_speed";
readingsUpdate($def, $sensor, $i->{current});
readingsBulkUpdate($def, $sensor, $i->{current});
$sensor = "wind_avspeed";
readingsUpdate($def, $sensor, $i->{average});
readingsBulkUpdate($def, $sensor, $i->{average});
}
elsif ($i->{type} eq "direction") {
$val .= "WD: ".$i->{current}." ";
$val .= "WDN: ".$i->{string}." ";
$sensor = "wind_dir";
readingsUpdate($def, $sensor, $i->{current} . " " . $i->{string});
readingsBulkUpdate($def, $sensor, $i->{current} . " " . $i->{string});
}
elsif ($i->{type} eq "rain") {
$val .= "RR: ".$i->{current}." ";
$sensor = "rain_rate";
readingsUpdate($def, $sensor, $i->{current});
readingsBulkUpdate($def, $sensor, $i->{current});
}
elsif ($i->{type} eq "train") {
$val .= "TR: ".$i->{current}." ";
$sensor = "rain_total";
readingsUpdate($def, $sensor, $i->{current});
readingsBulkUpdate($def, $sensor, $i->{current});
}
elsif ($i->{type} eq "flip") {
$val .= "F: ".$i->{current}." ";
$sensor = "rain_flip";
readingsUpdate($def, $sensor, $i->{current});
readingsBulkUpdate($def, $sensor, $i->{current});
}
elsif ($i->{type} eq "uv") {
$val .= "UV: ".$i->{current}." ";
$val .= "UVR: ".$i->{risk}." ";
$sensor = "uv_val";
readingsUpdate($def, $sensor, $i->{current});
readingsBulkUpdate($def, $sensor, $i->{current});
$sensor = "uv_risk";
readingsUpdate($def, $sensor, $i->{risk});
readingsBulkUpdate($def, $sensor, $i->{risk});
}
elsif ($i->{type} eq "weight") {
$val .= "W: ".$i->{current}." ";
$sensor = "weight";
readingsUpdate($def, $sensor, $i->{current});
readingsBulkUpdate($def, $sensor, $i->{current});
}
elsif ($i->{type} eq "hexline") {
$sensor = "hexline";
readingsUpdate($def, $sensor, $i->{current});
readingsBulkUpdate($def, $sensor, $i->{current});
}
else {
print "\nTRX_WEATHER: Unknown: ";
@ -906,7 +908,7 @@ TRX_WEATHER_Parse($$)
$val =~ s/^\s+|\s+$//g;
$def->{STATE} = $val;
readingsUpdate($def, "state", $val);
readingsBulkUpdate($def, "state", $val);
}
readingsEndUpdate($def, 1);

View File

@ -1,5 +1,5 @@
################################################################
# $Id$
################################################################
#
# (c) 2012 Copyright: Martin Fischer (m_fischer at gmx dot de)
# All rights reserved
@ -260,7 +260,7 @@ IPCAM_getSnapshot($) {
print FH $snapshot;
close(FH);
Log 5, "IPCAM $name snapshot $storage/$imageFile written.";
readingsUpdate($hash,"last",$lastSnapshot);
readingsBulkUpdate($hash,"last",$lastSnapshot);
$hash->{STATE} = "last: $dateTime";
$hash->{READINGS}{"snapshot$seqF"}{TIME} = $dateTime;
$hash->{READINGS}{"snapshot$seqF"}{VAL} = $imageFile;
@ -269,7 +269,7 @@ IPCAM_getSnapshot($) {
Log GetLogLevel($name,4), "IPCAM $name image: $imageFile";
if($seq == $seqImages) {
readingsUpdate($hash,"snapshots",$seq);
readingsBulkUpdate($hash,"snapshots",$seq);
$seq = 0;
}
readingsEndUpdate($hash, defined($hash->{LOCAL} ? 0 : 1));

View File

@ -1,3 +1,4 @@
# $Id$
################################################################
#
# Copyright notice
@ -33,7 +34,7 @@
# define ws300 WS300 9 (always 9)
# set WS300Device <interval(5-60 min.)> <height(0-2000 m)> <rainvalume(ml)>
################################################################
# $Id$
package main;
@ -287,15 +288,15 @@ WS300_Parse($$)
# state
$val = "T: $t H: $h Bat: $b LR: $l";
$def->{STATE} = $val;
readingsUpdate($def, 'state', $val);
readingsBulkUpdate($def, 'state', $val);
# temperature
readingsUpdate($def, $txt[0], $t);
readingsBulkUpdate($def, $txt[0], $t);
# humidity
readingsUpdate($def, $txt[1], $h);
readingsBulkUpdate($def, $txt[1], $h);
# battery
readingsUpdate($def, $txt[5], $b);
readingsBulkUpdate($def, $txt[5], $b);
# lost receives
readingsUpdate($def, $txt[6], $l);
readingsBulkUpdate($def, $txt[6], $l);
Log $ll, "WS300 $def->{NAME}: $val";
@ -307,26 +308,26 @@ WS300_Parse($$)
# state
$val = "T: $t H: $h W: $wind R: $rain IR: $ir Bat: $b LR: $l";
$def->{STATE} = $val;
readingsUpdate($def, 'state', $val);
readingsBulkUpdate($def, 'state', $val);
$def->{CHANGED}[0] = $val;
$def->{CHANGETIME}[0] = $tm;
# temperature
readingsUpdate($def, $txt[0], $t);
readingsBulkUpdate($def, $txt[0], $t);
# humidity
readingsUpdate($def, $txt[1], $h);
readingsBulkUpdate($def, $txt[1], $h);
# wind
readingsUpdate($def, $txt[2], $wind);
readingsBulkUpdate($def, $txt[2], $wind);
# rain counter
readingsUpdate($def, $txt[3], $rainc);
readingsBulkUpdate($def, $txt[3], $rainc);
# is raining
readingsUpdate($def, $txt[4], $ir);
readingsBulkUpdate($def, $txt[4], $ir);
# battery
readingsUpdate($def, $txt[5], $b);
readingsBulkUpdate($def, $txt[5], $b);
# lost receives
readingsUpdate($def, $txt[6], $l);
readingsBulkUpdate($def, $txt[6], $l);
# rain cumulative
readingsUpdate($def, $txt[8], $rain);
readingsBulkUpdate($def, $txt[8], $rain);
# statistics
if($actday == 99)
{
@ -346,9 +347,9 @@ WS300_Parse($$)
$rain_month = sprintf("%.1f",$rain_month);
$ref->{acthour}{TIME} = $tm;
$ref->{acthour}{VAL} = "$acthour";
readingsUpdate($def, $txt[9], $rain_hour);
readingsUpdate($def, $txt[10], $rain_day);
readingsUpdate($def, $txt[11], $rain_month);
readingsBulkUpdate($def, $txt[9], $rain_hour);
readingsBulkUpdate($def, $txt[10], $rain_day);
readingsBulkUpdate($def, $txt[11], $rain_month);
$rain_hour=0;
}
if($actday != $lt[3])
@ -376,9 +377,9 @@ WS300_Parse($$)
$oldrain = $rain;
$ref->{acthour}{TIME} = $tm;
$ref->{acthour}{VAL} = "$acthour";
readingsUpdate($def, $txt[9], $rain_hour);
readingsUpdate($def, $txt[10], $rain_day);
readingsUpdate($def, $txt[11], $rain_month);
readingsBulkUpdate($def, $txt[9], $rain_hour);
readingsBulkUpdate($def, $txt[10], $rain_day);
readingsBulkUpdate($def, $txt[11], $rain_month);
}
Log $ll,"WS300 $def->{NAME}: $val";
@ -410,15 +411,15 @@ WS300_Parse($$)
# state
$val = "T: $t H: $h P: $press Willi: $willi";
$def->{STATE} = $val;
readingsUpdate($def, 'state', $val);
readingsBulkUpdate($def, 'state', $val);
# temperature
readingsUpdate($def, $txt[0], $t);
readingsBulkUpdate($def, $txt[0], $t);
# humidity
readingsUpdate($def, $txt[1], $h);
readingsBulkUpdate($def, $txt[1], $h);
# pressure
readingsUpdate($def, $txt[7], $press);
readingsBulkUpdate($def, $txt[7], $press);
# willi
readingsUpdate($def, 'willi', $willi);
readingsBulkUpdate($def, 'willi', $willi);
Log $ll,"WS300 $def->{NAME}: $val";

View File

@ -1,12 +1,26 @@
#
#
#
# 57_Calendar.pm
# written by Dr. Boris Neubert 2012-06-01
# e-mail: omega at online dot de
#
##############################################
# $Id$
##############################################################################
#
# 57_Calendar.pm
# Copyright by Dr. Boris Neubert
# e-mail: omega at online dot de
#
# This file is part of fhem.
#
# Fhem is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Fhem is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with fhem. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# Todos:
# Support recurring events
@ -653,16 +667,16 @@ sub Calendar_CheckTimes($) {
readingsBeginUpdate($hash); # clears all events in CHANGED, thus must be called first
# we create one fhem event for one changed calendar event
map { addEvent($hash, "changed: " . $_->uid() . " " . $_->mode() ); } @changedevents;
readingsUpdate($hash, "lastCheck", $hash->{fhem}{lastCheck});
readingsUpdate($hash, "modeUpcoming", join(";", @upcoming));
readingsUpdate($hash, "modeAlarm", join(";", @alarm));
readingsUpdate($hash, "modeAlarmed", join(";", @alarmed));
readingsUpdate($hash, "modeAlarmOrStart", join(";", @alarm,@start));
readingsUpdate($hash, "modeChanged", join(";", @changed));
readingsUpdate($hash, "modeStart", join(";", @start));
readingsUpdate($hash, "modeStarted", join(";", @started));
readingsUpdate($hash, "modeEnd", join(";", @end));
readingsUpdate($hash, "modeEnded", join(";", @ended));
readingsBulkUpdate($hash, "lastCheck", $hash->{fhem}{lastCheck});
readingsBulkUpdate($hash, "modeUpcoming", join(";", @upcoming));
readingsBulkUpdate($hash, "modeAlarm", join(";", @alarm));
readingsBulkUpdate($hash, "modeAlarmed", join(";", @alarmed));
readingsBulkUpdate($hash, "modeAlarmOrStart", join(";", @alarm,@start));
readingsBulkUpdate($hash, "modeChanged", join(";", @changed));
readingsBulkUpdate($hash, "modeStart", join(";", @start));
readingsBulkUpdate($hash, "modeStarted", join(";", @started));
readingsBulkUpdate($hash, "modeEnd", join(";", @end));
readingsBulkUpdate($hash, "modeEnded", join(";", @ended));
readingsEndUpdate($hash, 1); # DoTrigger, because sub is called by a timer instead of dispatch
}
@ -729,13 +743,13 @@ sub Calendar_GetUpdate($) {
#$hash->{STATE}= $val;
readingsBeginUpdate($hash);
readingsUpdate($hash, "calname", $calname);
readingsUpdate($hash, "lastUpdate", $hash->{fhem}{lastUpdate});
readingsUpdate($hash, "all", join(";", @all));
readingsUpdate($hash, "stateNew", join(";", @new));
readingsUpdate($hash, "stateUpdated", join(";", @updated));
readingsUpdate($hash, "stateDeleted", join(";", @deleted));
readingsUpdate($hash, "stateChanged", join(";", @changed));
readingsBulkUpdate($hash, "calname", $calname);
readingsBulkUpdate($hash, "lastUpdate", $hash->{fhem}{lastUpdate});
readingsBulkUpdate($hash, "all", join(";", @all));
readingsBulkUpdate($hash, "stateNew", join(";", @new));
readingsBulkUpdate($hash, "stateUpdated", join(";", @updated));
readingsBulkUpdate($hash, "stateDeleted", join(";", @deleted));
readingsBulkUpdate($hash, "stateChanged", join(";", @changed));
readingsEndUpdate($hash, 1); # DoTrigger, because sub is called by a timer instead of dispatch
$t+= $hash->{fhem}{interval};

View File

@ -1,5 +1,5 @@
################################################################
# $Id$
################################################################
# vim: ts=2:et
#
# (c) 2012 Copyright: Martin Fischer (m_fischer at gmx dot de)
@ -227,7 +227,7 @@ HCS_Set($@) {
#$hash->{STATE} = "off";
$hash->{NEXTCHECK} = "offline";
readingsBeginUpdate($hash);
readingsUpdate($hash, "state", "off");
readingsBulkUpdate($hash, "state", "off");
readingsEndUpdate($hash, 1);
Log 1, "$type $name monitoring of valves interrupted";
}
@ -275,9 +275,9 @@ HCS_setState($$) {
$stateDevice = ReadingsVal($name,"device","");
readingsBeginUpdate($hash);
readingsUpdate($hash, "device", $cmd);
readingsUpdate($hash, "overdrive", $overdrive) if($sensor);
readingsUpdate($hash, "state", $state);
readingsBulkUpdate($hash, "device", $cmd);
readingsBulkUpdate($hash, "overdrive", $overdrive) if($sensor);
readingsBulkUpdate($hash, "state", $state);
readingsEndUpdate($hash, 1);
if($defs{$device}) {
@ -455,10 +455,10 @@ HCS_getValves($$) {
readingsBeginUpdate($hash);
for my $d (sort keys %valves) {
readingsUpdate($hash, $d."_state", $valves{$d}{state});
readingsUpdate($hash, $d."_demand", $valves{$d}{demand});
readingsBulkUpdate($hash, $d."_state", $valves{$d}{state});
readingsBulkUpdate($hash, $d."_demand", $valves{$d}{demand});
}
readingsUpdate($hash, "sensor", $tempValue) if(defined($tempValue) && $tempValue ne "");
readingsBulkUpdate($hash, "sensor", $tempValue) if(defined($tempValue) && $tempValue ne "");
readingsEndUpdate($hash, 1);
return ($list) ? $ret : $heatDemand;

View File

@ -1,8 +1,27 @@
# $Id$
##############################################################################
#
# 59_Twilight.pm
# written by Sebastian Stuecker based on Twilight.tcl http://www.homematic-wiki.info/mw/index.php/TCLScript:twilight
# 59_Twilight.pm
# Copyright by Sebastian Stuecker
# based on Twilight.tcl http://www.homematic-wiki.info/mw/index.php/TCLScript:twilight
# e-mail: omega at online dot de
#
##############################################
# This file is part of fhem.
#
# Fhem is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Fhem is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with fhem. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
package main;
use strict;
@ -183,7 +202,7 @@ Twilight_GetUpdate($)
}
Twilight_getWeatherHorizon($hash);
readingsUpdate($hash,"condition",$hash->{CONDITION});
readingsBulkUpdate($hash,"condition",$hash->{CONDITION});
if($hash->{WEATHER_HORIZON} > (89-$hash->{LATITUDE}+$declination) ){
$hash->{WEATHER_HORIZON} = 89-$hash->{LATITUDE}+$declination;
}
@ -203,10 +222,10 @@ Twilight_GetUpdate($)
($sunrise_set[$i]{RISE}, $sunrise_set[$i]{SET})=
Twilight_calc($latitude, $longitude, $sunrise_set[$i]{DEGREE},
$declination, $timezone, $midseconds, $timediff);
readingsUpdate($hash, $sunrise_set[$i]{SR_NAME},
readingsBulkUpdate($hash, $sunrise_set[$i]{SR_NAME},
$sunrise_set[$i]{RISE} eq "nan" ? "undefined" :
strftime("%H:%M:%S",localtime($sunrise_set[$i]{RISE})));
readingsUpdate($hash, $sunrise_set[$i]{SS_NAME},
readingsBulkUpdate($hash, $sunrise_set[$i]{SS_NAME},
$sunrise_set[$i]{SET} eq "nan" ? "undefined" :
strftime("%H:%M:%S",localtime($sunrise_set[$i]{SET})));
}
@ -218,10 +237,10 @@ Twilight_GetUpdate($)
for(my $i=0; $i < 12; $i++) {
my $nexttime=$sunrise_set[6-abs($i-6)-$k]{$half};
if($nexttime ne "nan" && $nexttime > $now) {
readingsUpdate($hash, "light", 6-abs($i-6));
readingsUpdate($hash, "nextEvent",
readingsBulkUpdate($hash, "light", 6-abs($i-6));
readingsBulkUpdate($hash, "nextEvent",
$sunrise_set[6-abs($i-6)-$k]{$sname});
readingsUpdate($hash, "nextEventTime",
readingsBulkUpdate($hash, "nextEventTime",
strftime("%H:%M:%S",localtime($nexttime)));
if($i==5 || $i==6) { # Weather
@ -247,12 +266,12 @@ Twilight_GetUpdate($)
if(!$alarmOffset) {
$alarmOffset = 900;
readingsUpdate($hash,"light", 0);
readingsBulkUpdate($hash,"light", 0);
$hash->{STATE}=0;
}
if(!$hash->{LOCAL}) {
InternalTimer($now+$alarmOffset, "Twilight_GetUpdate", $hash, 0);
readingsUpdate($hash,"nextUpdate",
readingsBulkUpdate($hash,"nextUpdate",
strftime("%H:%M:%S",localtime($now+$alarmOffset)));
}

View File

@ -1,13 +1,28 @@
#
#
# 59_Weather.pm
# maintainer: Dr. Boris Neubert 2009-06-01
# e-mail: omega at online dot de
# Port to Yahoo by Erwin Menschhorn 2012-08-30
# e-mail emenschhorn at gmail dot com
#
##############################################
# $Id$
##############################################################################
#
# 59_Weather.pm
# Copyright by Dr. Boris Neubert
# e-mail: omega at online dot de
#
# This file is part of fhem.
#
# Fhem is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Fhem is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with fhem. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
package main;
use strict;
@ -165,13 +180,13 @@ sub Weather_UpdateReading($$$$) {
my $reading= $prefix . $key;
readingsUpdate($hash,$reading,$value);
readingsBulkUpdate($hash,$reading,$value);
if($reading eq "temp_c") {
readingsUpdate($hash,"temperature",$value); # additional entry for compatibility
readingsBulkUpdate($hash,"temperature",$value); # additional entry for compatibility
}
if($reading eq "wind_condition") {
$value=~ s/.*?(\d+).*/$1/; # extract numeric
readingsUpdate($hash,"wind",wind_in_km_per_h($value,$unitsystem)); # additional entry for compatibility
readingsBulkUpdate($hash,"wind",wind_in_km_per_h($value,$unitsystem)); # additional entry for compatibility
}
return 1;
@ -230,19 +245,19 @@ sub Weather_RetrieveData($)
my $loc = "";
$loc = $1 if (defined($1));
$loc .= ", $2" if (defined($2));
readingsUpdate($hash, "city", $loc);
readingsBulkUpdate($hash, "city", $loc);
}
### current condition and forecast
if (($tag eq "yweather:condition" ) || ($tag eq "yweather:forecast" )) {
my $code = (($value =~/code="([0-9]*?)".*/) ? $1 : undef);
if (defined($code)) {
readingsUpdate($hash, $prefix . "code", $code);
readingsBulkUpdate($hash, $prefix . "code", $code);
my $text = $YahooCodes_i18n[$code];
if ($text) { readingsUpdate($hash, $prefix . "condition", $text); }
if ($text) { readingsBulkUpdate($hash, $prefix . "condition", $text); }
#### add icon logic here - generate from code
$text = $iconlist[$code];
readingsUpdate($hash, $prefix . "icon", $text) if ($text);
readingsBulkUpdate($hash, $prefix . "icon", $text) if ($text);
}
}
@ -250,30 +265,30 @@ sub Weather_RetrieveData($)
if ($tag eq "yweather:condition" ) {
my $temp = (($value =~/temp="(-?[0-9.]*?)".*/) ? $1 : undef);
if ($temp) {
readingsUpdate($hash, "temperature", $temp);
readingsUpdate($hash, "temp_c", $temp); # compatibility
readingsBulkUpdate($hash, "temperature", $temp);
readingsBulkUpdate($hash, "temp_c", $temp); # compatibility
$temp = int(( $temp * 9 / 5 ) + 32.5); # Celsius to Fahrenheit
readingsUpdate($hash, "temp_f", $temp); # compatibility
readingsBulkUpdate($hash, "temp_f", $temp); # compatibility
}
my $datum = (($value =~/date=".*? ([0-9].*)".*/) ? $1 : undef);
readingsUpdate($hash, "current_date_time", $datum) if (defined($1));
readingsBulkUpdate($hash, "current_date_time", $datum) if (defined($1));
my $day = (($value =~/date="(.*?), .*/) ? $1 : undef);
if ($day) {
readingsUpdate($hash, "day_of_week", $wdays_txt_i18n{$day});
readingsBulkUpdate($hash, "day_of_week", $wdays_txt_i18n{$day});
}
}
### forecast
if ($tag eq "yweather:forecast" ) {
my $low_c = (($value =~/low="(-?[0-9.]*?)".*/) ? $1 : undef);
if ($low_c) { readingsUpdate($hash, $prefix . "low_c", $low_c); }
if ($low_c) { readingsBulkUpdate($hash, $prefix . "low_c", $low_c); }
my $high_c = (($value =~/high="(-?[0-9.]*?)".*/) ? $1 : undef);
if ($high_c) { readingsUpdate($hash, $prefix . "high_c", $high_c); }
if ($high_c) { readingsBulkUpdate($hash, $prefix . "high_c", $high_c); }
my $day1 = (($value =~/day="(.*?)" .*/) ? $1 : undef); # forecast
if ($day1) {
readingsUpdate($hash, $prefix . "day_of_week", $wdays_txt_i18n{$day1});
readingsBulkUpdate($hash, $prefix . "day_of_week", $wdays_txt_i18n{$day1});
}
}
@ -281,28 +296,28 @@ sub Weather_RetrieveData($)
if ($tag eq "yweather:atmosphere" ) {
$value =~/humidity="([0-9.]*?)" .*visibility="([0-9.]*?|\s*?)" .*pressure="([0-9.]*?)" .*rising="([0-9.]*?)" .*/;
if ($1) { readingsUpdate($hash, "humidity", $1); }
if ($1) { readingsBulkUpdate($hash, "humidity", $1); }
my $vis = (($2 eq "") ? " " : int($2+0.5)); # clear visibility field
readingsUpdate($hash, "visibility", $vis);
if ($3) { readingsUpdate($hash, "pressure", int($3+0.5)); }
readingsBulkUpdate($hash, "visibility", $vis);
if ($3) { readingsBulkUpdate($hash, "pressure", int($3+0.5)); }
if ($4) {
readingsUpdate($hash, "pressure_trend", $4);
readingsUpdate($hash, "pressure_trend_txt", $pressure_trend_txt_i18n{$4});
readingsUpdate($hash, "pressure_trend_sym", $pressure_trend_sym{$4});
readingsBulkUpdate($hash, "pressure_trend", $4);
readingsBulkUpdate($hash, "pressure_trend_txt", $pressure_trend_txt_i18n{$4});
readingsBulkUpdate($hash, "pressure_trend_sym", $pressure_trend_sym{$4});
}
}
### wind
if ($tag eq "yweather:wind" ) {
$value =~/chill="(-?[0-9.]*?)" .*direction="([0-9.]*?)" .*speed="([0-9.]*?)" .*/;
readingsUpdate($hash, "wind_chill", $1) if (defined($1));
readingsUpdate($hash, "wind_direction", $2) if (defined($2));
readingsBulkUpdate($hash, "wind_chill", $1) if (defined($1));
readingsBulkUpdate($hash, "wind_direction", $2) if (defined($2));
my $windspeed= defined($3) ? int($3+0.5) : "";
readingsUpdate($hash, "wind_speed", $windspeed);
readingsUpdate($hash, "wind", $windspeed); # duplicate for compatibility
readingsBulkUpdate($hash, "wind_speed", $windspeed);
readingsBulkUpdate($hash, "wind", $windspeed); # duplicate for compatibility
if (defined($2) & defined($3)) {
my $wdir = degrees_to_direction($2,@directions_txt_i18n);
readingsUpdate($hash, "wind_condition", "Wind: $wdir $windspeed km/h"); # compatibility
readingsBulkUpdate($hash, "wind_condition", "Wind: $wdir $windspeed km/h"); # compatibility
}
}
}

View File

@ -1,11 +1,27 @@
# $Id$##############################################################################
#
# 67_ECMDDevice.pm
# Copyright by Dr. Boris Neubert
# e-mail: omega at online dot de
#
# 66_ECMDDevice.pm
# written by Dr. Boris Neubert 2011-01-15
# e-mail: omega at online dot de
# This file is part of fhem.
#
##############################################
# $Id$
# Fhem is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Fhem is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with fhem. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
package main;
use strict;
@ -79,10 +95,7 @@ ECMDDevice_Changed($$$)
{
my ($hash, $cmd, $value)= @_;
readingsBeginUpdate($hash);
readingsUpdate($hash, $cmd, $value);
readingsEndUpdate($hash, 1);
readingsSingleUpdate($hash, $cmd, $value, 1);
$hash->{STATE} = "$cmd $value";

View File

@ -29,7 +29,7 @@
#
# Contributed by Kai 'wusel' Siering <wusel+fhem@uu.org> in 2012
# Based in part on work for FHEM by other authors ...
# $Id: 70_TellStick.pm 1 2011-11-12 07:51:08Z real-wusel $
# $Id$
###########################
package main;

View File

@ -1,22 +1,39 @@
#
# Module: YAMAHA_AVR
#
# An FHEM Perl module for controlling Yamaha AV-Receivers
# via network connection. As the interface is standardized
# within all Yamaha AV-Receivers, this module should work
# with any receiver which has an ethernet or wlan connection.
#
# Currently supported are: power (on|off)
# input (hdmi1|hdmi2|...)
# volume (-50 ... 10)
# mute (on|off)
#
# Of course there are more possibilities than these 4 commands.
# But in my oppinion these are the most relevant usecases within FHEM.
#
# $Id$
##############################################################################
#
###################################
# 71_YAMAHA_AVR.pm
# An FHEM Perl module for controlling Yamaha AV-Receivers
# via network connection. As the interface is standardized
# within all Yamaha AV-Receivers, this module should work
# with any receiver which has an ethernet or wlan connection.
#
# Currently supported are: power (on|off)
# input (hdmi1|hdmi2|...)
# volume (-50 ... 10)
# mute (on|off)
#
# Of course there are more possibilities than these 4 commands.
# But in my oppinion these are the most relevant usecases within fhem.
#
# Copyright by Markus Bloch
# e-mail:
#
# This file is part of fhem.
#
# Fhem is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Fhem is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with fhem. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
package main;
@ -91,7 +108,7 @@ YAMAHA_AVR_GetStatus($;$)
if($return =~ /<Power>(.+)<\/Power>/)
{
$power = $1;
readingsUpdate($hash, "power", lc($power));
readingsBulkUpdate($hash, "power", lc($power));
if($power eq "Standby")
{
$power = "Off";
@ -102,13 +119,13 @@ YAMAHA_AVR_GetStatus($;$)
}
if($return =~ /<Volume><Lvl><Val>(.+)<\/Val><Exp>(.+)<\/Exp><Unit>.+<\/Unit><\/Lvl><Mute>(.+)<\/Mute><\/Volume>/)
{
readingsUpdate($hash, "volume_level", ($1 / 10 ** $2));
readingsUpdate($hash, "mute", lc($3));
readingsBulkUpdate($hash, "volume_level", ($1 / 10 ** $2));
readingsBulkUpdate($hash, "mute", lc($3));
}
if($return =~ /<Input_Sel>(.+)<\/Input_Sel>/)
{
readingsUpdate($hash, "input", InputParamToFhemInput(lc($1), 0));
readingsBulkUpdate($hash, "input", InputParamToFhemInput(lc($1), 0));
}
readingsEndUpdate($hash, 1);
@ -176,7 +193,7 @@ YAMAHA_AVR_Set($@)
if($result =~ /RC="0"/ and $result =~ /<Power><\/Power>/)
{
# As the receiver startup takes about 5 seconds, the status will be already set, if the return code of the command is 0.
readingsUpdate($hash, "power", "on");
readingsBulkUpdate($hash, "power", "on");
$hash->{STATE} = "on";
return undef;
}

View File

@ -1,14 +1,30 @@
##############################################
#
# Modul: FB_CALLMONITOR
#
# Connects to a FritzBox Fon via network.
#
# When a call is received or takes place it creates an event with further call informations.
#
# This module has no sets or gets as it is only used for event triggering.
#
# $Id$
##############################################################################
#
# 72_FB_CALLMONITOR.pm
# Connects to a FritzBox Fon via network.
# When a call is received or takes place it creates an event with further call informations.
# This module has no sets or gets as it is only used for event triggering.
#
# Copyright by Markus Bloch
# e-mail:
#
# This file is part of fhem.
#
# Fhem is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Fhem is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with fhem. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
package main;
@ -99,13 +115,13 @@ FB_CALLMONITOR_Read($)
@array = split(";", $data);
readingsBeginUpdate($hash);
readingsUpdate($hash, "event", lc($array[1]));
readingsUpdate($hash, "external_number", $array[3]) if(not $array[3] eq "0" and $array[1] eq "RING");
readingsUpdate($hash, "internal_number", $array[4]) if($array[1] eq "RING");
readingsUpdate($hash, "external_number" , $array[5]) if($array[1] eq "CALL");
readingsUpdate($hash, "internal_number", $array[4]) if($array[1] eq "CALL");
readingsUpdate($hash, "used_connection", $array[5]) if($array[1] eq "RING");
readingsUpdate($hash, "used_connection", $array[6]) if($array[1] eq "CALL");
readingsBulkUpdate($hash, "event", lc($array[1]));
readingsBulkUpdate($hash, "external_number", $array[3]) if(not $array[3] eq "0" and $array[1] eq "RING");
readingsBulkUpdate($hash, "internal_number", $array[4]) if($array[1] eq "RING");
readingsBulkUpdate($hash, "external_number" , $array[5]) if($array[1] eq "CALL");
readingsBulkUpdate($hash, "internal_number", $array[4]) if($array[1] eq "CALL");
readingsBulkUpdate($hash, "used_connection", $array[5]) if($array[1] eq "RING");
readingsBulkUpdate($hash, "used_connection", $array[6]) if($array[1] eq "CALL");
readingsEndUpdate($hash, 1);

View File

@ -431,7 +431,7 @@ CommandJsonList($$)
"room": "Server",
"statefile": "/var/cache/fhem/fhem.save",
"verbose": "4",
"version": "=VERS= from =DATE= ($Id: fhem.pl,v $)"
"version": "=VERS= from =DATE= ($Id$)"
},
"READINGS": []
}

View File

@ -1,5 +1,5 @@
##############################################
# $Id: 99_WOL.pm 1116 2012-01-21 15:01:34Z matthiasklass $
# $Id$
package main;
use strict;

View File

@ -1,5 +1,26 @@
##############################################
# $Id$
##############################################################################
#
# 98_structure.pm
# Copyright by
# e-mail:
#
# This file is part of fhem.
#
# Fhem is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Fhem is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with fhem. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
package main;
use strict;
@ -232,9 +253,7 @@ sub structure_Notify($$)
Log 3, "Update structure '" .$me . "' to " . $newState .
" because device '" .$dev->{NAME}. "' has changed";
$hash->{STATE} = $newState;
readingsBeginUpdate($hash);
readingsUpdate($hash, "state", $newState);
readingsEndUpdate($hash, 1);
readingsSingleUpdate($hash, "state", $newState, 1);
}
undef;
}

View File

@ -1,5 +1,5 @@
##############################################
# $Id: 98_telnet.pm 1098 2011-11-12 07:51:08Z rudolfkoenig $
# $Id$
# Note: this is not really a telnet server, but a TCP server with slight telnet
# features (disable echo on password)

View File

@ -1,5 +1,5 @@
##############################################
# $Id: FritzBoxUtils.pm 1148 2011-12-28 19:21:19Z rudolfkoenig $
# $Id$
package main;
use strict;

View File

@ -1,5 +1,5 @@
##############################################
# $Id: TcpServerUtils.pm 1098 2011-11-12 07:51:08Z rudolfkoenig $
# $Id$
package main;
use strict;

View File

@ -2913,11 +2913,11 @@ readingsEndUpdate($$) {
}
#
# Call readingsUpdate to update the reading.
# Call readingsBulkUpdate to update the reading.
# Example: readingsUpdate($hash,"temperature",$value);
#
sub
readingsUpdate($$$) {
readingsBulkUpdate($$$) {
my ($hash,$reading,$value)= @_;
my $name= $hash->{NAME};
@ -2955,6 +2955,19 @@ readingsUpdate($$$) {
return $rv;
}
#
# this is a shorthand call
#
sub
readingsSingleUpdate($$$$) {
my ($hash,$reading,$value,$dotrigger)= @_;
readingsBeginUpdate($hash);
my $rv= readingsBulkUpdate($hash,$reading,$value);
readingsEndUpdate($hash,$dotrigger);
return $rv;
}
###############################################################################
#
# date and time routines