Skip to content

Instantly share code, notes, and snippets.

View jisotalo's full-sized avatar

Jussi Isotalo jisotalo

View GitHub Profile
@jisotalo
jisotalo / shelly-porssisahko.js
Created November 17, 2024 11:05
shelly-porssisahko v.3.0.1 preview
/**
* @license
*
* shelly-porssisahko
*
* (c) Jussi isotalo - http://jisotalo.fi
* https://github.com/jisotalo/shelly-porssisahko
*
* License: GNU Affero General Public License v3.0
*/
@jisotalo
jisotalo / gist:6880c2a982c905fd0607186b7e525cf8
Created December 18, 2023 06:14
shelly-porssisahko 2.9.0 test 3
let C_HIST=24,C_ERRC=3,C_ERRD=120,C_DEF={mode:0,m0:{cmd:0},m1:{lim:0},m2:{per:24,cnt:0,lim:-999,sq:0,m:999},vat:24,day:0,night:0,bk:0,err:0,outs:[0],fh:0,inv:0},l={s:{v:"2.9.0",dn:"",st:0,cmd:0,chkTs:0,errCnt:0,errTs:0,upTs:0,timeOK:0,configOK:0,fCmdTs:0,tz:"+02:00",p:{ts:0,now:0,low:0,high:0,avg:0}},p:[],h:[],c:C_DEF},c=!1,o=!1;function i(t,e){e-=t;return 0<=e&&e<3600}function f(t){return Math.floor((t?t.getTime():Date.now())/1e3)}function n(t,e,s){let n=t.toString();for(;n.length<e;)n=s?s+n:" "+n;return n}function u(t){return t.getDate()}function r(t){let e=t.toString();(e="+0000"==(e=e.substring(3+e.indexOf("GMT")))?"Z":e.substring(0,3)+":"+e.substring(3))!=l.s.tz&&(l.s.p.ts=0),l.s.tz=e}function a(t,e){console.log((new Date).toISOString().substring(11)+": "+(e?e+" - ":""),t)}function b(){var t=new Date;l.s.timeOK=2e3<t.getFullYear()?1:0,l.s.dn=Shelly.getComponentConfig("sys").device.name,!l.s.upTs&&l.s.timeOK&&(l.s.upTs=f(t))}function p(t){Shelly.call("KVS.Get",{key:"porssi-config"},function(e,t,s,n){l.c=e
@jisotalo
jisotalo / gist:9b941a8c4dc74064c499e4ff2f1ff27f
Created December 16, 2023 10:18
shelly-porssisahko 2.9.0 test version 2
let C_HIST=24,C_ERRC=3,C_ERRD=120,C_DEF={mode:0,m0:{cmd:0},m1:{lim:0},m2:{per:24,cnt:0,lim:-999,sq:0,m:999},vat:24,day:0,night:0,bk:0,err:0,outs:[0],fh:0,inv:0},c={s:{v:"2.9.0",dn:"",st:0,cmd:0,chkTs:0,errCnt:0,errTs:0,upTs:0,timeOK:0,configOK:0,fCmdTs:0,tz:"+02:00",p:{ts:0,now:0,low:0,high:0,avg:0}},p:[],h:[],c:C_DEF},l=!1,o=!1;function i(t,e){e-=t;return 0<=e&&e<3600}function f(t){return Math.floor((t?t.getTime():Date.now())/1e3)}function n(t,e,s){let n=t.toString();for(;n.length<e;)n=s?s+n:" "+n;return n}function u(t){return t.getDate()}function r(t){let e=t.toString();(e="+0000"==(e=e.substring(3+e.indexOf("GMT")))?"Z":e.substring(0,3)+":"+e.substring(3))!=c.s.tz&&(c.s.p.ts=0),c.s.tz=e}function a(t,e){console.log((new Date).toISOString().substring(11)+": "+(e?e+" - ":""),t)}function b(){var t=new Date;c.s.timeOK=2e3<t.getFullYear()?1:0,c.s.dn=Shelly.getComponentConfig("sys").device.name,!c.s.upTs&&c.s.timeOK&&(c.s.upTs=f(t))}function p(t){Shelly.call("KVS.Get",{key:"porssi-config"},function(e,t,s,n){c.c=e
@jisotalo
jisotalo / gist:9730af21dc319702afc19cff80c39db5
Created December 16, 2023 08:29
shelly-porssisahko v.2.9.0 test version
let C_ERRC=3,C_ERRD=120,C_DEF={mode:0,m0:{cmd:0},m1:{lim:0},m2:{per:24,cnt:0,lim:-999,sq:0,m:999},vat:24,day:0,night:0,bk:0,err:0,outs:[0],fh:0,inv:0},l={s:{v:"2.9.0",dn:"",st:0,cmd:0,chkTs:0,errCnt:0,errTs:0,upTs:0,timeOK:0,configOK:0,fCmdTs:0,tz:"+02:00",p:{ts:0,now:0,low:0,high:0,avg:0}},p:[],h:[],c:C_DEF},c=!1,o=!1;function i(t,e){e-=t;return 0<=e&&e<3600}function f(t){return Math.floor((t?t.getTime():Date.now())/1e3)}function n(t,e,s){let n=t.toString();for(;n.length<e;)n=s?s+n:" "+n;return n}function u(t){return t.getDate()}function r(t){let e=t.toString();(e="+0000"==(e=e.substring(3+e.indexOf("GMT")))?"Z":e.substring(0,3)+":"+e.substring(3))!=l.s.tz&&(l.s.p.ts=0),l.s.tz=e}function a(t,e){console.log((new Date).toISOString().substring(11)+": "+(e?e+" - ":""),t)}function b(){var t=new Date;l.s.timeOK=2e3<t.getFullYear()?1:0,l.s.dn=Shelly.getComponentConfig("sys").device.name,!l.s.upTs&&l.s.timeOK&&(l.s.upTs=f(t))}function p(t){Shelly.call("KVS.Get",{key:"porssi-config"},function(e,t,s,n){l.c=e?e.value:{
/*
Example how to subscribe and handle TwinCAT Logger data
https://jisotalo.github.io
Copyright (c) Jussi Isotalo <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@jisotalo
jisotalo / read-target-ads-routes.js
Last active July 10, 2021 19:39
Reading TwinCAT routes from target system using ads-client Node.js library (https://github.com/jisotalo/ads-client)
/*
Copyright (c) 2021 Jussi Isotalo <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: