Author Topic: Fix for time issue  (Read 8003 times)

Offline mcvflorin

  • Administrator
  • Hero Member
  • *****
  • Posts: 1756
  • Karma: +11/-3
Fix for time issue
« on: March 26, 2012, 12:58:12 pm »
NOTE: This won't fix the year resetting to 2010 issue.

Due to a bug in uClibc the time is not updated to the summer time. This is an OpenWRT bug, and it's not Vera specific.

This is a fix for the time issue, which is for both UI4 and UI5 firmwares.

UI4:
Go to MiOS Developers >> Test Luup code and run the script.

UI5:
Go to Apps >> Develop Apps >> Test Luup code and run the script.

Code: [Select]
local TIMEZONE_JSON_URL
local version = luup.version_branch * 100000 + luup.version_major * 10000 + luup.version_minor
if (version >= 111362) then
    TIMEZONE_JSON_URL = "http://download.mios.com/fixes/timezone_UI5.json"
else
    TIMEZONE_JSON_URL = "http://download.mios.com/fixes/timezone_UI4.json"
end

-- Replace the current timezone.json with a fixed one.
os.execute("rm /www/cmh/timezone.json")
os.execute("curl "..TIMEZONE_JSON_URL.." --output /www/cmh/timezone.json")

-- Replace the summertime string in /etc/TZ.
local file = io.open("/etc/TZ", "r+")
local line = file:read("*l")
line = line:gsub("3%.5%.0", "3.4.0")
local tz = line:gsub("10%.5%.0", "10.4.0")
file:seek("set")
file:write(tz)
file:close()

-- Replace the summertime string in /etc/TZ-full
local file = io.open("/etc/TZ-full", "r+")
local line = file:read("*l")
line = line:gsub("3%.5%.0", "3.4.0")
line = line:gsub("10%.5%.0", "10.4.0")
file:seek("set")
file:write(line)
file:close()

-- Update the timezone in /etc/config/system.
os.execute("uci set system.@system[0].timezone=" .. tz)

-- Reload Luup.
luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "Reload", {}, 0)

Edit: Updated the code to fix the timezone parameter in /etc/config/system.
« Last Edit: March 27, 2012, 09:29:22 am by mcvflorin »