Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 762
» Latest member: johnsonfe
» Forum threads: 298
» Forum posts: 1,683

Full Statistics

Online Users
There are currently 355 online users.
» 0 Member(s) | 354 Guest(s)
Bing

Latest Threads
SIP Stopped Working After...
Forum: Report a problem
Last Post: dan
2024 Dec 16, 04:19 PM
» Replies: 6
» Views: 221
Master keeps resetting to...
Forum: Report a problem
Last Post: DavidCNZ
2024 Dec 04, 08:57 PM
» Replies: 12
» Views: 246
installation fails
Forum: Installation and set up questions
Last Post: dan
2024 Nov 20, 06:52 PM
» Replies: 4
» Views: 92
Allow plugins ability to ...
Forum: Feature requests
Last Post: jonathan
2024 Aug 11, 10:56 PM
» Replies: 11
» Views: 489
Tank Fill Function
Forum: Feature requests
Last Post: dan
2024 Jul 12, 03:07 PM
» Replies: 3
» Views: 267
Curl Method Menu
Forum: Installation and set up questions
Last Post: astrogerard
2024 Jun 22, 03:15 PM
» Replies: 4
» Views: 333
Module i2c relay.
Forum: Feature requests
Last Post: litronas
2024 Jun 22, 12:45 PM
» Replies: 5
» Views: 386
problem after upgrade to ...
Forum: Installation and set up questions
Last Post: Darek
2024 May 19, 08:54 PM
» Replies: 2
» Views: 257
Monthly Adjust per Statio...
Forum: Writing plugins
Last Post: cdesouza
2024 Apr 18, 06:33 AM
» Replies: 17
» Views: 874
MQTT Plugin initialised b...
Forum: Report a problem
Last Post: cdesouza
2024 Mar 25, 03:56 PM
» Replies: 2
» Views: 235

 
  Set Timezone
Posted by: paul - 2021 Oct 07, 09:59 PM - Forum: Feature requests - Replies (2)

Hi Dan:

I wrote this script (timezone.py) to set timezone within SIP (ie., without having to go through sudo raspi-config).
The script detects the ip-address of isp (external_ip), to determine its timezone id (e.g. Asia/Shanghai), and then set the timezone via the command line.
Running this script ("python3 /pi/home/SIP/timezone.py") will change the device time on SIP/template/base.html

To test, I switch the timezone between my isp ip-address and a dummy external_ip (external_ip = '64.233.191.255' is a google ip-address in Los Angelse)

#### begin of timezone.py #####
#!/bin/bash
# path: /home/pi/SIP/timezone.py
# references:
# https://www.raspberrypi.org/forums/viewt...p?t=197938
# https://stackoverflow.com/questions/6357...-in-python
"""
change timezone via python script

"""

import json
import urllib.request
import subprocess

GEO_IP_API_URL = 'http://ip-api.com/json/'
external_ip = urllib.request.urlopen('https://ident.me').read().decode('utf8')
#external_ip = '64.233.191.255'
# Creating request object to GeoLocation API
req = urllib.request.Request(GEO_IP_API_URL+external_ip)
# Getting in response JSON
response = urllib.request.urlopen(req).read()
# Loading JSON from text to object
json_response = json.loads(response.decode('utf-8'))

# Print timezone
timezone = json_response['timezone']
print('timezone: {}'.format(timezone))

if __name__ == "__main__":
    out = subprocess.run('sudo ln -fs /usr/share/zoneinfo/' + timezone + ' /etc/localtime', shell=True)
    print(out)
    out = subprocess.run('sudo dpkg-reconfigure -f noninteractive tzdata', shell=True)
    print(out)

#### end of timezone.py #####

In the options page, I include a "Set timezone" button below the 24-hour clock checkbox. This addition shows up in 3 places in options.html page.

1a. In SIP/templates/options.html, I introduce a button id 'cSetTimezone' below the condition 'if name == "tf"'(so this button will appear to the right of 24-hour clock checkbox):

            if datatype == "boolean":
                output += "<input name='o" + name + "' type='checkbox' " + ("checked" if value>0 else "") + ">\n"
                if name == "tf":
                    output += "&nbsp;<button id='cSetTimezone' title=" + json.dumps(_(u'Use only if device time is wrong; Use isp ip-address to correct'), ensure_ascii=False) + ">" + _(u'Set timezone')+"</button>"

1b. In the jQuery section, after jQuery("button#cRestart"), I include a corresponding jQuery("button#cSetTimezone"). The name='stz' is used further down in webpages.py.

        jQuery("button#cRestart").click(function(){
            jQuery("input[name='rstrt']").val(1);
            jQuery("form[name='of']").submit();
        });

        jQuery("button#cSetTimezone").click(function(){
            jQuery("input[name='stz']").val(1);
            jQuery("form[name='of']").submit();
        });

1c. Under the "hidden" section to hide the background checkbox, after the Restart checkbox (name='rstrt'), I hide the "stz" checkbox:
        <input type="hidden" name="rstrt" value="0">
        <input type="hidden" name="stz" value="0">

The button 'stz' requires a restart to update device time.

2. In SIP/webpages.py, I include a u"stz" (set timezone) section ala u"rstrt".

        if u"rstrt" in qdict and qdict[u"rstrt"] == u"1":
            restart(2)
            raise web.seeother(u"/restart")

        if u"stz" in qdict and qdict[u"stz"] == u"1":
            report_timezone_set()
            subprocess.run('sudo python3 /home/pi/SIP/timezone.py', shell=True)
            restart(2)
            raise web.seeother(u"/restart")

Paul

Print this item

  Stations wont turn off after update
Posted by: reformedricky - 2021 Sep 25, 04:04 PM - Forum: Report a problem - Replies (2)

Updated from 3.2.6x to 4.1.2
station 1 and 3 stay on no matter what (restart SIP turns them off for a few seconds) 
i tried disabling all stations and that did not work, is there a way to do a clean install? 
I deleted the folder and pull it from git again, but had the same results... my next stage might be to wipe the SD card.

Print this item

  Pi_plates relayplate support
Posted by: hugie - 2021 Sep 24, 03:42 AM - Forum: Feature requests - Replies (4)

pi_plates makes stackable 7 relay HATs for raspberry pi.  The relays are activated by simple python calls such as RELAY.relayON(platenumber,relaynumber).  What would be involved in implementing a plugin for this?  Has anyone tried?

Print this item

  error loading email_adj plugin
Posted by: paul - 2021 Sep 23, 01:32 PM - Forum: Plugin questions - Replies (5)

Hi Dan,

I couldn't get eamil_adj plug-in to load properly.

Here is the error message when I start sip.py manually (after turning off sip3.service):

pi@comitup-580:~/SIP $ sudo python3 sip.py
...
Ignoring exception while loading the email_adj plug-in.
cannot import name 'Encoders' from 'email' (/usr/lib/python3.7/email/__init__.py)

Also, the pressure_adj plugin does not load, for a different reason:
...
Ignoring exception while loading the pressure_adj plug-in.
No module named 'ospi'

Regard,
Paul

Print this item

  set location with google-map format entry
Posted by: paul - 2021 Sep 17, 01:00 AM - Forum: Feature requests - Replies (1)

Hi Dan,

It is a bit of an effort on a mobile phone to reformat google-map location data ("lat,lon") for the location settings in weather_level_adj plugin.

So here a snippet to do so -- at line number 366 of SIP/plugins/weather_level_adj.py I add:

        # allow for google map loc format (lat, lon)
        loc = lwa_options[u"loc"]
        q_contain_letters = loc.lower().islower() # city name would contain some letters
        if not(q_contain_letters) and (", " in loc):
            lat, lon = loc.split(", ") # assume google map location format: loc="lat, lon"
            lat, lon = map(lambda s: str(round(float(s),4)), [lat, lon]) # keep only 4 decimal places
            loc = "lat="+lat+"_lon="+lon
            lwa_options[u"loc"] = loc

