I am currently working on a fail safe system in case the Shelly (Shelly PRO 4PM) loses connection to the MQTT-Broker.
The fail safe does work so far and i am also getting the unixtimestemp from the shelly. But what i still need is the day of the week from the unixtimestamp.
I need the day of the week because i want the script to change the status of the switches in regards to the time of the day and the day of the week.
Code
Shelly.call(
"Shelly.GetStatus",
{},
function (response) {
h = response.sys.unixtime;
dateObject = new Date(h*1000;)
humanDate = dateObject.getDay();
},
);
The code above works fine until the "new Date" function. I know from the shelly doc that the "new" keyword doesn't work, so i am not surprised my code as a whole doesn't work.
Is there a workaround or something i am missing?
The "new Date" function is the only thing i've found in regards to transforming unix in JavaScript.