I have scripts working from switch triggers in /home/pi/domoticz/scripts/python.
The file value written allows a Python program to freeze certain garden window shutters. All well and good.
I would like a Dzvents script to directly write a value to a python file in /home/pi/Documents on a Raspberry so that another python script accessing that file (not in the Domoticz scripts directory) can work with the data.
I couldn't find any info about this. Does it mean that it is not possible?
Writing a file with a value to /home/pi/Documents on Raspberry [Solved]
Moderator: leecollings
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Writing a file with a value to /home/pi/Documents on Raspberry
Sure it is but this is not specific to domoticz or dzVents so you will find the information on how to do that in more generic Lua documentation. I cannot see in your post what kind of value you need and if you want to (re)create a file or insert a value in an existing file. The example below just create a file when it does not exist and append a text line including a variable (here a date/time).paul402 wrote: Thursday 27 June 2019 14:17 I would like a Dzvents script to directly write a value to a python file in /home/pi/Documents on a Raspberry so that another python script accessing that file (not in the Domoticz scripts directory) can work with the data.
Code: Select all
-- write value to file
return
{
on = { timer = { 'every minute' }}, -- just for the example
logging = { level = domoticz.LOG_DEBUG, marker = 'value2File' },
execute = function( dz )
local out = '/home/pi/Documents/"Python file"'
local function osCommand(cmd)
local fileHandle = assert(io.popen(cmd, 'r'))
local commandOutput = assert(fileHandle:read('*a'))
local returnTable = {fileHandle:close()}
dz.log('\nCommand: ' .. cmd ..
'\nReturnCode: ' .. returnTable[3] ..
'\ncommandOutput: ' .. commandOutput,
dz.log_debug)
return commandOutput,returnTable[3] -- rc[3] contains returnCode
end
osCommand ('echo dzVents was here at ' .. dz.time.rawDate .. ' ' .. dz.time.rawTime .. ' >> ' .. out .. '; chmod a+r ' .. out )
end
}Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Writing a file with a value to /home/pi/Documents on Raspberry
The pass2php version
Sorry, can't help it. It's stronger than myself 
Code: Select all
lg('Pass2PHP whas here at '.strftime("%F %T", TIME));-
paul402
- Posts: 105
- Joined: Monday 23 May 2016 23:07
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Writing a file with a value to /home/pi/Documents on Raspberry [Solved]
A big thanks to both of you for a) putting me on the right track. It's so easy when you know how, and b) giving me a new avenue of php to explore!
Who is online
Users browsing this forum: No registered users and 1 guest