Send temperature by email with blockly script

Moderator: leecollings

Post Reply
julien92
Posts: 16
Joined: Tuesday 08 January 2019 10:39
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9701
Location: France
Contact:

Send temperature by email with blockly script

Post by julien92 »

Hi all,

I’m a newbie this Domoticz and would like to send the external temperature by email every hour, via a blockly script.

In order to manage this, I’m wondering how :
- Get the value of the temperature and put it into a variable
- Send the content of this variable within an email

Could you please help me to achieve this? (I hope without needing to use LUA script, which I don’t know at all ;)

Thanks a lot in advance.

Julien
User avatar
Xenomes
Posts: 416
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: Send temperature by email with blockly script

Post by Xenomes »

Try this is email blocky Temperatuur = {{temperaturedevice[273]}}
HP T630 (256GB SSD/8GB Mem) - Ubuntu 24.04.2 LTS (64Bit) - Domoticz 2025.1 (Docker) Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
julien92
Posts: 16
Joined: Tuesday 08 January 2019 10:39
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9701
Location: France
Contact:

Re: Send temperature by email with blockly script

Post by julien92 »

Hi,

I've managed to get the temperature and put it into a variable :

Code: Select all

temp_ext=$(curl -s 'http://192.168.1.45:8082/json.htm?type=devices&rid=59' | awk -F "\"" '/Data/ {print $4}')
IDX 59 being my temperature sensor


When I type :

Code: Select all

echo $temp_ext
It displays the temperature.


BUT when putting it into a shell script, that does not work, and I can't figure out why :

Code: Select all

sudo nano /home/pi/scripts/get_sensors_values.sh

Code: Select all

#!/bin/bash
temp_ext=$(curl -s 'http://192.168.1.45:8082/json.htm?type=devices&rid=59' | awk -F "\"" '/Data/ {print $4}')

Code: Select all

sudo chmod +x /home/pi/scripts/get_sensors_values.sh
I then execute the script :

Code: Select all

./get_sensors_values.sh
And when typing :

Code: Select all

echo $temp_ext
It does not display the last temperature.

Does anybody have any idea how I could fix this?


Once I will have solved that, I still need to figure out how to put this variable within a blockly script, in order to send it by email.

Julien
julien92
Posts: 16
Joined: Tuesday 08 January 2019 10:39
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9701
Location: France
Contact:

Re: Send temperature by email with blockly script

Post by julien92 »

I'm still answering to myself :

The script needs to be launched with source command :

Code: Select all

source ./get_sensors_values.sh
or

Code: Select all

. ./get_sensors_values.sh
It's working fine like this.

Now I just need to know how to make this variable useable by domoticz, so that I can use this variable within an email sent by a blockly script.
I'm still looking for that...
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest