Hi!
Here’s my quick and dirty method to control our essent e-thermostat.
Create the following bash script:
sudo nano ethermostat.sh
Paste following code into it (with putty press SHIFT+INSERT)
# E-thermostaat control & info script
USERNAME=USERNAME FROM E-THERMOSTAAT
PASSWORD=PASSWORD FROM E-THERMOSTAAT
SN=SERIAL NUMBER A.K.A UID
CELCIUS=$'\xe2\x84\x83'
TOKEN=`curl -s --request POST 'https://portal.icy.nl/login' --data 'username='${USERNAME}'&password='${PASSWORD}'' | awk -F":" '{print $12}' | awk -F'"' '{print $2}'` SET=`curl -s -H "Session-token:$TOKEN" --request GET 'https://portal.icy.nl/data' --data 'username='${USERNAME}'&password='${PASSWORD}'' |awk -F":" '{print $10}' | awk -F',' '{print $1}'`
case "$1" in
temp)
TEMP=`curl -s -H "Session-token:$TOKEN" --request GET 'https://portal.icy.nl/data' --data 'username='${USERNAME}'&password='${PASSWORD}'' |awk -F":" '{print $11}' | awk -F',' '{print $1}'`
echo huidig: $TEMP$CELCIUS ingesteld: $SET$CELCIUS
;;
comfort)
TEMPERATURE=20
for RETRY in 1 2 3 4 5 6
do
RESULT=`curl -s -H "Session-token:$TOKEN" --request POST 'https://portal.icy.nl/data' --data "uid=$SN&temperature1=$TEMPERATURE" | tr -d '{}"' | awk -F":" '{print $4}'`
[ $RESULT = OK ] && break
sleep 300
done
;;
bespaar)
TEMPERATURE=15
for RETRY in 1 2 3 4 5 6
do
RESULT=`curl -s -H "Session-token:$TOKEN" --request POST 'https://portal.icy.nl/data' --data "uid=$SN&temperature1=$TEMPERATURE" | tr -d '{}"' | awk -F":" '{print $4}'`
[ $RESULT = OK ] && break
sleep 300
done
;;
set)
TEMPERATURE=$2
for RETRY in 1 2 3 4 5 6
do
RESULT=`curl -s -H "Session-token:$TOKEN" --request POST 'https://portal.icy.nl/data' --data "uid=$SN&temperature1=$TEMPERATURE" | tr -d '{}"' | awk -F":" '{print $4}'`
[ $RESULT = OK ] && break
sleep 300
done
;;
check)
echo "$SET"
;;
up)
NEWSET=`echo $SET + 1 |bc`
for RETRY in 1 2 3 4 5 6
do
RESULT=`curl -s -H "Session-token:$TOKEN" --request POST 'https://portal.icy.nl/data' --data "uid=$SN&temperature1=$NEWSET" | tr -d '{}"' | awk -F":" '{print $4}'`
[ $RESULT = OK ] && break
sleep 300
done
;;
down)
NEWSET=`echo $SET - 1 |bc`
for RETRY in 1 2 3 4 5 6
do
RESULT=`curl -s -H "Session-token:$TOKEN" --request POST 'https://portal.icy.nl/data' --data "uid=$SN&temperature1=$NEWSET" | tr -d '{}"' | awk -F":" '{print $4}'`
[ $RESULT = OK ] && break
sleep 300
done
;;
*)
echo "Please use one of the following options:"
echo "check :Display current set point"
echo "info :Display current temperature and setpoint"
echo "set :Set the setpoint to the given value"
echo "comfort :Set the setpoint to 20"
echo "bespaar :Set the setpoint to 15"
echo "up/down :Adjust the setpoint with + 1"
exit 1
;;
esac
CTRL + X to save
sudo chmod +x ethermostat.sh
Script works as following:
./ethermostat.sh {COMMAND} e.x ./ethermostat.sh up will set the temp +1.
We only need “set” and “check”. So lets go!
Add following device to your config:
{
"class": "DummyHeatingThermostat",
"id": "cvtemp",
"name": "Temperatuur",
"comfyTemp": 23,
"ecoTemp": 16,
"guiShowModeControl": false
},
These devices are for getting the current temp, setpoint temp and one device to handle “manual” changes made by hand.
Show temperature and setpoint on your GUI:
{
"id": "tempthuis",
"name": "Kamer",
"class": "ShellSensor",
"attributeName": "temperatuur",
"attributeType": "string",
"attributeUnit": "",
"command": "sudo bash /home/pi/ethermostat.sh temp",
"interval": 3600
},
You should keep the next one hidden from your pages since this is only for updating the dummy heater if your wife changes temp with her hands.
{
"id": "setpoint",
"name": "Live setpoint",
"class": "ShellSensor",
"attributeName": "live setpoint",
"attributeType": "string",
"attributeUnit": "",
"command": "sudo bash /home/pi/ethermostat.sh check",
"interval": 3600
},
It has pretty high interval’s but you can adjust it.
add these devices to your pages
{
"deviceId": "cvtemp"
},
{
"deviceId": "tempthuis"
},
Save your config.
Create the following variable to store the value you set by hand, or your wife(grr)
$setpointValue
Make the following rules:
This rule will set your temperature according to COMFY, ECO or setpoint temperature(+ and -) from the dummyheater. (change the path to your script)
IF $cvtemp.temperatureSetpoint changes THEN execute "/home/pi/ethermostat.sh set $cvtemp.temperatureSetpoint"
This basicly executes ./ethermostat.sh set 17
And following rule to adjust temperature to manual set
IF $setpoint.live setpoint changes THEN set $setpointValue to $setpoint.live setpoint and after 1 second set temp of Temperatuur to $setpointValue
That’s it. I hope it wasnt too hard to follow, this was my first tutorial.
There are probably better ways to do this, but as i said, it’s quick and dirty.
The script was made by someone else, cant find who, but credits to him for the script!