more G-Labs products

Author Topic: ACPUPSD support  (Read 9018 times)

January 12, 2015, 05:56:51 PM
Reply #30

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
Is the reason I don't have mono-service due to using the standard MRE (mono runtime environment) and not the MDK (mono development kit).  I saw you mention these in a different thread, so I thought maybe you have access to them since you are running a different environment.

January 13, 2015, 12:31:39 AM
Reply #31

drpepper

  • *
  • Information
  • Newbie
  • Posts: 23
Nope, mono-service should be an apt package depending on how you installed HomeGenie on your Pi. (I usually just install with mono-complete to get by without any CLR dependencies). Something like:

Code: [Select]
$ aptitude search mono|grep service
> p   mono-2.0-service                - Mono service manager for CLI 2.0
> p   mono-4.0-service                - Mono service manager for CLI 4.0
$ apt-get install mono-4.0-service -y (depending on what CLR your have installed)
$ cd /usr/local/bin/homegenie && mono-service --debug ./HomeGenie.exe
...etc...

January 13, 2015, 08:07:42 AM
Reply #32

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
I installed the mono-4.0-service package and was able to run HG in mono-service --debug mode.  I tried stopping the service normally via:

Code: [Select]
sudo service homegenie stop
This didn't work with the mono-service so I was not able to test the above code.  Suggestions?

January 13, 2015, 03:21:26 PM
Reply #33

drpepper

  • *
  • Information
  • Newbie
  • Posts: 23
The service command will use /etc/init.d/homegenie which looks for the pid file at a different location. That's why I posted to check with the kill command using the pid file where mono-service puts it  ???

See the difference?
Code: [Select]
$ ls /tmp
 HomeGenie.exe.lock  homegenie.pid  ssh-n4R9fvuVltHa

If you want to use the service command, specify the same pid file when using mono-service like
Code: [Select]
$ mono-service --debug -l:/tmp/homegenie.pid HomeGenie.exe
Then you can probably use service homegenie stop.




January 13, 2015, 04:46:57 PM
Reply #34

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
Right, I got that and used the lock file to stop the mono-service.  I was just wondering if that exits HG the same way as using the service stop command.  I did not get an email when HG exited from mono-service, so if that should have worked when using the kill command, it didn't.

I'll try using the -l command to see how that works.  Thanks!

October 31, 2015, 07:48:39 PM
Reply #35

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
I'm looking to update this code to save the UPS details to a widget rather than outputting to a notification.  It looks like the generic sensor widget would be most appropriate to use (since I don't know anything about building a custom widget).  But, I'm not sure what parameters are available for saving to.  I know about a few that I've used, but I don't have a full list.  Is there a listing on GitHub or the documentation that would help?

Here's what I have right now:
Status.Battery
Sensor.Temperature
Sensor.Luminance
Sensor.Humidity
Meter.Watts
Sensor.DoorWindow
Sensor.Alarm
Sensor.Smoke
Sensor.Flood
Sensor.Heat
Sensor.Generic
Status.Level

I extracted this list from viewing the Javascript of homegenie/generic/sensor.  It would be good if there was a central location for all widgets (assuming one doesn't exist currently).

November 02, 2015, 01:17:29 PM
Reply #36

kevin1

  • *****
  • Information
  • Hero Member
  • Posts: 330
The generic sensor widget allows any parameters to be created and then displayed.  I have this to show how frequently my sump pump is running...

Code: [Select]
Program.AddVirtualModules("HomeAutomation.ArduinoBsmtUtil", "Sensor", "homegenie/generic/sensor", 4, 4);
////
var module4 = Modules.InDomain("HomeAutomation.ArduinoBsmtUtil").WithAddress("4").Get();
Program.RaiseEvent(module4, "Sensor.SCPH", data[AM_SUMP_SCPH], "Sump pump cycles per hour counter on arduino ");

There are benefits to using the pre-defined ones you mention though (if they exist for your parameter)... some force an icon to show up for example.

I also have a generic sensor widget for the "multi-sensor" my Arduinos implement.  I added "uptime" parameter so I can see if they are resetting frequently (My ESP8266 started resetting too frequently after updating the arduino libraries a couple months ago). 
« Last Edit: November 02, 2015, 01:28:27 PM by kevin1 »

November 02, 2015, 05:29:13 PM
Reply #37

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
How did you do the uptime?  I assume you just assign a string to the parameter and format it however you want it to be displayed rather than saving a number of seconds/minutes/hours/etc that HG has to convert (somehow knowing it's a time).

For the this APP, I will be writing state ("ONLINE"), battery remaining percent, and time remaining ("52.2 minutes").  I was thinking that parameters had to be decimal to be displayed, but now that I see you saving strings, that would make it a bit nicer than saving the state as "status.level = 1" which results in "1" showing up all the time.

November 02, 2015, 07:41:19 PM
Reply #38

kevin1

  • *****
  • Information
  • Hero Member
  • Posts: 330
Arduino sends uptime as seconds then in HG I just do a couple rough calculations and display as string...

Code: [Select]
Program.RaiseEvent(module3, "Sensor.Uptime",   upd.ToString()+"d "+uph.ToString()+"h", "Uptime");

November 02, 2015, 07:56:55 PM
Reply #39

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
Ok, that's what I figured.  I have it set up so that I can write the time in either string or float format.  The advantage of float is that I can use the statistics to view the data (should I need to).  But, using a string it's a lot easier since it comes in that way and it's nicely formatted in the widget.

March 03, 2016, 02:35:20 AM
Reply #40

amselem

  • **
  • Information
  • Jr. Member
  • Posts: 25
Hi
I have written a little widget for apcupsd. I also have refined your code to support pushalot notifications.

You can discuss here: http://www.homegenie.it/forum/index.php?topic=1465.0

Please note that I run HG under Windows so I don't know if it's going to help you.

Regards