I have a string with hold the data of my smartmeter. I need the 5e element. How do i separete that element.
1508914;1483046;446236;1202730;3018;0
Thanks
split string power
Moderator: leecollings
-
- Posts: 12
- Joined: Tuesday 18 April 2017 21:55
- Target OS: -
- Domoticz version:
- Contact:
Re: split string power
Try this:
str = "1508914;1483046;446236;1202730;3018;0"
words = {}
for word in str:gmatch("([^;]+)") do table.insert(words, word) end
print (words[5])
str = "1508914;1483046;446236;1202730;3018;0"
words = {}
for word in str:gmatch("([^;]+)") do table.insert(words, word) end
print (words[5])
-
- Posts: 12
- Joined: Tuesday 18 April 2017 21:55
- Target OS: -
- Domoticz version:
- Contact:
Re: split string power
Thanks this works.
-
- Posts: 536
- Joined: Friday 23 December 2016 16:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: Netherlands Purmerend
- Contact:
Re: split string power
str = "1508914;1483046;446236;1202730;3018;0"
local result = mw.text.split(str,";")
-- result[4] will give "3018"
local result = mw.text.split(str,";")
-- result[4] will give "3018"
-
- Posts: 6
- Joined: Wednesday 06 September 2017 22:55
- Target OS: Linux
- Domoticz version: V4.10301
- Location: Almere
- Contact:
Re: split string power
Thanks @SweetPants
Fibaro HC2, 2 x Raspberry Pi, Xiaomi, Toon, Homey en nogal wat Z-Wave en ZigBee spul.
Who is online
Users browsing this forum: No registered users and 1 guest