reef-pi :: An opensource reef tank controller based on Raspberry Pi.

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
Location
Missouri
Rating - 0%
0   0   0
I managed to solve it but wondering if there is a better solution, I installed network-manager and added a this to reef-pi.service
Code:
ExecStartPre=/usr/bin/nm-online --quiet --timeout=20

Will wait at least 20secs for the network to come up before starting reef-pi service, seems to work so far but hoping for something cleaner, @Ranjib will be curious if you already have a solution, I tried searching but not successful in finding another solution.

Update, there are lots of solutions to this, trying to find the easiest path forward, just adding sleep now to the ExecPrestart, that should do it also...will poke around some more and see what may be best.

Update2, here is what I currently have set:
Code:
[Unit]
Description=raspberry pi based reef tank controller
After=multi-user.target

[Service]
ExecStartPre=/bin/sleep 20

Not sure I need the sleep since adding the multi-user.target but will need to test some more tomorrow and narrow things down, plus I installed network-manager so I need to re-image and start from scratch again.


:)
 
Last edited:

theatrus

Valuable Member
View Badges
Joined
Mar 26, 2016
Messages
2,253
Reaction score
3,603
Location
Sacramento, CA area
Rating - 0%
0   0   0
So playing with a HS300 and its no workie after a reboot, I see some comments from @Ranjib mentioning this but the outlet once defined will not work unless I restart the service after boot. In the journal I see this error message -
Code:
ERROR: equipment subsystem: Failed to sync equipment hs300 outlet 1 . Error: can't update 1 - can't get output pin

If you restart the service it comes up clean, this is a new load with the latest version, it's the order of the startup, it may be trying to come up before network is up which would cause the issue. I will do some more digging and see if I can pinpoint the issue, unless there is already a fix.

:)

Hmm, this seems fragile. Drivers should not depend on communicating to block the rest of Reef-Pi from starting and the output from working. I'd need to look at the driver for this again to see if there is a simple way to avoid it if it needs to detect something about the hardware.
 

Des Westcott

Well-Known Member
View Badges
Joined
May 29, 2018
Messages
646
Reaction score
1,025
Location
Durban - South Africa
Rating - 0%
0   0   0
Are there any settings in reef-pi that I may have missed or on the tablet? I renamed my pi 220dt so I typed in http://220dt.local and just get a blank screen. It works fine from a computer just nothing else.

Thank you

I have always had intermittent problems when using the local "name". At one stage it worked, then all of a sudden stopped working. However it has always worked if I use the IP address.
 

Freccialata

Community Member
View Badges
Joined
Jan 31, 2020
Messages
54
Reaction score
97
Location
Rome (Italy)
Rating - 0%
0   0   0
If you want restricted access from outside you can simply setup a VPN oln your
I agree with you, but I prefer to have more than "one road" to access.
If the Raspberry itself or the VPN service stuck... I can manage my router and restart the wifi smart plug in another way! ;-)
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
Location
Missouri
Rating - 0%
0   0   0
Hmm, this seems fragile. Drivers should not depend on communicating to block the rest of Reef-Pi from starting and the output from working. I'd need to look at the driver for this again to see if there is a simple way to avoid it if it needs to detect something about the hardware.

I've seen this before I am having to do the network manager trick on my mythtv recording setup, I use network tuners and systemd brings up the application before bringing up the network, this is no different. I see it in the logs that reef-pi is starting up before the network stack and errors out on the hs300 inputs. There are lots of ways to address it, I've listed a couple and will do some more testing tonight, the one that I am using for myth is the first one but that requires you using network manager which is not installed by default and requires lots of tweaking. I am leaning towards the second option, its also working but going to see on a default install if it will work and also if there are any other alternatives that would be better.\

:)
 

Michael Lane

Well-Known Member
View Badges
Joined
Aug 11, 2018
Messages
677
Reaction score
1,121
Rating - 0%
0   0   0
I've seen this before I am having to do the network manager trick on my mythtv recording setup, I use network tuners and systemd brings up the application before bringing up the network, this is no different. I see it in the logs that reef-pi is starting up before the network stack and errors out on the hs300 inputs. There are lots of ways to address it, I've listed a couple and will do some more testing tonight, the one that I am using for myth is the first one but that requires you using network manager which is not installed by default and requires lots of tweaking. I am leaning towards the second option, its also working but going to see on a default install if it will work and also if there are any other alternatives that would be better.\

:)
I think I'd like to see the driver initialization process changed to include an outcome instead of just success or failure. Network based drivers could return a delay/retry result and reef-pi could try again after the requested delay for some number of attempts.

This would allow non-network related drivers to initialize and keep things going, while the network based drivers wait until their requirements are met.
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
Location
Missouri
Rating - 0%
0   0   0
I think I'd like to see the driver initialization process changed to include an outcome instead of just success or failure. Network based drivers could return a delay/retry result and reef-pi could try again after the requested delay for some number of attempts.

This would allow non-network related drivers to initialize and keep things going, while the network based drivers wait until their requirements are met.

