Domoticz solar script on Synology NAS

Got the LUA script from this website

http://www.domoticz.com/forum/viewtopic.php?f=23&t=10077&hilit=%2Fusr%2Flocal+WMOID

Had to change it so that it would run on the Synology NAS.

  • change the path to the LUA library script (JSON.lua needs to be copied into path /usr/local/domoticz/var/scripts/lua)
  • make sure that you create the JSON.lua script inside the above lua folder. https://www.domoticz.com/wiki/Lua_-_json.lua
  • Blog for solar script https://www.domoticz.com/forum/viewtopic.php?f=23&t=10077&p=92798#p92798

script modifications    

      local WMOID = '06370'            -- (06370 Eindhoven Airport) Your nearest SYNOP Station for ogimet (to get Cloud layer).
                                        -- Run once with debug=1 to get it in the log. (LK doesn't give the right WMOID)
                                        -- (or, better, choose it there : http://www.ogimet.com/gsynop_nav.phtml.en )
                                        -- ERROR: UTC is calculated wrong to 0700 but should be 0200, otherwise data fails

and

       --json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()  -- For Linux
       --json = (loadfile "D:\\Domoticz\\scripts\\lua\\json.lua")()  -- For Windows
       json = (loadfile "/usr/local/domoticz/var/scripts/lua/JSON.lua")()  -- LK For Synology with via package installed Domoticz

also several other script modifications done

from this website

http://www.domoticz.com/forum/viewtopic.php?f=23&t=10077&p=92830#p92830

 -- Get  SYNOP  message from  Ogimet web  site
      --[[
       hourUTCminus1 = os.date("!%H")-1
       if string.len(hourUTCminus1) == 1 then
          hourUTCminus1 = "0" .. hourUTCminus1
       end
       UTC = os.date("%Y%m%d").. hourUTCminus1.."00" -- os.date("!%M")
       ]]--
       UTC = os.date("!%Y%m%d%H").."00"

and also

    if string.find(synop,"Status: 500") == nil
    then
        if string.find(synop, WMOID) ~= nil    -- first 15 to 25 minutes of the hour ogimet returns an empty string
        then
            rslt = split(synop,",")
            CodeStation = rslt[1]
            rslt = split(synop, " "..CodeStation.. " ")
            Trame = string.gsub(rslt[2], "=", "")
            Trame = CodeStation .." ".. Trame
            rslt = split(Trame, " ")
--      if( DEBUG == 1 ) then print(logprefix .. 'rslt[3]:'..rslt[3]) end
            Octa = string.sub(rslt[3], 1, 1)  -- 3rd char is the cloud layer.  0=no cloud , 1-8= cloudy from 1 to 8 max , 9 =Fog , / = no data
            if Octa == "/"
            then   -- not defined ? take the previous value
                print(logprefix .. 'Octa = /. i.e. no data available from WMOID '..WMOID)
                Octa = uservariables['octa']
            elseif Octa == "9" 
            then
                Octa = 8
            end
            commandArray[indexArray] = {['Variable:octa'] = tostring(Octa)}
            indexArray=indexArray+1
        else
            print(logprefix .. 'ogimet returned no valid data yet.')
            Octa = uservariables['octa']
        end
    else
        print(logprefix .. 'ogimet returned error 500: '..synop)
        Octa = uservariables['octa']
    end

Note that the script requests information to ogimet website based on the UTC time. UTC time is calculated based on your local time and timezone.

The ogimet website provides data for the next hour after 15 – 20 minutes into the next hour. That’s why above modifications are done to make sure script does not crash when no data is received yet.

Asus RT-N66U and Asus RT-AC66U VPN

To create a single network from 2 different sites using 2 Asus routers.
Taken from smallnetbuilder forum.

Originally Posted by bbsc View Post
I prefer tap/udp for joining two networks.
Both nets are 192.168.5.0, netmask 255.255.255.0.
1-st gateway is 192.168.5.1 (router ip), DHCP from 192.168.5.2 to 192.168.5.126.
2-nd gateway is 192.168.5.129 (router ip), DHCP from 192.168.5.130 to 192.168.5.254.

It’s better to add to /jffs/scripts/firewall-start the next strings for to block DHCP queries over OpenVPN (client side will be enough):

#!/bin/sh
ebtables -A INPUT --in-interface tap+ --protocol ipv4 --ip-protocol udp --ip-destination-port 67:68 -j DROP
 ebtables -A INPUT --in-interface tap+ --protocol ipv4 --ip-protocol udp --ip-source-port 67:68 -j DROP
 ebtables -A FORWARD --out-interface tap+ --protocol ipv4 --ip-protocol udp --ip-destination-port 67:68 -j DROP
 ebtables -A FORWARD --out-interface tap+ --protocol ipv4 --ip-protocol udp --ip-source-port 67:68 -j DROP
 a

Create the mentioned firewall-start file yourself. Add text above in it. Save and do a chmod +x firewall-start

(this is pending tests, need to install second router first)

Squeezebox Duet Receiver blue led after power loss

I’ve been struggling with this issue too many times over and over. Time to make a note.

Environment:

Controller connected via wireless network.

Receiver connected via ethernet to LAN.

Router (gateway to WAN with build in router) acting as DHCP server.

Synology NAS running Squeezebox server (7.7.2 at time of writing)

Problem:

Whenever the receiver gets switched off for a couple of hours it will not connect anymore.

The button in front shows a blue led.

The controller can find the receiver but the receiver fails to connect to the squeezebox server (running on a synology NAS in my case).

Pressing the front button for 3 seconds so it restarts or reconnecting the power does not solve the problem. After a while the led turns blue again.

Looking at the DHCP client the MAC address of the receiver (see sticker on bottom) is not listed. So apparently the receiver does not have an IP address. Not sure how the controller manages to find it anyway. ARP packages?

Solution:

Press and hold the front button for 5 seconds, this will reset to default settings.

The button in front will first blink red fast (meaning it sets default settings).

Then red light will keep blinking slower (meaning it has to be setup).

Using the controller, select the receiver.

You will be asked to select wireless or ethernet. This shows that setup has to be done again.

In my environment I select ethernet. After that the receiver shows up in the DHCP list on the router.

Automatically it connects to the synology NAS’ Squeezebox server.

All is well.

GPT protective partition (default Windows 7) is not compatible with Windows XP

When formatting a disk in Windows 7 and then creating a partition, the partition must be of type MBR instead of GPT.

Why doesn’t disk manager warn about this?

Some info from other blog:

After further investigation, I noticed that the drive appeared in the disk management utility on Windows XP as a “GPT protective partition”, thus Win XP could not access it.

This came about via my own lack of knowledge when I initialized the new disk in Windows 7 and selected “GUID partition table (GPT) partition style”.  I should have selected the master boot record (MBR) method.

I couldn’t figure out how to revert the disk. A quick web search for “GPT protective partition” led me to this page:

How to delete GPT Protective Partition – Paul Gu|blog

In Win XP, I followed the command prompt instructions given on that page, and re-initialized, formatted NTFS, etc. Now the drive works fine in both OS

Fortunately I had very little data to lose, but it was an exercise in wasted time due to my own ignorance. 

Thanks to AddRam for some good advice as well (Partition Wizard Bootable CD) – Had I heard it before I reformatted it may have saved me some time and effort

Install InguzEQ on Synology

The Synology DS210j (800MHz 128MB) will be too slow for this with too little memory, but we can try to run it at least.

Using SqueezeBox server 7.5.4-003 spk. Currently latest squeezebox server version is 7.6.1.

Running InguzEQ on Mac 7.6.1 server without problems. Info installing on MAC:

Online instructions with link to installation files

A word document containing instructions

Important notice: while installing on MAC using the installer found on the first link, the inguzDSP files were incorrectly installed in /Library/PreferencePanes (global library, not user specific). Copying the files (InguzDSP script, InguzDSP.exe, InguzDSP.exe.config, DSPUtil.dll) to /Library/PreferencePanes/Squeezebox.prefPane/contents/server/bin/darwin solves the problem.

Installing InguzEQ on synology:

  1. install mono using ‘ipkg install mono’
  2. copy inguzDSP files (InguzDSP script, InguzDSP.exe, InguzDSP.exe.config, DSPUtil.dll) to /volume2/@appstore/SqueezeCenter/Bin
  3. change the InguzDSP script so it starts InguzDSP.exe from the /volume2/@appstore/SqueezeCenter/Bin folder
  4. create /usr/share/InguzEQ so the error.txt log can be created.
  5. start ‘./InguzDSP’ and you should get the line*
  6. copy InguzEQ folder containing the plugin into the /volume2/@appstore/SqueezeCenter/Plugins
  7. restart the server. Check via web page to server if the plugin is installed.
  8. on the SqueezeBox find the plugin via ‘extras’. You may need to restart the server a second time (text indicating ‘restart server’ after selecting plugin via ‘extras’)
  9. install the impuls files (created for example with ‘align’, wav format, single stereo wav file) to  /usr/share/InguzEQ/Impulses
* Synology> ./InguzDSP
Usage: InguzDSP -id clientID [-d outputbitdepth] [-r samplerate] [-wav] [-be]
Notes:
  • Make sure all files have the same owner as the rest of the files in SqueezeCenter folder (chown -R <user>:<group> InguzEQ)
  • I also did a chmod -R 777 InguzEQ
  • have only seen ‘extras’ via server 7.6.1 running on OS-X. How to access InguzEQ menu from 7.5.4?
  • the ‘extras’ menu is visible on the web browser to the 7.5.4-003 spk version on synology, why not on SqueezeBox? (directories are still scanning, related?)

Investigate:

  • why does squeezesoft (squeeze player emulator running on Mac) say ‘preferences could not be saved’ when changing InguzEQ options? InguzEQ is not working***
  • why does squeezebox duet (running 7.5.4) not have the ‘extras’ menu? to solve, see next line (plugin.zip for 7.5.4)
  • for 7.5.4 server use Plugin.pm from Plugin.zip found here changes described here
  • install latest nightly builds on Synology**
Note: in case of problems, check in the Logs folder for server.log (in the SqueezeCenter folder on synology).
***Problems with saving preferences:
When changing settings via de ‘extras – EQ’ menu option on the Squeezebox, you may have saving of settings problems.
Check the <SqueezeCenter>/Logs/server.log file. You can do this realtime by ‘tail -f server.log’. You will find:
[11-08-30 21:37:28.6595] Plugins::InguzEQ::Plugin::oops (526) oops:  – Preferences could not be saved to /usr/share/InguzEQ/Settings/00_04_20_16_f1_e0.settings.conf.

Synology default root password

root/synopass

Things to check when you can’t access Synology from the Mac

Problem: copying files to the DS210j from (path)finder requires a username and password, but even after entering that the copy is aborted.

Things to check:

– ! Make sure the target folder has write permission for group (775)

– NFS Privileges (should not make a difference when using AFP though)

Note when NAS can not access the shared folder check that the guest user has RW access to the shared folder.

Changing transmission settings on Synology diskstation

  • open a terminal, login to synology
  • in case of multiple volumes, check each for the ‘homes’ folder
  • for example cd /volume2/homes
  • in ./homes all users created on the synology (using disk manager) have their home folder
  • go into the home folder used by transmission (you can see which users for example by checking the owner of files created by transmission)
  • do an ls -al to see hidden files
  • there should be a .config folder
  • enter that folder, enter the transmission-daemon folder
  • edit the settings.json
  • restart transmission (use package management of diskstation to easily stop and start transmission, assuming transmission was installed using an spk package)

Settings overview:

https://trac.transmissionbt.com/wiki/EditConfigFiles

settings.json is stored in /usr/local/transmission/var/

Ethernet configuration Linux

Make changes on /etc/hosts CH3SNAS ‘persistent’

/etc/hosts on the CH3SNAS is overwritten each time the NAS is rebooted.

Copy the changed /etc/hosts to /ffp/etc/hosts and update the /ffp/etc/fun_plug.local script and add at the end of the script

cp /ffp/etc/hosts /etc/hosts

You might want to do the same with /etc/resolve.conf (not sure if this one is overwritten as well on reboot)