Page 1 of 1

Cant execute bash script from dzvents

Posted: Thursday 18 October 2018 22:39
by Ant1q
First of all i'm begginer =) I have Xiaomi Humidifier 2(air washer) and want to read information from Humidifier Sensors(t, %hum and water level), as base i used viewtopic.php?t=17498
I have corrected humidifier.js to recieve separated readings and make bash-script that send it to user variables in domoticz

Code: Select all

#!/bin/bash
(cd /home/pi/domoticz/scripts/Xiaomi

# Main Bedroom Humidifier
# Get the data
data_w=$(node humidifier.js 192.168.0.19 status_water)
data_t=$(node humidifier.js 192.168.0.19 status_t)
data_h=$(node humidifier.js 192.168.0.19 status_h)
# Sort it
w=$(echo "$data_w" | grep -o -E '[0-9]+')
t=$(echo "$data_t" | grep -o -E '[0-9]+')
h=$(echo "$data_h" | grep -o -E '[0-9]+')


# Load it into Domoticz
curl -s "http://192.168.0.2:8080/json.htm?type=command&param=updateuservariable&vname=hum_water_lvl&vtype=0&vvalue=${w}"
curl -s "http://192.168.0.2:8080/json.htm?type=command&param=updateuservariable&vname=hum_t&vtype=0&vvalue=${t}"
curl -s "http://192.168.0.2:8080/json.htm?type=command&param=updateuservariable&vname=hum_h&vtype=0&vvalue=${h}"
)&
then i try to execute this .sh form dzVents by this script

Code: Select all

        local command = '/home/pi/domoticz/scripts/Xiaomi/humidifier_uv_update.sh'
        os.execute(command)
but nothing happenes, btw if i use this command from putty it update readings.
what i'm doing wrong?

Re: Cant execute bash script from dzvents

Posted: Friday 19 October 2018 0:13
by waaren
Ant1q wrote: Thursday 18 October 2018 22:39 I have Xiaomi Humidifier 2(air washer) and want to read information from Humidifier Sensors(t, %hum and water level), as base i used viewtopic.php?t=17498
.....
i try to execute this .sh form dzVents by this script

Code: Select all

        local command = '/home/pi/domoticz/scripts/Xiaomi/humidifier_uv_update.sh'
        os.execute(command)
but nothing happenes, btw if i use this command from putty it update readings.
what i'm doing wrong?
Is this your complete dzVents script ? If not please show the complete script.
What do you see in the log ?

Re: Cant execute bash script from dzvents

Posted: Friday 19 October 2018 8:35
by Ant1q
log

Code: Select all

2018-10-19 09:30:42.087 Status: dzVents: Info: ------ Start internal script: humidifeir th_water:, trigger: every minute
2018-10-19 09:30:42.169 Status: dzVents: Info: ------ Finished humidifeir th_water
dZ script, but there is only that part does not work - executing bash

Code: Select all

return {
		on = {
		timer = { 'every minute' },
		logging = {
        level = domoticz.LOG_DEBUG,
        marker = ""
                 },
	},
	execute = function(domoticz)
		local wl_raw = domoticz.variables('hum_water_lvl').value
        local t_raw = domoticz.variables('hum_t').value
		local h_raw = domoticz.variables('hum_h').value
		local humid = domoticz.devices('Мойка воздуха').level
		local h = h_raw - humid/5
        local wl = wl_raw/125*100
		local t = t_raw/10
        local hs = domoticz.devices('Мойка воздуха TH').humidityStatus
        local command = '/home/pi/domoticz/scripts/Xiaomi/humidifier_uv_update.sh'
        os.execute(command)
		domoticz.devices('Мойка воздуха TH').updateTempHum(t,h,hs)
		domoticz.devices('Уровень Воды').updatePercentage(wl)
		
        
	end
	
}


Re: Cant execute bash script from dzvents

Posted: Monday 29 October 2018 19:14
by molnaratti
Ant1q wrote: Thursday 18 October 2018 22:39 First of all i'm begginer =) I have Xiaomi Humidifier 2(air washer) and want to read information from Humidifier Sensors(t, %hum and water level), as base i used viewtopic.php?t=17498
I have corrected humidifier.js to recieve separated readings and make bash-script that send it to user variables in domoticz

Code: Select all

#!/bin/bash
(cd /home/pi/domoticz/scripts/Xiaomi

# Main Bedroom Humidifier
# Get the data
data_w=$(node humidifier.js 192.168.0.19 status_water)
data_t=$(node humidifier.js 192.168.0.19 status_t)
data_h=$(node humidifier.js 192.168.0.19 status_h)
# Sort it
w=$(echo "$data_w" | grep -o -E '[0-9]+')
t=$(echo "$data_t" | grep -o -E '[0-9]+')
h=$(echo "$data_h" | grep -o -E '[0-9]+')


# Load it into Domoticz
curl -s "http://192.168.0.2:8080/json.htm?type=command&param=updateuservariable&vname=hum_water_lvl&vtype=0&vvalue=${w}"
curl -s "http://192.168.0.2:8080/json.htm?type=command&param=updateuservariable&vname=hum_t&vtype=0&vvalue=${t}"
curl -s "http://192.168.0.2:8080/json.htm?type=command&param=updateuservariable&vname=hum_h&vtype=0&vvalue=${h}"
)&
then i try to execute this .sh form dzVents by this script

Code: Select all

        local command = '/home/pi/domoticz/scripts/Xiaomi/humidifier_uv_update.sh'
        os.execute(command)
but nothing happenes, btw if i use this command from putty it update readings.
what i'm doing wrong?
Please share your humidifier.js.
Thank you