Yeah agree that would be a better long term solution, it is a current issue though, would have thought others would have noticed but maybe not a lot of folks using the tp-link stuff and its only on boot. If you restart the service after its up it all works. Never have been a fan of systemd, but it is what it is...

This works also,
Code:
ExecStartPre=/bin/sh -c 'until ping -c1 google.com; do sleep 1; done;'

:)
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,876
Reaction score
16,680
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
I use react and noticed you guys also use react but have no backed experience in GO progrmaing language.

Here is my very rough idea let me know what you think thanks

ReefPI.png
I think it looks awesome and just wanted to say thank you so much for your interest. We could really use your help with various UI enhancement/bugfixing. Use the slackchannel invite in the very first post in this thread to get started. Theres a bunch of issues tagged as UI/UX in github that you can also take a look at.
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,876
Reaction score
16,680
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
I purchased one of the hs300 units, I like the concept but not sure I like the no security thing, I need to dig into it some more and understand how it works, but it appears you only need to be on the local network to control it. Would be nice if they had a way of verifying the request coming if etc, thinking of sticking it on my IOT network which has limited or no access outbound or to my lan. Need to do some more reading on how it works but currently it appears to be ip:9999 and you can do stuff. Here is one of the better article that digs into how it works, not up to date with a current firmware but does go into a lot of detail in how they work - TP-asa outlets
It uses auto-encrypt algorithm over a tcp connection. Its not at all a good security implementation. DLI uses digest auth which is little better but slower in performance. You can audit the details here: https://github.com/reef-pi/drivers/blob/master/tplink/connection.go

Let me know what you think., my current approach has been to have dedicated , locked down SSID for IoT things, and only allow those that work on local. SSID that's connected to internet gateway are on end to end iptables+ipsec (transport layer) encrypted
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,876
Reaction score
16,680
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
I'm still "playing" with my reef-pi, even if it is running on a real fish tank I have to dismiss.

I use on “old” Samsung Galaxy Tab upon my Fish tank.
I also use Chrome and I reach my reef-pi server just with The IP.

The display is always on so that I can see data from my Adafruit’s profile Dashboard.

This is my configuration for the Raspberry:
Smart Plug WiFi --> Power Adapter --> Power Bank --> Raspberry
On the Raspberry is runnung a VPN server so that I can easily connect it from the outside.

On the tablet I have installed TeamViewer and the app to control the smart plug where is connected the Raspberry and the app to control the TP-Link smart plugs that control temperature and (later) the ph.

In case of problem I can access my lan in any way.

Next step is to connect my router to an UPS.... and/or put a SIM in the tablet.

6D3E31AF-D419-4BF1-89DE-05DA0835BC57.jpeg 051B26CC-5A09-4294-9416-DB00466BC109.jpeg
Very nice :-0) . Thank you for sharing
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,876
Reaction score
16,680
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Are there any settings in reef-pi that I may have missed or on the tablet? I renamed my pi 220dt so I typed in http://220dt.local and just get a blank screen. It works fine from a computer just nothing else.

Thank you
the .local domain utilizes mdns/bonjour style discovery. It has different behavior across different devices in different versions. Most new things work, most apple and windows things work. Some older android versions do not work,
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,876
Reaction score
16,680
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
So playing with a HS300 and its no workie after a reboot, I see some comments from @Ranjib mentioning this but the outlet once defined will not work unless I restart the service after boot. In the journal I see this error message -
Code:
ERROR: equipment subsystem: Failed to sync equipment hs300 outlet 1 . Error: can't update 1 - can't get output pin

If you restart the service it comes up clean, this is a new load with the latest version, it's the order of the startup, it may be trying to come up before network is up which would cause the issue. I will do some more digging and see if I can pinpoint the issue, unless there is already a fix.

:)
you can reload reef-pi after pi is restarted to fix this issue. You can also update the systemd unit file for reef-pi to make it wait for network upon startup to permanently fix this issue.
 

scottrotton

Active Member
View Badges
Joined
Oct 5, 2017
Messages
128
Reaction score
135
Location
Sydney
Rating - 0%
0   0   0
I think it looks awesome and just wanted to say thank you so much for your interest. We could really use your help with various UI enhancement/bugfixing. Use the slackchannel invite in the very first post in this thread to get started. Theres a bunch of issues tagged as UI/UX in github that you can also take a look at.
Will join the slack group for Dev talk thanks
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
Location
Missouri
Rating - 0%
0   0   0
you can reload reef-pi after pi is restarted to fix this issue. You can also update the systemd unit file for reef-pi to make it wait for network upon startup to permanently fix this issue.

This is what I am using so far
Code:
ExecStartPre=/bin/sh -c 'until ping -c1 google.com; do sleep 1; done;'
but think we need to make sure users of that equipment are aware that they will need to reload once things come back up, I did notice though that the UI did not always come up either on clean boot. I need to do more testing and see if I can narrow things down, just passing along the information.
:)
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
Location
Missouri
Rating - 0%
0   0   0
It uses auto-encrypt algorithm over a tcp connection. Its not at all a good security implementation. DLI uses digest auth which is little better but slower in performance. You can audit the details here: https://github.com/reef-pi/drivers/blob/master/tplink/connection.go

