- do_not_notify
- readingFnAttributes
- pin[AD]?[0-9]+<rising|falling> [<pullup>] [min] <min length> [[analog] out <out pin> [threshold] <min, max>]
Define a GPIO pin of the Arduino or ESP board as input. This attribute expects for digital inputs either
rising
or falling
, followed by an optional pullup
and the optional keyword min
and an optional number as minimal length of pulses and gaps between pulses.
The counter device will track rising and falling edges of each impulse and measure the length of a pulse in milliseconds.
The minimal length specified here is the minimal duration of a pulse and a pause before a pulse. If one is too small,
the pulse is not counted but added to a separate reject counter.
Example:
attr MyCounter pinD4 falling pullup 25
For analog inputs with connected reflective light barries, you have to add analog out
and the GPIO pin number of the pin where the light source (LED or laser) is connected, the keyword threshold
followed by the lower and upper threshold separated by a komma.
Example:
attr MyCounter pinA0 rising pullup min 3 analog out 27 threshold 120,220
- interval <normal> <max> [<min> <min count> [<analog interval> <analog samples>]]
Defines the parameters that affect the way counting and reporting works.
This Attribute expects at least two and a maximum of six numbers as value.
The first is the normal interval, the second the maximal interval, the third is a minimal interval and the fourth is a minimal pulse count.
The last two numbers are only needed for counting with reflective light barriers. They specify the delay between the measurements
and the number of samples for each measurement.
In the usual operation mode (when the normal interval is smaller than the maximum interval),
the Arduino board just counts and remembers the time between the first impulse and the last impulse for each pin.
After the normal interval is elapsed the Arduino board reports the count and time for those pins where impulses were encountered.
This means that even though the normal interval might be 10 seconds, the reported time difference can be
something different because it observed impulses as starting and ending point.
The Power (e.g. for energy meters) is then calculated based of the counted impulses and the time between the first and the last impulse.
For the next interval, the starting time will be the time of the last impulse in the previous reporting period
and the time difference will be taken up to the last impulse before the reporting interval has elapsed.
The second, third and fourth numbers (maximum, minimal interval and minimal count) exist for the special case
when the pulse frequency is very low and the reporting time is comparatively short.
For example if the normal interval (first number) is 60 seconds and the device counts only one impulse in 90 seconds,
the the calculated power reading will jump up and down and will give ugly numbers.
By adjusting the other numbers of this attribute this can be avoided.
In case in the normal interval the observed impulses are encountered in a time difference that is smaller than the third number (minimal interval)
or if the number of impulses counted is smaller than the fourth number (minimal count) then the reporting is delayed until the maximum interval has elapsed
or the above conditions have changed after another normal interval.
This way the counter will report a higher number of pulses counted and a larger time difference back to fhem.
Example:
attr myCounter interval 60 600 5 2
If this is seems too complicated and you prefer a simple and constant reporting interval, then you can set the normal interval and the mximum interval to the same number.
This changes the operation mode of the counter to just count during this normal and maximum interval and report the count.
In this case the reported time difference is always the reporting interval and not the measured time between the real impulses.
For analog sampling the last two numbers define the delay in milliseconds between analog measurements and the number of samples that will be taken as one mesurement.
- board
specify the type of the board used for ArduCounter like NANO, UNO, ESP32, ESP8266 or T-Display
Example:
attr myCounter board NANO
- pulsesPerUnit <number>
specify the number of pulses that the meter is giving out per unit that sould be displayed (e.g. per kWh energy consumed).
For many S0 counters this is 1000, for old ferraris counters this is 75 (rounds per kWh).
This attribute used to be called pulsesPerKWh and this name still works but the new name should be used preferably since the old one could be removed in future versions.
Example:
attr myCounter pulsesPerUnit 75
- readingPulsesPerUnit[AD]?[0-9]+ <number>
is the same as pulsesPerUnit but specified per GPIO pin individually in case you have multiple counters with different settings at the same time
This attribute used to be called readingPulsesPerKWh[AD]?[0-9]+ and this name still works but the new name should be used preferably
since the old one could be removed in future versions.
Example:
attr myCounter readingPulsesPerUnitA7 75
attr myCounter readingPulsesPerUnitD4 1000
- readingFlowUnitTime[AD]?[0-9]+ <time>
specified the time period in seconds which is used as the basis for calculating the current flow or power for the given pin.
If the counter e.g. counts liters and you want to see the flow in liters per minute, then you have to set this attribute to 60.
If you count kWh and you want to see the current power in kW, then specify 3600 (one hour).
Since this attribute is just used for multiplying the consumption per second, you can also use it to get watts
instead of kW by using 3600000 instead of 3600.
- flowUnitTime <time>
like readingFlowUnitTimeXX but applies to all pins that have no explicit readingFlowUnitTimeXX attribute.
- readingNameCount[AD]?[0-9]+ <new name>
Change the name of the counter reading pinX to something more meaningful.
Example:
attr myCounter readingNameCountD4 CounterHaus_internal
- readingNameLongCount[AD]?[0-9]+ <new name>
Change the name of the long counter reading longX to something more meaningful.
Example:
attr myCounter readingNameLongCountD4 CounterHaus_long
- readingNameInterpolatedCount[AD]?[0-9]+ <new name>
Change the name of the interpolated long counter reading InterpolatedlongX to something more meaningful.
Example:
attr myCounter readingNameInterpolatedCountD4 CounterHaus_interpolated
- readingNameCalcCount[AD]?[0-9]+ <new name>
Change the name of the real unit counter reading CalcCounterX to something more meaningful.
Example:
attr myCounter readingNameCalcCountD4 CounterHaus_kWh
- readingNamePower[AD]?[0-9]+ <new name>
Change the name of the power reading powerX to something more meaningful.
Example:
attr myCounter readingNamePowerD4 PowerHaus_kW
- readingStartTime[AD]?[0-9]+ [0|1]
Allow the reading time stamp to be set to the beginning of measuring intervals.
This is a hack where the timestamp of readings is artificially set to a past time and may have side effects
so avoid it unless you fully understand how Fhem works with readings and their time.
- verboseReadings[AD]?[0-9]+ [0|1]
create the additional readings lastMsg and pinHistory for each pin
if verboseReafings is set to 1 for the specified pin.
If set to -1 then the internal counter, the long counter and interpolated long counter readings will be hidden.
Example:
attr myCounter verboseReadingsD4 1
- enableHistory [0|1]
tells the counting device to record the individual time of each change at each GPIO pin and send it to Fhem.
This information is cached on the Fhem side and can be viewed with the command get history
The optput of get history
will look like this:
Seq 12627 2020-03-22 20:39:54 Pin D5 0.080 seconds at 0 -> pulse counted
Seq 12628 2020-03-22 20:39:55 Pin D5 1.697 seconds at 1 -> gap
Seq 12629 2020-03-22 20:39:56 Pin D5 0.080 seconds at 0 -> pulse counted
Seq 12630 2020-03-22 20:39:56 Pin D5 1.694 seconds at 1 -> gap
Seq 12631 2020-03-22 20:39:58 Pin D5 0.081 seconds at 0 -> pulse counted
Seq 12632 2020-03-22 20:39:58 Pin D5 1.693 seconds at 1 -> gap
Seq 12633 2020-03-22 20:40:00 Pin D5 0.081 seconds at 0 -> pulse counted
Seq 12634 2020-03-22 20:40:00 Pin D5 1.696 seconds at 1 -> gap
Seq 12635 2020-03-22 20:40:02 Pin D5 0.081 seconds at 0 -> pulse counted
Seq 12636 2020-03-22 20:40:02 Pin D5 1.699 seconds at 1 -> gap
Seq 12637 2020-03-22 20:40:03 Pin D5 0.079 seconds at 0 -> pulse counted
Seq 12638 2020-03-22 20:40:03 Pin D5 1.700 seconds at 1 -> gap
Seq 12639 2020-03-22 20:40:05 Pin D5 0.080 seconds at 0 -> pulse counted
Seq 12642 2020-03-22 20:40:05 Pin D5 1.699 seconds at 1 -> gap
Seq 12643 2020-03-22 20:40:07 Pin D5 0.080 seconds at 0 -> pulse counted
Seq 12644 2020-03-22 20:40:07 Pin D5 1.698 seconds at 1 -> gap
- enableSerialEcho [0|1]
tells the counting device to show diagnostic data over the serial line when connected via TCP
- enablePinDebug [0|1]
tells the counting device to show every level change of the defined input pins over the serial line or via TCP
- enableAnalogDebug [0|1]
tells the counting device to show every analog measurement of the defined analog input pins over the serial line or via TCP
- enableDevTime [0|1]
tells the counting device to show its internal millis timer so a drift between the devices time and fhem time can be calculated and logged
- maxHist <max entries>
specifies how many pin history lines hould be buffered for "get history".
This attribute defaults to 1000.
- analogThresholds
this Attribute is outdated. Please specify the analog thresholds for reflective light barrier input with the attribute "pin..."
- flashCommand <new shell command>
overrides the default command to flash the firmware via Wifi (OTA) or serial line. It is recommended to not define this attribute.
Example:
attr myCounter flashCommand avrdude -p atmega328P -c arduino -b 57600 -P [PORT] -D -U flash:w:[HEXFILE] 2>[LOGFILE]
[PORT]
is automatically replaced with the serial port for this device as it is specified in the define
command.
[HEXFILE]
or [BINFILE]
are synonyms and are both automatically replaced with the firmware file appropriate for the device.
For ESP32 boards [HEXFILE]
would be replaced by ArduCounter-8266.bin for example.
[LOGFILE]
is automatically replaced ArduCounterFlash.log in the fhem log subdirectory.
[NETPORT]
is automatically replaced by the tcp port number used for OTA flashing.
For ESP32 this usually is 3232 and for 8266 Bords it is 8266.
- keepAliveDelay <delay>
defines an interval in which the module sends keepalive messages to a counter device that is conected via tcp.
This attribute is ignored if the device is connected via serial port.
If the device doesn't reply within a defined timeout then the module closes and tries to reopen the connection.
The module tells the device when to expect the next keepalive message and the device will also close the tcp connection if it doesn't see a keepalive message within the delay multiplied by 3
The delay defaults to 10 seconds.
Example:
attr myCounter keepAliveDelay 30
- keepAliveTimeout <seconds>
defines the timeout when wainting for a keealive reply (see keepAliveDelay)
The timeout defaults to 2 seconds.
Example:
attr myCounter keepAliveTimeout 3
- keepAliveRetries <max number of retries>
defines how often sending a keepalive is retried before the connection is closed and reopened.
It defaults to 2.
Example:
attr myCounter keepAliveRetries 3
- nextOpenDelay <delay>
defines the time in seconds that the module waits before retrying to open a disconnected tcp connection.
This defaults to 60 seconds.
Example:
attr myCounter nextOpenDelay 20
- openTimeout <timeout>
defines the timeout in seconds after which tcp open gives up trying to establish a connection to the counter device.
This timeout defaults to 3 seconds.
Example:
attr myCounter openTimeout 5
- silentReconnect [0|1]
if set to 1, then it will set the loglevel for "disconnected" and "reappeared" messages to 4 instead of 3
Example:
attr myCounter silentReconnect 1
- deviceDisplay <pin> <unit> <flowUnit>
controls the unit strings that a local display on the counting device will show.
Example:
attr myCounter deviceDisplay 36,l,l/m
attr myCounter deviceDisplay 36,kWh,kW
- disable [0|1]
if set to 1 then the module is disabled and closes the connection to a counter device.
- factor
Define a multiplicator for calculating the power from the impulse count and the time between the first and the last impulse.
This attribute is outdated and unintuitive so you should avoid it.
Instead you should specify the attribute pulsesPerUnit or readingPulsesPerUnit[0-9]+ (where [0-9]+ stands for the pin number).
- readingFactor[AD]?[0-9]+
Override the factor attribute for this individual pin.
Just like the attribute factor, this is a rather cumbersome way to specify the pulses per kWh.
Instead it is advised to use the attribute pulsesPerUnit or readingPulsesPerUnit[0-9]+ (where [0-9]+ stands for the pin number).
- runTime[AD]?[0-9]+
if this attribute is set for a pin, then a new reading will be created which accumulates the run time for this pin while consumption is greater than 0.
This allows e.g. to check if a water meter shows water consumption for a time longer than X without stop.
- runTimeIgnore[AD]?[0-9]+
this allows to ignore consumption for the run time attribute while a certain other device is switched on.
- devVerbose
this attribute is outdated and has been replaced with the attributes
enableHistory, enableSerialEcho, enablePinDebug, enableAnalogDebug, enableDevTime
- configDelay
specify the time to wait for the board to report its configuration before Fhem sends the commands to reconfigure the board
- helloSendDelay
specify the time to wait for the board to report its type before Fhem sends the commands to ask for it
- helloWaitTime
specify the time to wait for the board to report its type when Fhem has asked for it before a timeout occurs