Integrating Fritz DECT Devices into Node Red

Installation

AVM is selling smart home devices in their product series Fritz!Dect. I bought an Fritz!Dect 210 outlet for my solar cell. The Dect 210 is a switchable outlet, but the more interesting features for me are its capabilities for measuring electrical power, energy and ambient temperature. The Dect 210 is not only measuring outlet power but also inlet power. AVM does also offer the Fritz!Dect 200. The only difference I found is that the 210 is kind of water proof and therefore suitable for usage outdoors.

dnknth provided a node for node red with which you can control your smart home DECT devices. To install the node you need to add it to your palette either by command line

npm install node-red-contrib-fritzapi

Or you use the user interface. Just enter "fritz" as a search term and select the install button of node-red-contrib-fritzapi
Installation of the Fritz API nodes

New Nodes

After Installation you will find five new nodes in your node overview:
The five newly installed nodes
For this tutorial I will focus on the outlet node as I only have experience with this one, but the others should work in a similar way.

Thermostat, outlet, bulb and blind require an input and give some output. As input you need to pass the AIN (actuator identification number) of the DECT device you'd like to controll. You get the AIN from the user interface of your Fritz Box. Select "Smart Home" from the navigation menue, then "Device management". You'll find a list of the connected DECT devices. Click on the pencil like symbol of the device you'd like to controll and copy the AIN from the page that opens. Please be aware that in my case there was a blank space contained in the AIN which I had to delete to make the configuration in node red work.

Configuration

Once you draged an outlet node onto your flow and double clicked on it, you'll see the configuration of the node
Configuration menue of node outlet
First you need to set up a connection. To do this, click on the pencil like button on the right. Please enter a connection name.
Configuration menue of fritz connection
As host address node red uses a default http://fritz.box. This might work in a simple network, but I have a mesh network. Therefore I got different error messages and warnings during development. It worked finaly when I used the IP address of my Fritz Box, e.g. http://169.254.1.1

Keep the checkbox for "Check SSL certificate?" checked and provide a valid username and password. Now click the update button on the upper right and return to the node configuration.

Optionally enter a name for the node and select one of the given actions.
Selection of available actions

The Flow

In my example I will configure a flow which polls cyclicly the power, energy and temperature of an outlet node. So I drag a inject node, an outlet node and a debug node onto my flow.

The first flow setup

In the injection node you need to enter the AIN of your DECT device in the topic field. If you want to request the data cyclicly you need to check the "inject once after" checkbox. As default there is a delay of 0.1 seconds. Adapt if necessary for you. Select the type of intervall in the drop down menue. If you want to define a time range for requesting the data, choose "interval between times". As example I configured my node to request the data every 10 minutes on every day (monday to sunday) between 6 am and 11 pm (23:00)

Configuration of the injection node

In the outlet node I picked the "Get power" action. The Debug output was 0.19. As I tested this at nigth, I knew that the returned value was the power loss of the DECT210 and my DC/AC converter. As a Reminder: I want to log the gained electrical solar power. This means before storing the value to my database I need to remove the offset of 0.19 Watt. Todo so I added a function node

enhanced flow with function node

msg.payload = parseFloat(msg.payload) - 0.19;
return msg;

Enhancing the Flow

If you want to receive more values from the DECT device you need to add an additional node for each value

Flow with power, energy and temperature

The debug output was 0 | 16809 | 18.5
The first value is the current electrical power in Watt. The second is the total of the received electrical energy in Watthours. This means if you want to trace this value cyclicly you need to add a function node which does the calculation for the last intervall.
The last value is the ambient temperature in degree celsius.

To do the calulation of the energy I added a function block in which I used a context variable to store the last received value in. If the variable does not exist, it is created locally. If its type is undefined, we set it to the last received value and create the variable in the context space. If it was already set, we subtract its value from the last received value to get the amount of gained energy in the last 10 minutes.

var deltaEnergy = context.get("dEnergy");
if(deltaEnergy === undefined)
{
 deltaEnergy = parseFloat(msg.payload);
 context.set("dEnergy", deltaEnergy);
} else {
 deltaEnergy = parseFloat(msg.payload) - deltaEnergy;
}
msg.payload = deltaEnergy;
return msg;

Last edit: 2022-10-11

Content:

Helpfull links: