Plugwise Smile P1 meter

Read Plugwise Smile P1 meter data with HTTP requests from LogicMachine #

About Plugwise Smile P1 #

Plugwise smile_p12.png

The Plugwise Smile P1 gives you real time insight into your energy for both electricity and gas via smartphone or tablet.

Resident or scheduled script #

Create a resident or a scheduled script to read the meter data periodically. Adjust the url as needed.

require('socket.http')

url = 'http://smile:hjzfhmdf@192.168.178.21/core/modules'

socket.http.TIMEOUT = 5
smiledata = socket.http.request(url)

if not smiledata then
  alert('Smile: cannot fetch data')
end

result = {}

function starttag(parser, tag, args)
  if tag == 'measurement' then
    curkey = args.directionality
    if args.tariff_indicator then
      curkey = curkey .. '_' .. args.tariff_indicator
    end

    savevalue = true
  elseif tag:find('_meter') then
    curid = args.id
    result[ curid ] = { type = tag }
  end
end

function chardata(parser, text)
  if savevalue then
    result[ curid ][ curkey ] = tonumber(text)
    savevalue = false
  end
end

-- parse xml
require('lxp').new({
  StartElement = starttag,
  CharacterData = chardata,
}):parse(smiledata)

-- log full result table
log(result)
-- log single consumption item
log(result['ad2ea5e2498e4b658ee54ed149f5f0e8'].consumed)