Let me know what you think., my current approach has been to have dedicated , locked down SSID for IoT things, and only allow those that work on local. SSID that's connected to internet gateway are on end to end iptables+ipsec (transport layer) encrypted

Will take a look at your information, so does the HS300 need internet access or not at least after it is setup. I believe it does if you want to get any energy data from it, but still poking at it. I have a dedicate vlan to iot things and may stick it there but it does not have internet access, I could open it up for certain devices but still thinking about how I want to proceed.

Thanks :)
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,876
Reaction score
16,680
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
This is what I am using so far
Code:
ExecStartPre=/bin/sh -c 'until ping -c1 google.com; do sleep 1; done;'
but think we need to make sure users of that equipment are aware that they will need to reload once things come back up, I did notice though that the UI did not always come up either on clean boot. I need to do more testing and see if I can narrow things down, just passing along the information.
:)
You can just add
Code:
After=network-online.target
Wants=network-online.target
its lot cleaner that way
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,876
Reaction score
16,680
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Will take a look at your information, so does the HS300 need internet access or not at least after it is setup. I believe it does if you want to get any energy data from it, but still poking at it. I have a dedicate vlan to iot things and may stick it there but it does not have internet access, I could open it up for certain devices but still thinking about how I want to proceed.

Thanks :)
It does not need internet access. But the pi to hs300 connection requires local wifi network , which is why i think my proposed solution is better, since it does not rely on internet/google name server. as long as eth0/wlan0 is up (ip assignment), we are good to go
 

MaccaPopEye

Well-Known Member
View Badges
Joined
Jan 5, 2016
Messages
697
Reaction score
1,224
Rating - 0%
0   0   0
The wifi power strips must be compatible with specific protocols. At this time, reef-pi supports some DLI, Shelly 1 and 2.5, and TP-Link HS 103, 110, and 300 outlets. Other systems, like espurna and Tasmota aren't supported yet.
Thanks, if you are just talking about the wifi protocol then it looks like they all use the same IEEE 802.11b/g/n protocol that the board I linked uses. But if you mean some other back end protocol then I am not sure if they are the same or not.

Either way I am still quite time poor atm so I am going to buy the boards I linked as they will be useful on the tank in the meantime anyway. Then I will hopefully have some time in June / July to see if they are compatible with reef-pi or not :)
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
Location
Missouri
Rating - 0%
0   0   0
It does not need internet access. But the pi to hs300 connection requires local wifi network , which is why i think my proposed solution is better, since it does not rely on internet/google name server. as long as eth0/wlan0 is up (ip assignment), we are good to go

I will do some more playing tonight and over weekend, I've seen lots of articles where this does not work:
Code:
After=network-online.target
Wants=network-online.target

Honestly I'm not a systemd fan so I do not fully understand it, but I read several indications that the after and wants does not do what you would think like this - systemd

I will research some more and see what I can figure out, I do not think it will be that straight forward. I think the critical part of that article is this section
The right "wait" service must be enabled too (NetworkManager-wait-online.service if NetworkManager is used to configure the network, systemd-networkd-wait-online.service if systemd-networkd is used, etc.). systemd-networkd.service has Also=systemd-networkd-wait-online.service in its [Install] section, so when systemd-networkd.service is enabled, systemd-networkd-wait-online.service will be enabled too, which means that network-online.target will include systemd-networkd-wait-online.service when and only when systemd-networkd.service is enabled. NetworkManager-wait-online.service is set up similarly. Verify that the right service is enabled (usually only one should be):

Thats what I was doing in my first example but it requires network manager to be installed and configured and I do not think we want to go down that path. Will see what I can figure out.
 
Last edited:

TOP 10 Trending Threads

WHAT AMOUNT OF LIVE ROCK AND SAND SHOULD BE PRIORITIZED FOR OPTIMAL BIODIVERSITY/FILTRATION?

  • 100% live rock + bagged sand

    Votes: 38 26.6%
  • 100% dry rock + 100% live sand

    Votes: 48 33.6%
  • 50/50 live/dry rock, 50/50 live/bagged sand

    Votes: 32 22.4%
  • 75% live rock, 25% live sand

    Votes: 15 10.5%
  • 25% live rock, 75% live sand

    Votes: 10 7.0%
Free Phyto Promo
Spend $39+ → free 16oz Phyto · Use code FREEPHYTO at checkout · $16.99 value · Densest 6-species blend · Free shipping on every order · 100% live arrival guaranteed Spend $39+ → free 16oz Phyto · Use code FREEPHYTO at checkout · $16.99 value · Densest 6-species blend · Free shipping on every order · 100% live arrival guaranteed
Shop Now Code: FREEPHYTO
Back
Top