Eastron SDM230 (working)

Moderator: leecollings

Post Reply
User avatar
ILoveIOT
Posts: 59
Joined: Sunday 25 March 2018 17:47
Target OS: Linux
Domoticz version: 2020.2
Location: NL
Contact:

Eastron SDM230 (working)

Post by ILoveIOT »

Just confirming the Eastron SDM230 is working as well with the "sdm120c" files.

Install & info https://www.domoticz.com/wiki/Eastron_SDM120C

For Domoticz;
Add dummy and virtual device Electric(Instant+counter)
Add dummy and virtual device Voltage (for voltage)
Add dummy and virtual device Voltage (for hertz/frequency so you see a nice line, instead off text, but the V should be a H)
Add dummy and virtual device Ampere (for amps)

Adjusted the script a bit to get more value's from it (p=power / t=total / v=voltage / f=frequency / c=amps) + 4x retry + don't send invalid value's to Domoticz. Tried to keep it simple as possible, so people can adjust it too their wishes.

Code: Select all

#!/bin/bash
#title           : Eastron SDM230 Module with PL2303 Serial Port
#description     : Read multiple value's from SDM230 and sends it to Domoticz.
#author		 	 : JM (updated by ILoveIoT)
#date            : 17-02-2019
#version         : 0.2
#usage		 	 : /root/scripts/stroomverbruik.sh
#notes           : With p=power / t=total / v=voltage / f=frequency / c=amps and retry (-z 4)
#bash_version    :
#==============================================================================
#=====================Change Server and IDX to youre config====================
#==============================================================================

SERVER="http://127.0.0.1:8080"   # Server location

DOMOTICZIDXPOWERANDTOTAL="178"   # Domoticz IDX for power and total
DOMOTICZIDXVOLTAGE="184"		 # Domoticz IDX for voltage
DOMOTICZIDXFREQUENCY="183" 		 # Domoticz IDX for frequency
DOMOTICZIDXAMPERE="182"			 # Domoticz IDX for ampere

#==============================================================================
#===============================Begin Script===================================
#==============================================================================

# Getting the info
VALUES=`/usr/local/bin/sdm120c /dev/ttyUSB0 -P N -z 4 -p -t -v -f -c -q` #p=power / t=total / v=voltage / f=frequency / c=amps / q=short output
POWER=`echo $VALUES | cut -d ' ' -f3`
TOTAL=`echo $VALUES | cut -d ' ' -f5`
VOLTAGE=`echo $VALUES | cut -d ' ' -f1`
FREQUENCY=`echo $VALUES | cut -d ' ' -f4`
AMPERE=`echo $VALUES | cut -d ' ' -f2`
echo ""
echo "Eastron SDM230 Module with PL2303 Serial Port on /dev/ttyUSB0"
echo ""
echo "Use : (/usr/local/bin/sdm120c /dev/ttyUSB0 -P N -z 3) to get all available parameters"
echo ""
echo "POWER     : $POWER"
echo "TOTAL     : $TOTAL"
echo "VOLTAGE   : $VOLTAGE"
echo "FREQUENCY : $FREQUENCY"
echo "AMPERE    : $AMPERE"
echo ""
curl -s {$SERVER"/json.htm?type=command&param=udevice&idx="$DOMOTICZIDXPOWERANDTOTAL"&nvalue=0&svalue="$POWER";"$TOTAL""}  #send current to Domoticz


# If value's are NUL/NOK/0 or emtpy, don't send them to Domoticz
if [ "$VOLTAGE" = "0" ] || [ "$VOLTAGE" = "NOK" ] || [ -z "$VOLTAGE" ] ; then
	echo "!! VOLTAGE = $VOLTAGE ..invalid value not sending it to Domoticz !!"
else
	curl -s {$SERVER"/json.htm?type=command&param=udevice&idx="$DOMOTICZIDXVOLTAGE"&nvalue=0&svalue="$VOLTAGE""}  #send voltage to Domoticz
fi

if [ "$FREQUENCY" = "0" ] || [ "$FREQUENCY" = "NOK" ] || [ -z "$FREQUENCY" ] ; then
	echo "!! FREQUENCY = $FREQUENCY ..invalid value not sending it to Domoticz !!"
else
	curl -s {$SERVER"/json.htm?type=command&param=udevice&idx="$DOMOTICZIDXFREQUENCY"&nvalue=0&svalue="$FREQUENCY""}  #send frequency to Domoticz
fi

if [ "$AMPERE" = "NOK" ] || [ -z "$AMPERE" ] ; then
	echo "!! AMPERE = $AMPERE ..invalid value not sending it to Domoticz !!"
else
	curl -s {$SERVER"/json.htm?type=command&param=udevice&idx="$DOMOTICZIDXAMPERE"&nvalue=0&svalue="$AMPERE""}  #send ampere to Domoticz
fi

echo ""
echo ""
exit
#EOF
Attachments
stroomverbruik.zip
(1.12 KiB) Downloaded 145 times
1x OPI PC 5.8.16 Debian 10, MiniDNLA,SMD230,EpEver,MPD,800GB,Wiegand,7 temps,DHT,32/64 I/O,2022.1
2x OPI PC 4.19.25 Debian 9, MPD,7 temps,16/32 I/O,BMP,4.10717
1x IntelNUC 5.10 Debian 10, 2TB,DalyBMS,2023.1
3x ESPEasy NodeMCU V3, 16/16 I/O
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest