Page 1 of 1
Beginner Warning-Stuck at first base with send to log
Posted: Wednesday 22 November 2017 17:19
by paul402
Spent a day trying to figure this out now and I watched the video 6 times.

All I want to do is put some data in the log file. I used a variant of the example.
Code: Select all
return {
active = true,
on = {
devices = {
'GetAbHum'
},
},
execute = function(domoticz, device)
domoticz.log('Msg 1 Start Ab Hum switched')
if (switch.state=='On' ) then
domoticz.log('Hey I am ON')
else
domoticz.log('Hey OFF')
end
end
}
I see messages about this in the log file but not my messages. Logging is set to the recommended Errors + Minimal + Generic
Code: Select all
date+time User: Admin initiated a switch command (1197/StartAbNum/On
date+time (GetAbHum) Light/Switch (StartAbHum)
Hardware device info is in the attached graphic.

- dozy.jpg (11.62 KiB) Viewed 1169 times
.
Would appreciate any tips before giving up! I can't spend all day in front of a computer achieving nothing. It is soul destroying.
Re: Beginner Warning-Stuck at first base with send to log
Posted: Wednesday 22 November 2017 22:54
by Doler
You should replace (switch.state=='On' ) with (device.state=='On')
Re: Beginner Warning-Stuck at first base with send to log
Posted: Thursday 23 November 2017 8:22
by dannybloe
You rename the second parameter in your execute function to 'switch':
Code: Select all
execute = function(domoticz, switch)
...
end
Re: Beginner Warning-Stuck at first base with send to log
Posted: Thursday 23 November 2017 12:28
by paul402
Thanks for the suggestions but they did not affect the output at all. I wonder if my installation is corrupt!
Still life is too short. I will find another way to do what I need.
Re: Beginner Warning-Stuck at first base with send to log
Posted: Thursday 23 November 2017 14:27
by dannybloe
Maybe dzVents isn't enabled or you've put the script in the wrong folder? Or did you write it with the internal GUI editor in Domoticz? (and was the active switch set for the script)?
Re: Beginner Warning-Stuck at first base with send to log
Posted: Friday 24 November 2017 0:55
by paul402
Network is set to 127.0.0.1
dzVents 2.2.0 is not disabled
Event is active
Active = true in script
Scripting is from the Domoticz editor
How can I identify if dzVents is actually live on the system? Is there a dzVents script to return the installed version or some debug status?
Re: Beginner Warning-Stuck at first base with send to log
Posted: Friday 24 November 2017 9:04
by dannybloe
if you have loglevel to debug mode then you must see all kind of dzVents logging information in Domoticz' log. Can you verify that? And I'd suggest to switch to the beta which uses dzVents 2.3. Maybe you can try that.
Re: Beginner Warning-Stuck at first base with send to log
Posted: Friday 24 November 2017 11:28
by paul402
Yes with debug on I got this in the log file
Code: Select all
2017-11-24 11:20:20.185 User: Admin initiated a switch command (1197/StartAbHum/On)
2017-11-24 11:20:20.234 dzVents: Debug: Dumping domoticz data to /home/pi/domoticz/scripts/dzVents//domoticzData.lua
2017-11-24 11:20:20.269 dzVents: Debug: Event trigger type: device
2017-11-24 11:20:20.301 dzVents: Debug: Found module in /home/pi/domoticz/scripts/dzVents/generated_scripts folder: testdz
2017-11-24 11:20:20.325 dzVents: Debug: Device-adapter found for StartAbHum: Switch device adapter
2017-11-24 11:20:20.334 dzVents: Debug: Processing device-adapter for StartAbHum: Switch device adapter
2017-11-24 11:20:20.334 dzVents: Debug: Device-event for: StartAbHum value: On
2017-11-24 11:20:20.334 dzVents: Debug: Searching for scripts for changed item: StartAbHum
2017-11-24 11:20:20.344 (GetAbhum) Light/Switch (StartAbHum)
But none of my messages to the log file.
At least I know that the dzVents subsystem is working. I will try the beta soon.
And thanks again for the feedback.
Re: Beginner Warning-Stuck at first base with send to log
Posted: Friday 24 November 2017 11:37
by dannybloe
And where did you put your script?
Re: Beginner Warning-Stuck at first base with send to log
Posted: Saturday 25 November 2017 17:05
by paul402
Its where the system put it, "/home/pi/domoticz/scripts/dzVents/generated_scripts".
If I create a deliberate error and run the script I get an error message in the log so I think that it is in the correct place.
Re: Beginner Warning-Stuck at first base with send to log
Posted: Saturday 25 November 2017 17:42
by paul402
So I deleted my script and wrote it again and it worked! Thank you for all the help. Some how I had either corruption or had entered a hidden character somehow, but everything is working fine now....
I guess a wetware error.