OWL and Wind Meter Script

Moderator: leecollings

Post Reply
ffranzini
Posts: 1
Joined: Tuesday 19 April 2016 0:46
Target OS: OS X
Domoticz version:
Contact:

OWL and Wind Meter Script

Post by ffranzini »

Hi to everyone
I am a newbie on Domoticz and starting to using it i found some issue and i want to share my small experience, on the past few weeks i tried to implement both OWL energy meter and Lacrosse weather station discovering some discrepancies, to solve those issue i wrote two small LUA scripts using, as a baseline, some code from this forum.

OWL scripts, very simple, to adjust the readings according with the real line voltage, if you need to use it you have only to edit the device name and the new device ID, please remember to create the new virtual device (deviceid) and to edit the name of the real device (Owl on the script, Owl CM119 IT is the virtual device name )

Code: Select all

function update(device, id, power, energy, index)
      commandArray[index] = {['UpdateDevice'] = id .. "|0|" .. power .. ";" .. energy}
end

commandArray = {}

local voltage = 220
local owlvoltage = 230
local deviceid = 5

if devicechanged['Owl'] then
   owl = otherdevices_svalues['Owl']
   print('Owl         : '..owl)

   words = {}
   for w in string.gmatch(owl, "%d+%.?%d*") do
      words[#words + 1] = w
   end

   voltage = voltage / owlvoltage
   power = voltage * tonumber(words[1])
   energy = voltage * tonumber(words[2])

   housepower =  math.floor( (power * 10^1) + 0.5) / (10^1)
   print('Owl CM119 IT : '..housepower)

   commandArray['Owl Switch'] = 'On'
   update("Owl CM119 IT", deviceid, power, energy, 1)

end
Wind script, to take care on some wrong reading on Gust Speed (stuck on 16.4 m/s) and to extract the wind chill,

Code: Select all

function update(device, id, direction, heading, speed, gust, temp, chill, index)
      commandArray[index] = {['UpdateDevice'] = id .. "|0|" .. direction .. ";" .. heading .. ";" .. speed .. ";" .. gust .. ";" .. temp .. ";" .. chill}
end

commandArray = {}

local deviceid = 68

if devicechanged['LaCrosseV2 Wind Meter'] then
   wind = otherdevices_svalues['LaCrosseV2 Wind Meter']
   temp = otherdevices_svalues['LaCrosseV2 Esterno']
   print('LaCrosseV2 Wind Meter : '..wind)
   print('LaCrosseV2 Esterno : '..temp)

   words = {}
   for w in string.gmatch(wind, "%d+%.?%d*") do
      words[#words + 1] = w
   end

   word = {}
   for w in string.gmatch(wind, "%w+") do
      word[#word + 1] = w
   end

   wordt = {}
   for w in string.gmatch(temp, "%d+%.?%d*") do
      wordt[#wordt + 1] = w
   end

direction = tonumber(words[1])
heading = (word[3])
speed = tonumber(words[2])
gust = tonumber(words[3])
temp = tonumber(wordt[1])
chill = tonumber(words[5])
speedwc = speed * 3.6
speedwcexp = speedwc^0.16

   if temp < 10.0 and speedwc > 4.8 then
      chill = 13.12 + (0.6215 * temp) - (11.37 * speedwcexp) + (0.3965 * temp * speedwcexp)
   else
      chill = temp
   end

   chill =  math.floor( (chill * 10^1) + 0.5) / (10^1)

print ('temp  : '..temp)
print ('chill : '..chill)

if gust == 164 then
   gust = speed
else
   gust = gust
end

   commandArray['Wind switch'] = 'On'
   update("Wind", deviceid, direction, heading, speed, gust , temp , chill ,1)
end

return commandArray
I hope this will be helpful

Best

Francesco
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest