Skip to content

Commit

Permalink
[P176] Handle ON and OFF values as 1 and 0
Browse files Browse the repository at this point in the history
  • Loading branch information
tonhuisman committed Oct 30, 2024
1 parent 8f475f1 commit 21ff328
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/source/Plugin/P176.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ The *Data* column shows the actual data as received.

The *Value* column shows a factored result based on the value, as mV is not always very useful, so that's converted to V, mA to A, Wh to kWh, etc.

For items that use ON and OFF (or On and Off for older firmwares) as Data, these will be available as 1 and 0 respectively, so they can be used as Values. If needed, a transformation like ``[VE.Direct#Alarm#O]`` can be used to present the value as ON/OFF for 1/0. Adding the ``C`` justification, like ``[VE.Direct#Alarm#O#C]``, will be presented as On/Off.

It shows that it has received 2 packets, but as a packet only contains a part of the available data, and a next packet another part, etc. there's no fixed relation to the amount of samples, and the number of packets received. Some devices may send all data in a single packet, other devices may need 3 or even 4 packets to send all available data.

Also, the number of checksum errors is shown, this counter is automatically reset after receiving 50 consecutive correct packets.
Expand Down
1 change: 1 addition & 0 deletions src/_P176_VE_Direct.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// #######################################################################################################

/** Changelog:
* 2024-10-30 tonhuisman: Accept ON/On and OFF/Off as 1 and 0 numeric values, to be able to use them as Values in the device configuration
* 2024-10-30 tonhuisman: Simplifying the code somewhat, making it more robust, partially by TD-er
* 2024-10-29 tonhuisman: Optimize receiving and processing data, resulting in much lower load (based on suggestions by TD-er)
* Removed the RX Timeout setting, as it doesn't help here, seems to slow things down.
Expand Down
6 changes: 6 additions & 0 deletions src/src/PluginStructs/P176_data_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ struct P176_data_struct : public PluginTaskData_base {

if (validIntFromString(_value, iValue)) {
_numValue = iValue * _factor;
} else
if (_value.equalsIgnoreCase(F("ON"))) { // Can be ON or On
_numValue = 1.0f;
} else
if (_value.equalsIgnoreCase(F("OFF"))) { // Can be OFF or Off
_numValue = 0.0f;
} else {
_isNumeric = false;
}
Expand Down

0 comments on commit 21ff328

Please sign in to comment.