The data will be saved in the original SIP format, "lat=x.xxx_lon=y.yyy", but one can now copy and paste "lat,lon" from google-map drop-pin.

Of course, the original "city name" and SIP formats still work.

Hope it makes setting up SIP a bit easier.

Paul

Print this item

  Possible bug when deactivating a station.
Posted by: numero9 - 2021 Aug 31, 04:58 PM - Forum: Report a problem - Replies (4)

Hi again Dan, thank you for your work and effort in creating and maintaining SIP.

The other day I had to deactivate a station due to a leak.
I noticed that despite being disabled, this station worked when programmed.

Other data:
I have a program with 3 stations. It failed both deactivating 1 of them and deactivating 2.
The disabled station does not appear on the Home screen. But in the log it does appear.

(running version: 4.1.20)

Print this item

  what is the function of pin_relay?
Posted by: paul - 2021 Aug 31, 06:34 AM - Forum: Installation and set up questions - Replies (1)

Hi Dan,


In the file gpio_pins.py, there is a pin_relay assignment for raspberry-pi:


        pin_relay = gv.pin_map[10]


What is the purpose of this pin?


It is set up as an output pin, but I have no clue other than that:


        GPIO.setup(pin_relay, GPIO.OUT)


The latest incarnation of ospi hardware (v1.51) has this pin.  See attached.


Also in the schematic above, there is a second rain sensor input, labeled SR2.

Let's say like SR1, it also accepts binary input states (hi or low), but let's say its mode of operation can be either active low or active high (NC or NO).

What is the proper way to incorporate it in the SIP program?

1. Create a new plugin, or
2. Modify sip.py to include an "OR" gate that combine SR1 and SR2

Paul



Attached Files Thumbnail(s)
   
Print this item

  how to preserve plugin modifications when SIP system is updated
Posted by: paul - 2021 Aug 31, 05:59 AM - Forum: Writing plugins - Replies (1)

Hi Dan,

Let's say I have made a pin reassignment in the buzzer.py plugin:

BUZZER_PIN = 32 --> 
BUZZER_PIN = 10

I want to preserve this reassignment in the following two scenarios:

1. when I perform SIP upgrade, and
2. when I re-install the plugin

If it is not possible, do I just keep a local copy of the modified plugin and then copy it to the SIP/plugins directory after the upgrade or re-install? 

On the other hand, I think the plugin runs independently from sip.py so might not be vulnerable to SIP upgrade.

Paul

Print this item

  Master station adjust
Posted by: astrogerard - 2021 Aug 24, 09:07 PM - Forum: Feature requests - Replies (6)

Hi Dan,

I've seen that the Master station adjust can only have positive values resulting in the master starting x second(s) after the station is activated. Do you think it is possible without too much work to have an option to start the master before the station? I use the master to switch on the 24v system which drives the valves. To reduce the peak current it would be nice to switch on the (large) transformer first without load and a second later activate the valve(s).

--Gerard

Print this item

  I2C io interface
Posted by: astrogerard - 2021 Aug 12, 01:54 PM - Forum: Feature requests - Replies (48)

Hi Dan,

You might have seen the "shift register" discussion. I had some thoughts about the level of knowledge one needs to succesfully and reliably build this. For me no problem but I'm not so sure about the larger audience.

In my setup I directly connect the relayboard to the Pi. Although the Pi has some IO pins and in most setups it works fine I'm still not happy with it. Therefore I want to make a seperate interface between the Pi and the relay board(s). First I wanted to make/develop a pcb with shift registers but now I'm going to focus on I2C.

I'm going to use a (or more) PFC8574 IC's or modules. There are ready to use modules for less than $2 and these modules can be daisy chained effectively having 64 channels/valves to use.

Long intro but I want to know if you have any design considerations on this. From python it is only a few lines of code and I'm not sure if a plugin or just a commandline call is the best approach.

Do you have any thoughts on this? Is it worth to create a plugin for this or will I be the only user and is an commandline call a better/easier choice?

--Gerard



Attached Files Thumbnail(s)
   
Print this item