This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Energy Management by Wiser
#12
Work with EER31600, with EER31800 don't knwo ?

in user library

WiserLinkIP.lua
Code:
-- ******************************************** --
--               SCHNEIDER ELECTRIC             --
--                                              --
-- Author : Valentin THOMAS                     --
-- Version : 1.0                                --
-- Update Date : 17/10/2017                     --
-- Name : WISER_LINK.lua                        --
--                                              --
-- ******************************************** --


WISER_LINK = function ()
  local self = {script={}}

  local debug = false
  local history = false

  local json = require('json')
  local http = require("socket.http")


  -- -------------------------------------------------------------------
  --- This function
  -- @param (none)
  --
  -- @return (none)
  function round(nb)
    i,f=math.modf(nb)
    return i+(math.ceil(f/0.0625)*0.0625)
  end


  -- -------------------------------------------------------------------
  --- This function
  -- @param (none)
  --
  -- @return (none)
  function self.getData(_ip, _login, _password)
   
    local wiser_data = {}
    local datas, http_code, header, err = http.request("http://".._login..":".._password.."@".._ip.."/vesta/UsageMeter")
   
    --Si le code HTTP de la réponse est 200
    if http_code == 200 then

      if not datas then

        error('Cannot fetch data at : '..ip_address)
   
      else
         
        local datas=json.decode(datas)

        for index,usage in pairs (datas.UsageMeterList)do
           
          usage_name=string.gsub(usage.Type," ","_")--Remplacement de l'espace par un underscore

          wiser_data["Power_"..usage_name]=round(usage.Power)
          wiser_data["Energy_"..usage_name]=round(usage.EnergyConsumed)
         
        end
       
      end
       
    else
      msg=string.format("Error in HTTP request, code:%s, Message:%s",http_code,err)
       
      error(msg)
      log(msg)
      alert(msg)
    end

  end

  -- -------------------------------------------------------------------
  --- This function
  -- @param (none)
  --
  -- @return (none)
  function self.script.event(event, _params)

  end


  -- -------------------------------------------------------------------
  --- This function
  -- @param (none)
  --
  -- @return (none)
  function self.script.cycle( _params )

  end


  -- -------------------------------------------------------------------
  --- This function
  -- @param (none)
  --
  -- @return (none)
  function self.script.scheduler( _params )
   
  end
 
  return self
end

class_var =  WISER_LINK()
return class_var


-- CODE POUR SCRIPTS CLIENT
--[[
WISER_LINK = require('user.WISER_LINK')


params = {
  tag_name = 'record',              -- tag to add to each knx object to record
  records_delay = 1,                -- delay between 2 records in minutes
  records_limit = 50000,            -- limit of the sql table (adviced 50 000 - 10% de la mémoire)

  export_delay = 60,                -- delay between 2 exports on usb key in minutes
  export_value_separator  = ';',    -- name of the export file on the usb key
  export_line_separator = '\r\n',   -- name of the export file on the usb key
  export_file_name = 'log.csv'      -- name of the export file on the usb key
}

]]--


cycling script:

Code:
nb_compt = 6
DEBUG = true

require('user.WiserLinkIP')

--[[ Description du nom des usages

Hot_Water = Eau Chaude Sanitaire
Cooling = Refroidissement
Heating = Chauffage
Sockets = Prises
Others = Autres
Electricity_Meter = Total issu du TIC

]]--


ADD_IP="192.168.1.11" -- Adresse IP du module Wiser Link IP
PORT=80 --Précision d'un numero de port si NAT sinon laisser 80

LOGIN="admin"--Login
PASS="admin"--Mot de passe

if not my_wiser then
  my_wiser=WiserLinkIP.new(ADD_IP..":"..PORT,LOGIN,PASS)
end


-- Récupération des données depuis le module Wiser Link IP
-- Le rafraichissment est basé sur le temps de cycle du présent script

my_wiser:fetchDatas()

--Rafraichissment des valeurs sur KNX/IP
--log(my_wiser)

-- UPDATE KNX VARIABLES
-- Energies
grp.update('6/0/1', my_wiser.Energy_Heating)     --Chauffage
grp.update('6/0/2', my_wiser.Energy_Sockets)     --Prises
grp.update('6/0/3', my_wiser.Energy_Electricity_Meter) --Total
grp.update('6/0/4', my_wiser.Energy_Hot_Water)     --Eau Chaude
grp.update('6/0/5', my_wiser.Energy_Others)     --Autre
grp.update('6/0/6', my_wiser.Energy_Cooling)     --Eau Froide


-- Puissances
--grp.update('6/1/0',my_wiser.Power_Sockets)
--grp.update('8/2/2',my_wiser.Power_Hot_Water)
--grp.update('8/2/3',my_wiser.Power_Heating)
--grp.update('8/2/4',my_wiser.Power_Cooling)
--grp.update('8/2/5',my_wiser.Power_Electricity_Meter)
--grp.update('8/2/6',my_wiser.Power_Others)
-----------
FRANCE SMARTHOME & SMARTBUILDING INTEGRATION
SE ECO EXPERT
Reply


Messages In This Thread
Energy Management by Wiser - by baggins - 23.03.2019, 14:40
RE: Energy Management by Wiser - by baggins - 23.03.2019, 18:24
RE: Energy Management by Wiser - by AlexLV - 24.03.2019, 06:26
RE: Energy Management by Wiser - by AlexLV - 26.03.2019, 07:09
RE: Energy Management by Wiser - by Daniel - 14.07.2019, 09:23
RE: Energy Management by Wiser - by domotiqa - 24.10.2019, 14:20
RE: Energy Management by Wiser - by stemic01 - 13.01.2021, 19:51
RE: Energy Management by Wiser - by Daniel - 14.01.2021, 08:36
RE: Energy Management by Wiser - by stemic01 - 14.01.2021, 11:45
RE: Energy Management by Wiser - by Daniel - 14.01.2021, 12:29
RE: Energy Management by Wiser - by Daniel - 09.01.2023, 10:20
RE: Energy Management by Wiser - by AlexLV - 11.01.2023, 23:12
RE: Energy Management by Wiser - by domotiqa - 25.08.2023, 14:04

Forum Jump: