Tasmota integration with EmonCMS Input REST API

Raised this idea on Tasmota project.

1 Like

It appears the chances of that happening are not too good, unfortunately. Viz:

Https is unlikely to be supported on Esp8266 due to the limited capacities of the processor
http can already be performed with Websend command.
Have you tried it?

Another user commented:
Since MQTT support seems to exist for EmonCMS, this would be the better method for connecting.

1 Like

TBH I agree. I send my data to NR to process and set the timestamp in the right format before sending on to EmonCMS both via MQTT. I could do this by using Tasmota rules probably rather than NR.

It also means I can pick up the data as ā€˜sensorā€™ data in HA direct from Tasmota.

For those interested, iā€™ve archived the objective.
Running on a Hiking DDS238-2 WIFI with the firmware updated to Tasmota 9.4.0.2 or higher :

Documentation:

Basic settings:

{ā€œNAMEā€:ā€œHiking DDS238-2 WIFIā€,ā€œGPIOā€:[0,2272,0,2304,0,0,0,0,0,0,320,0,32,0],ā€œFLAGā€:0,ā€œBASEā€:54}

Backlog TuyaMCU 33,20; TuyaMCU 32,18; TuyaMCU 31,19;  TuyaMCU 37,101;
Backlog SetOption72 1; VoltRes 1; WattRes 1;

Rule1 
  ON System#Init DO backlog tuyasend1 1,1; RuleTimer1 5 ENDON 
  ON Rules#Timer=1 DO backlog TuyaSend8; RuleTimer1 5 ENDON

Rule2 
ON energy#power DO Var3 %value% ENDON
ON energy#voltage DO Var1 %value% ENDON
ON energy#total DO Var4 %value% ENDON
ON energy#apparentpower DO Var5 %value% ENDON
ON energy#reactivepower DO Var6 %value% ENDON
ON energy#Factor DO Var7 %value% ENDON
ON energy#Today DO Var8 %value% ENDON
ON energy#Yesterday DO Var9 %value% ENDON
ON energy#current DO Var2 %value% ENDON
ON Wifi#Connected DO backlog buzzer 2,1,1; RuleTimer2 5 ENDON 
ON Wifi#Disconnected DO backlog buzzer 1,3,1; RuleTimer2 0 ENDON 
ON Rules#Timer=2 DO backlog event SENDEMON; RuleTimer2 5 ENDON
ON event#SENDEMON DO WEBSEND [emon.server.com:80] /input/post.json?node=PowemeterLago&json={P:%Var3%,I:%Var2%,V:%Var1%,S:%Var5%,Q:%Var6%,Pf:%Var7%,Total:%Var4%,Today:%Var8%,Yesterday:%Var9%}&devicekey=YOURKEY ENDON

Backlog Rule1 1; Rule2 1;

restart 1

Advanced settings:

This resets the Today, Yesterday and Total kWh counter to the hardware value (cant reset the total hardware value);
Backlog EnergyReset1 0; EnergyReset2 0; EnergyReset3 0

Disables send state and sensor message interval (s):
TelePeriod 0

Security options:

WebPassword new_password
WifiConfig 4

Update rule 1 to disable the power off of the main relay, so that itā€™s not possible to shutdown the building power by accident:

Rule1 
  ON System#Init DO backlog PowerOnState 4; tuyasend1 1,1; RuleTimer1 5; ENDON 
  ON Rules#Timer=1 DO backlog TuyaSend8; RuleTimer1 5 ENDON

Add a Buzzer to GPIO15

{ā€œNAMEā€:ā€œHiking DDS238-2 WIFIā€,ā€œGPIOā€:[0,2272,0,2304,0,0,0,0,0,0,320,480,32,0],ā€œFLAGā€:0,ā€œBASEā€:54}

Triger buzzer when current is higher that 20A:

Rule3
  ON energy#current>20 DO buzzer -1,1,30 ENDON
  ON energy#current<20 DO buzzer 2,1,1 ENDON

Backlog Rule3 1; Rule3 5;
2 Likes

Thanks for sharing! I was trying to do something very similar, so this was a very good starting point for me. However, I realized that Rules and Scripting Language do not run in parallel, but I rely on scripting because of the Smart Metering Interface (Smart Meter Interface - Tasmota). But finally I managed it with a script too and shared it here: Read smart meters (SML interface) with ESP and Tasmota and send data to emoncms