egregius.be

Urban Exploration, PHP and others…

domoticzphp450

LUA Pass2PHP v2.0

Vervolg op LUA Pass2php

In grote lijnen dezelfde werkwijze als de vorige versie, vooral de functies zijn een groot stuk eenvoudiger geworden waardoor de code wat overzichtelijker en makkelijker te gebruiken is.

Download deze 2 bestanden en plaats ze in de Domoticz scripts folder:
JSON.lua ee5_base64.lua

Maak in Domoticz Events een device lua script, pas eventueel de foldernamen aan.

JSON=loadfile('/volume1/@appstore/domoticz/var/scripts/lua/JSON.lua')()
base64=loadfile('/volume1/@appstore/domoticz/var/scripts/lua/ee5_base64.lua')()
changed=base64.encode(JSON:encode(devicechanged))
devices=base64.encode(JSON:encode(otherdevices))
idx=base64.encode(JSON:encode(otherdevices_idx))
lastupdate=base64.encode(JSON:encode(otherdevices_lastupdate))
os.execute( '/volume1/web/secure/pass2php.php "'..changed..'" "'..devices..'" "'..idx..'" "'..lastupdate..'" &')
commandArray = {}
return commandArray

Maak een php bestand met de naam uit os_execute hierboven.
Opgelet: sinds kort maak ik gebruik van memcached om variabelen tijdelijk te bewaren.

Update: code moved to Github

3 reacties

  1. hi,
    I am experimenting with your pass2php solution and I like it! I now have every change of device status covered with your script, allowing me to ditch the script_device_xxx.lua scripts. But it is unclear to me if the time scripts can also be managed with your pass2php solution?
    Many thanks
    Rolf

    • If you create the script with time in the name instead of device it should run every minute.
      Maybe some alterations are required then, probably you don’t have or don’t need the DeviceChanged array.
      I trigger the pass2php script with a virtual solar device. I update that device during the day with the power generated by the solar inverter. During nighttime I just sent update 0 each minute, just to activate the script as a cron.
      This is probably the easiest way to have the script executed every minute.

LAAT EEN REACTIE ACHTER

Het e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *

Deze site gebruikt Akismet om spam te verminderen. Bekijk hoe je reactie-gegevens worden verwerkt.