Device not visible and no variable triggering

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

Moderator: leecollings

Post Reply
PVuser
Posts: 33
Joined: Monday 30 March 2020 19:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: DE
Contact:

Device not visible and no variable triggering

Post by PVuser »

I searched a while, but cannot find any hint. I'm new to Domoticz so it's more difficult for me. Also to detect the reason, so perhaps if this is not the right sub board please move my entry.

The problem 1:
I didn't find my device in any of the programming languages. And I cannot use it there. I only can find the device in device list, at counters and in the list of devices I get in the progamming view. The values are correct displayed.

I put the hardware and device to Domo with the following commands:
- --http://<ip of device>/json.htm?type=command&param=addhardware&htype=15&port=1&name=Fronius&enabled=true
--http://<ip and port of domoticz>/json.htm?type=createvirtualsensor&idx=8&sensorname=FroniusConsumption&sensortype=248

As I workaround I put the value in my deviceAdapter in a user variable.

Code: Select all

commandArray['Variable:nGrid'] = tostring(nGrid);
That I can use than in a lua script, but not in dzVent.

The problem 2: I cannot use dzVent
II followed the wiki tutorial for dzVent, but get not trigger. No trigger on the above described device, nor the user variable. I also tried to set a global variable in a lua script to trigger, but this fails also. I tried it as a numeric value and a string value:

Code: Select all

return {
	on = {
		variables = {
			'Grid','nGrid','sGrid'
		}
	},
	execute = function(domoticz, variable)
		domoticz.log('>>>>>>>>>> Variable ' .. variable.name .. ' was changed'..'to: '..variable, domoticz.LOG_INFO)
		-- code
	end
}
I tried Tasmota devices. They trigger as expected!
I tried timer. They trigger as expected!

Whats wrong. I hope I get any help - Thanks
PVuser
Posts: 33
Joined: Monday 30 March 2020 19:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: DE
Contact:

Re: Device not visible and no variable triggering

Post by PVuser »

Does no one have an idea??
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Device not visible and no variable triggering

Post by waaren »

PVuser wrote: Wednesday 01 April 2020 19:35 Does no one have an idea??
Not really yet. It is difficult for me to understand what your issues are based on your post.
It's unclear to me what the devices are. Maybe if you post a screenshot of the devices tab with the devices you want to evaluate / update in domoticz and tell us how you update them.
Same for the variables. Please show a screenshot and also tell us how you update them.

When not yet familiar with dzVents please start with reading Get started Before implementing (~ 5 minutes). Special attention please for "In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents enabled' is checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
PVuser
Posts: 33
Joined: Monday 30 March 2020 19:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: DE
Contact:

Re: Device not visible and no variable triggering

Post by PVuser »

Many thanks @waaren for your answer.
1) I have to mention, that I read the "Get started" and followed the instructions. So the tipps for starting dzVents I have done :-). Thats what I meant in my first post with "II followed the wiki tutorial..." sorry for unclear statement.

Also I thought, that my last two sentences will explain, that the dzVents basically work. Or isn't it a hint for working?

2) My issues are two things:
- My adopted devices are not visible for programming tasks
- My workaround with a variable didn't work with dzVents

3) The screenshots to devices
utils.png
utils.png (95.08 KiB) Viewed 451 times
This are my devices I added to domoticz with the commands, I wrote in my first post.

I wrote a lua script to get the values from the device and than update domoticz with this commands:

Code: Select all

 
           commandArray[1] = {['UpdateDevice'] = idx_PV .. '|0|' .. PAC .. ';' .. DAY_ENERGY}  -- PV-Leistung
            commandArray[2] = {['UpdateDevice'] = idx_VERBRAUCH .. '|0|' .. EVUNetz }           -- Einspeisung/Bezug 
            commandArray[3] = {['UpdateDevice'] = idx_EIGENVERBRAUCH .. '|0|' .. VERBRAUCH }    -- Akt. Verbrauch
            commandArray['Variable:nGrid'] = tostring(EVUNetz);                                                     -- for workaround
             
