can I do forEach on a table in global_data? [closed]

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

Moderator: leecollings

Post Reply
User avatar
rbisschops
Posts: 63
Joined: Monday 12 May 2014 11:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.2563
Location: Schiedam, Netherlands
Contact:

can I do forEach on a table in global_data? [closed]

Post by rbisschops »

Hi all,

I have a table in global_data that looks like this:

Code: Select all

harmony = {
            poweroff = {
                ['name']='PowerOff',
                ['índex']=10,
                ['lightscene']='video'
            },
            television = {
                ['name']='Televisie',
                ['índex']=20,
                ['lightscene']='video'
            }
        }
it is part of the helpers
I can call it with:

Code: Select all

domoticz.log (domoticz.helpers.harmony.television.lightscene)
But can I also do this:

Code: Select all

       domoticz.helpers.harmony().forEach(function(test)
            domoticz.log (test.name)
        end)
It throws an error:

Code: Select all

2018-06-25 16:01:54.123 Status: dzVents: Error (2.4.6): Harmony set Domoticz: ...moticz/scripts/dzVents/scripts/harmony_V-0-0-2-alpha.lua:101: attempt to call field 'harmony' (a table value)
Thank you all!

Ralph
Last edited by rbisschops on Friday 20 July 2018 15:55, edited 1 time in total.
RPi 3B (master): RFXtrx433, Harmony Hub, Z-Wave devices, CoCo units, Hue, Xiaomi Aquara
RPi 2B (slave): P1 connection, MySensors with custom built watermeter sensors on Aquadis+
RPi’s with: Mosquitto MQTT, Home Bridge, Home Assistant (for evaluation only)
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: can I do forEach on a table in global_data?

Post by dannybloe »

That's correct. forEach is a dzVents construct that is implemented for the various collections. So for other stuff you will have to do a standard Lua for loop.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
User avatar
rbisschops
Posts: 63
Joined: Monday 12 May 2014 11:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.2563
Location: Schiedam, Netherlands
Contact:

Re: can I do forEach on a table in global_data? [closed]

Post by rbisschops »

Thx @dannybloe, was expecting that.
RPi 3B (master): RFXtrx433, Harmony Hub, Z-Wave devices, CoCo units, Hue, Xiaomi Aquara
RPi 2B (slave): P1 connection, MySensors with custom built watermeter sensors on Aquadis+
RPi’s with: Mosquitto MQTT, Home Bridge, Home Assistant (for evaluation only)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest