maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   Situations app - bugs, questions, answers, help etc.. (https://talk.maemo.org/showthread.php?t=94442)

hhaveri 2020-01-07 06:23

Re: Situations app - bugs, questions, answers, help etc..
 
Quote:

Originally Posted by P@t (Post 1564182)
- I have not anymore the two-cells bug but I started with one cell while I thought it should be from zero

Situations automatically records the first cell when you start creating a new Network Cells condition. I suppose this is what happened?

Quote:

Originally Posted by P@t (Post 1564182)
- with flight mode on, the situation was still on

Very good finding, that probably needs separate handling with the new interface then.

Quote:

Originally Posted by P@t (Post 1564182)
- the situation seems to react as expected when moving but I will test more during the day

This sounds like an improvement over the previous version, so perhaps the blind implementation is on the right track :)

Quote:

Originally Posted by P@t (Post 1564182)
- enabling/disabling mobile data does not seem to work; it could be related to the fact that there is something special about having 2 sim slots.

You are probably right. Is there a separate mobile data switch for both sim slots in the system settings?

Br,
Heikki

P@t 2020-01-07 14:09

Re: Situations app - bugs, questions, answers, help etc..
 
Thanks for your blind work :)
The application seems to handle neatly cell towers.

I can confirm that there are settings to handle the possibility to use 2 sims. You can activate one or two sims, and then you can choose one or the other for mobile data. So activating mobile data for 'situations' needs likely to add which one...

nonsuch 2020-08-27 06:22

Re: Situations app - bugs, questions, answers, help etc..
 
I have been using Situations for a while.
It works well with switching wifi on and off depending on whether I'm home or not.
Now I am trying to activate BatteryBuddy when the charger is connected, and deactivate it when the charger is disconnected.
I figured out that I need the Command module for both actions, because I just want to launch the daemon.
So I have:

Name: Charging
When: Device = Charger
What: Command: harbour-batterybuddy-daemon
What: log to situations-buddy-on.txt

This works as expected. (*)

Name: Not Charging
When: Device != Charger
What: Command: /home/nemo/situations/kill-batterybuddy-daemon <=== Problem here
What: log to situations-buddy-off.txt

This works so far that the situation changes correctly when I disconnect the charger, but the command does not: first I just used "killall harbour-batterybuddy-daemon". This works when executed on the command line (ssh), but not through Situations.
Then, I wrapped it in a shell script. Again, this works when executed on the command line but not through situations. (*)

Nothing helpful in the logs (just START/STOP messages).

I told the kill script to log its activity, too, but it logs only when executed manually. Which leads me to believe that Situations does not execute the kill script at all.
Why?

(*) I am confirming with 'ps aux | grep buddy'.

nonsuch 2020-08-28 05:25

Re: Situations app - bugs, questions, answers, help etc..
 
Progress.
The command script now executes. I had to use the full path when calling it.

I had to change the script so that it takes a START and STOP option, and added full paths to all commands just to be sure, as well as some narrative for the logs:
Code:

#!/bin/bash

exec > "$HOME/situations/situations-batterybuddy.txt" 2>&1

whoami
date
echo $1

sleep 5

case $1 in
START)
if /sbin/pidof harbour-batterybuddy-daemon ; then
        echo "no action, harbour-batterybuddy-daemon is already running"
else
            echo "launching harbour-batterybuddy-daemon"
        /usr/bin/harbour-batterybuddy-daemon & disown
fi
;;
STOP)
if /sbin/pidof harbour-batterybuddy-daemon; then
        echo "killing harbour-batterybuddy-daemon"
        /usr/bin/killall -vw harbour-batterybuddy-daemon
else
            echo "not killing harbour-batterybuddy-daemon because it is not running"
fi
;;
esac

But harbour-batterybuddy-daemon neither starts nor stops, even though this works when the script is executed manually, as a normal user.

When executed manually, "$HOME/situations/situations-batterybuddy.txt" contains:
Code:

nemo
Fri Aug 28 08:18:54 EEST 2020
STOP
25045
killing harbour-batterybuddy-daemon
Killed harbour-batterybuddy-daemon(25045) with signal 15

When executed through Situations, "$HOME/situations/situations-batterybuddy.txt" contains:
Code:

nemo
Fri Aug 28 08:18:54 EEST 2020
STOP

I am stumped.

PS: this is academic; at this point itwould be much more practical to just leave BatteryBuddy running and do its thing without help from Situations, but I want to know why the Command plugin isn't doing what I think it should.

hhaveri 2020-08-29 16:31

Re: Situations app - bugs, questions, answers, help etc..
 
Quote:

Originally Posted by nonsuch (Post 1568942)
Progress.
The command script now executes. I had to use the full path when calling it.

I had to change the script so that it takes a START and STOP option, and added full paths to all commands just to be sure, as well as some narrative for the logs:
Code:

#!/bin/bash

exec > "$HOME/situations/situations-batterybuddy.txt" 2>&1

whoami
date
echo $1

sleep 5

case $1 in
START)
if /sbin/pidof harbour-batterybuddy-daemon ; then
        echo "no action, harbour-batterybuddy-daemon is already running"
else
            echo "launching harbour-batterybuddy-daemon"
        /usr/bin/harbour-batterybuddy-daemon & disown
fi
;;
STOP)
if /sbin/pidof harbour-batterybuddy-daemon; then
        echo "killing harbour-batterybuddy-daemon"
        /usr/bin/killall -vw harbour-batterybuddy-daemon
else
            echo "not killing harbour-batterybuddy-daemon because it is not running"
fi
;;
esac

But harbour-batterybuddy-daemon neither starts nor stops, even though this works when the script is executed manually, as a normal user.

When executed manually, "$HOME/situations/situations-batterybuddy.txt" contains:
Code:

nemo
Fri Aug 28 08:18:54 EEST 2020
STOP
25045
killing harbour-batterybuddy-daemon
Killed harbour-batterybuddy-daemon(25045) with signal 15

When executed through Situations, "$HOME/situations/situations-batterybuddy.txt" contains:
Code:

nemo
Fri Aug 28 08:18:54 EEST 2020
STOP

I am stumped.

PS: this is academic; at this point itwould be much more practical to just leave BatteryBuddy running and do its thing without help from Situations, but I want to know why the Command plugin isn't doing what I think it should.

Hi,

Hard to say what the problem is, since I had no problems running your script with the command action. I'm running Situations 3.2.258 on Sailfish 3.3.0.16 (Jolla 1).

Which Situations & Sailfish version are you on?

Br,
Heikki

hhaveri 2020-08-29 16:35

Re: Situations app - bugs, questions, answers, help etc..
 
By the way, you don't need two situations to execute the scripts. You can add one command action with the "START" argument and another command action with "STOP" argument to the same situation. You just need to select "At situation end" for the latter one.

Br,
Heikki

nonsuch 2020-08-31 19:20

Re: Situations app - bugs, questions, answers, help etc..
 
^ thanks for the tip, already implemented!

SailfishOS 3.3.0.16
Situations v3.2.258
Sonar 0.0.5

I solved it!
Something weird happened to the input field for the command for When = Charger. I moved around in it with arrow keys (special keyboard layout) and suddenly there was more text than there was before. I erased it. Still didn't work.
Then I looked at ~/.local/share/harbour-situations2application/harbour-situations2application/situations2/situations.json and found that the command entry had a superfluous '\n' at the end, like so: ... START\n
Apparently this was passed to the shell script _literally_ so that the case/esac did not match.
I removed it manually (edit the .json in nano).

Solution:
- no newlines at the end of the command
and/or
- add a * to the case/esac options:
START*)
STOP*)

It is working now, batterybuddy-daemon is active when I plug the charger in, and stops when I unplug it.
It just takes a couple of minutes to switch states; I guess that's by design (taking less resources).

nonsuch 2020-08-31 19:31

Re: Situations app - bugs, questions, answers, help etc..
 
I am trying to implement the following _without GPS_:

- switch on the Wifi when I'm home
- switch it off when I'm away

I have been using the Network cells condition; it scans and finds 2 cells - does that mean cell towers?
It's been working so-so, sometimes it recognizes when I'm home, sometimes not.
Is there a better way?
I guess I cannot scan for my home wifi ssid when wifi is off?

Additionally I cannot concatenate the 2 Home/Elsewhere conditions into 1 because I cannot choose Wifi state a 2nd time in the same condition (to switch it off at condition end, instead of switching it off in a separate condition, as hhaveri told me).
Why?

hhaveri 2020-09-01 04:47

Re: Situations app - bugs, questions, answers, help etc..
 
Quote:

Originally Posted by nonsuch (Post 1569015)
Is there a better way?

I guess Network cells (yes, basically cell towers) is your best bet. But it does have drawbacks.

First of all, if I remember correctly. it does not work well on Sailfish when the device is sleeping -> Situations might recognise cell changes only after user wakes up the device.

Secondly you need to cover (record) cells in all network technologies (2G/3G/4G/...) and over a long time span to make it as reliable as possible. But of course the location accuracy then suffers.

Quote:

Originally Posted by nonsuch (Post 1569015)
Additionally I cannot concatenate the 2 Home/Elsewhere conditions into 1 because I cannot choose Wifi state a 2nd time in the same condition (to switch it off at condition end, instead of switching it off in a separate condition, as hhaveri told me).
Why?

When a situations ends, it should restore settings like wifi state to the value before that situation was activated. So there is no need to do it explicitly. But if you want to be absolutely sure regardless of the previous state, then you can of course use another situation for it.

Br,
Heikki

nonsuch 2020-09-02 06:09

Re: Situations app - bugs, questions, answers, help etc..
 
Quote:

Originally Posted by hhaveri (Post 1569017)
Secondly you need to cover (record) cells in all network technologies (2G/3G/4G/...) and over a long time span to make it as reliable as possible. But of course the location accuracy then suffers.

Aha!
So does that mean more is better (when Situations is scanning network cells)?

I thought maybe the logic is that ALL cells need to be present for the What to apply...
I collected 8 cells with 2 sim cards, switching all available network modes (2G/3G/4G - took almost half an hour), and still Situations immediately recognizes my "Home" Situation, so that proves that logic wrong.
I will now test how it fares when I leave home, and if it generally switches Wlan off reliably.


All times are GMT. The time now is 09:19.

vBulletin® Version 3.8.8