It's triggered with "Device". But I also tried triggered "All". That is not the problem. In my log I get:

Code: Select all

2020-04-02 10:12:30.597 Status: EventSystem: Script event triggered: FroniusAdapter
FroniusAdapter is the name of the Script. I think this is the hint, that the script was done sucessfull

The values in the device tab are updated in a correct manner :-)

What not work is the dcVent - script:

Code: Select all

return {
	on = {
		devices = {
			'Smartmeter','FroniusAdapter','POW_01'
		}
	},
	execute = function(domoticz, device)
		domoticz.log('>>>>> Device ' .. device.name .. ' was changed', domoticz.LOG_INFO)
	end
}
The value I want to trigger is 'Smartmeter'. It's listed in the list of devices at the domoticz programming site:
dv.png
dv.png (45.13 KiB) Viewed 451 times
but the scrip will not be triggered. Also it is not usable in a normal lua script with:

Code: Select all

    local meter = otherdevices['Smartmeter']
To test the basic working of the dcVent script I added a Sonoff basic switch called POW_01. If I switch it on/off in the switches Tab I get the protocol output:

Code: Select all

 2020-04-02 10:40:49.295 Status: User: Admin initiated a switch command (3/POW_01/Off)
2020-04-02 10:40:49.437 Status: dzVents: Info: Handling events for: "POW_01", value: "Off"
2020-04-02 10:40:49.437 Status: dzVents: Info: ------ Start internal script: evTestDevice: Device: "POW_01 (Dummy devices)", Index: 3
2020-04-02 10:40:49.437 Status: dzVents: Info: >>>>> Device POW_01 was changed
2020-04-02 10:40:49.437 Status: dzVents: Info: ------ Finished evTestDevice
2020-04-02 10:40:49.611 Status: EventSystem: Script event triggered: FroniusAdapter
So that works fine! (The counters - of course I cannot trigger manually from the visual view, but they will be triggerd by a change of the value in my lua script.)

4) So I did the workaround with a user variable:

In the source code where I get the values from the device and write them to the commandArray (see above) I add the following line:

Code: Select all

commandArray['Variable:nGrid'] = tostring(EVUNetz);
In my lua script I can than use it with:

Code: Select all

   meter= uservariables["nGrid"] 
but not in dzVent:

Code: Select all

return {
	on = {
		variables = {
			'Grid','nGrid','sGrid'
		}
	},
	execute = function(domoticz, variable)
		domoticz.log('>>>>>>>>>> Variable ' .. variable.name .. ' was changed'..'to: '..variable, domoticz.LOG_INFO)
		-- code
	end
}
(I tried several ways of triggering, so there are additional variables sGrid and Grid as normal global variables which I set in the lua script.)

the userVariable is set in Settings-Option-User variable:
var.png
var.png (36.29 KiB) Viewed 451 times
So I hope you now have enougth information to help me. If not, as a different way, we can make a direct connection (mail,whatsapp, teamviewer,..), if you want. And than post the result here for others.

Many thanks in foreward
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Device not visible and no variable triggering

Post by waaren »

PVuser wrote: Monday 30 March 2020 21:41 Whats wrong. I hope I get any help - Thanks
Thx for clarifying I understand now what you try to do and why it does not work as you might expect.

You use classic domoticz Lua commands to update device- and variable values and expect that this will cause trigger an event.
in https://www.domoticz.com/forum/viewtop ... old post you will find an explanation why it does not work. And what is explained there is also true for updating variables with classic Lua commands.

If you want the event system to send a trigger you will have to find another way.
You could try to make a time triggered dzVents or switch to dzVents for the initial script or use the openURL way in classic Lua for updating the device / variable

BTW. Please do not use external sites to post your screenshots. Over time the link will no longer work and therewith make your post meaningless for other forum members. I converted them now to attachments.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest