Cant execute bash script from dzvents

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
Ant1q
Posts: 2
Joined: Thursday 18 October 2018 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Dnipro, Ukraine
Contact:

Cant execute bash script from dzvents

Post 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?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Cant execute bash script from dzvents

Post 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 ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Ant1q
Posts: 2
Joined: Thursday 18 October 2018 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Dnipro, Ukraine
Contact:

Re: Cant execute bash script from dzvents

Post 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
	
}

molnaratti
Posts: 34
Joined: Friday 02 February 2018 16:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Cant execute bash script from dzvents

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest