more G-Labs products

Author Topic: Temperature sensor widget's cannot be "named"  (Read 7183 times)

January 05, 2015, 08:13:54 PM
Read 7183 times

Wibo

  • ***
  • Information
  • Full Member
  • Posts: 95
Hi all,

instead of trying to debug HomeGenie I decided to try the easy way...

I have a hardware temperature sensor on the I2c bus.
It's a Tmp102 and I need to be able to address at least 16 of them.
On the hardware side everything works out untill now.
Succesfully modified raspberry-sharp and HomeGenie is displaying the values.
HomeGenie on raspberry is also propagating events to my win box, which is very cool

So this question is not really about hardware...

I tried to make a decent hgx/module in Configure/Automation/Raspberry by studying the code of the existing ones.

Somehow my module has a problem with names in general.
I can't change the name, the "Update program" is disabled, widget is showing FakeTemperature instead of a nice name
Second line is showing Automation 1003 instead of some useful info.

I see the same behavior in the DHT-11 sensor, but the GPIO module does it the way I like it.
Already played with VirtualModules, because I want the cluster to behave like the GPIO, but wasn't able to make it work yet.
So first I want to have a single sensor perfect, so I'm not writing code based on something crappy.

I have really no idea what I'm doing wrong without starting to debug HomeGenie.
Therefore I made FakeTemperatureSensor that doesn't rely on any hardware dependencies and exposes my problem.
Is it possible with revision 432 or do I need changes elsewhere?

I attached the hgx from the FakeTemperatureSensor anyone should be able to run that.
and a picture of my test case (Tmp102Cluster is my attempt to work with virtual modules it depends on hardware)

Any help will be appreciated.

Best Regards,
Wibo.

January 05, 2015, 08:56:50 PM
Reply #1

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Hi Wibo,

there must be done a difference between Virtual Modules and Program Modules.

A program module is automatically added by the system and associated to each program.
This can have a specific display widget when calling Program.AddControlWidget. The program module inherits the program name and other program parameters and these cannot be changed by the user unless these are configuration options (see AddInputField method).

A virtual module is added by Program.AddVirtualModule or Program.AddVirtualModules and it is a generic module fully user-configurable.
Virtual modules parameters are updated by programs by using the Program.RaiseEvent method.
See Program Helper Documentation for more informations about how to use these commands.

Also take a look at this discussion:
http://www.homegenie.it/forum/index.php?topic=586.msg3392#msg3392
it might contains other useful informations.

Cheers,
g.
« Last Edit: January 05, 2015, 09:08:16 PM by Gene »

January 05, 2015, 09:05:53 PM
Reply #2

Wibo

  • ***
  • Information
  • Full Member
  • Posts: 95
Hi Gene,

thanks for the pointers, I didn't realize the fundamental difference between Virtual Modules and Program Modules.
The forum thread was new to me too.

I'm on it, let you know the result.

Best regards,
Wibo.

January 05, 2015, 09:07:12 PM
Reply #3

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Please read again the post because I edited it and hopefully better described how it works. =)

g.

January 05, 2015, 10:05:40 PM
Reply #4

Wibo

  • ***
  • Information
  • Full Member
  • Posts: 95
Reread the message, think I'll take GPIO Modules as a template this time, instead of adding virtual modules to a DHT-11 Program module.

Will take some time, work and family comes first.

Let you know...

January 10, 2015, 07:48:26 PM
Reply #5

Wibo

  • ***
  • Information
  • Full Member
  • Posts: 95
Hi Gene,

yesterday I finished the FakeTemperatureCluster, it all works like intended.
Don't know if you can make time to review the hgx, I want to be sure I have a proper foundation for the real stuff I'm going to make. The FakeTemperatureCluster does not depend on any hardware and should run on Mac,Windows,Linux.

Thanks for your explanation about the modules, that was the missing part.

By the way, is it appreciated when I start a new thread where I report the progress of my project?
It would contain lots of info about the hardware I use, how to setup, etc.
If yes, should I do it in "Stories" or "Raspberry Pi GPIO/SPI/I2C" or somewhere else

Best regards,
Wibo.

January 11, 2015, 09:50:24 PM
Reply #6

Wibo

  • ***
  • Information
  • Full Member
  • Posts: 95
Hi all,

When testing the hgx from the previous post I have some issues that worries me.

My setup:
I had FakeTemperatureSensorCluster running at raspberry pi B+ r431 with 3 fake sensors active
HomeGenie on the Pi interconnects with a windows box
On the windows box r394 I use HomeGenie to log the temperature sensor events to a file

Issue 1
The CPU utilization on the Pi (using top in a terminal window) for the mono process is between 40 and 80% when I activate my sensors, when I disable the sensors the load is around 10%

Issue2
Sometimes a widget is not updating (skipping an event) after skipping it continues as usual.
The log file I'm writing to file misses a lot of samples, I'm firing the events fast in the order Sensor1, Sensor2, Sensor3. Looking at the file it almost seems that the last event (Sensor3) is eating the other events when it feels like it.

Snapshot of my logfile:
11-1-2015 20:21:24;RaspberryPi.FakeTSC;HeatEx cold H2o outlet;Sensor3;33.3
11-1-2015 20:21:25;RaspberryPi.FakeTSC;HeatEx cold H2o outlet;Sensor3;34.4
11-1-2015 20:21:26;RaspberryPi.FakeTSC;HeatEx cold H2o outlet;Sensor3;35.5
11-1-2015 20:21:27;RaspberryPi.FakeTSC;HeatEx cold H2o outlet;Sensor3;36.6
11-1-2015 20:21:28;RaspberryPi.FakeTSC;HeatEx cold H2o outlet;Sensor3;37.7
11-1-2015 20:21:29;RaspberryPi.FakeTSC;HeatEx cold H2o outlet;Sensor3;38.8
11-1-2015 20:21:30;RaspberryPi.FakeTSC;HeatEx cold water inlet;Sensor2;28.8
11-1-2015 20:21:30;RaspberryPi.FakeTSC;HeatEx cold H2o outlet;Sensor3;39.9
11-1-2015 20:21:32;RaspberryPi.FakeTSC;Boiler;Sensor1;19.9
11-1-2015 20:21:32;RaspberryPi.FakeTSC;HeatEx cold H2o outlet;Sensor3;31.1
11-1-2015 20:21:33;RaspberryPi.FakeTSC;HeatEx cold water inlet;Sensor2;21.1
11-1-2015 20:21:34;RaspberryPi.FakeTSC;HeatEx cold water inlet;Sensor2;22.2
11-1-2015 20:21:35;RaspberryPi.FakeTSC;HeatEx cold water inlet;Sensor2;23.3
11-1-2015 20:21:35;RaspberryPi.FakeTSC;HeatEx cold H2o outlet;Sensor3;34.4
11-1-2015 20:21:37;RaspberryPi.FakeTSC;HeatEx cold H2o outlet;Sensor3;35.5
11-1-2015 20:21:38;RaspberryPi.FakeTSC;HeatEx cold H2o outlet;Sensor3;36.6
11-1-2015 20:21:39;RaspberryPi.FakeTSC;HeatEx cold water inlet;Sensor2;26.6
11-1-2015 20:21:39;RaspberryPi.FakeTSC;HeatEx cold H2o outlet;Sensor3;37.7
11-1-2015 20:21:40;RaspberryPi.FakeTSC;HeatEx cold water inlet;Sensor2;27.7
11-1-2015 20:21:40;RaspberryPi.FakeTSC;HeatEx cold H2o outlet;Sensor3;38.8
11-1-2015 20:21:41;RaspberryPi.FakeTSC;HeatEx cold H2o outlet;Sensor3;39.9
11-1-2015 20:21:42;RaspberryPi.FakeTSC;HeatEx cold H2o outlet;Sensor3;30
11-1-2015 20:21:43;RaspberryPi.FakeTSC;HeatEx cold water inlet;Sensor2;20
11-1-2015 20:21:43;RaspberryPi.FakeTSC;HeatEx cold H2o outlet;Sensor3;31.1
11-1-2015 20:21:44;RaspberryPi.FakeTSC;HeatEx cold H2o outlet;Sensor3;32.2
11-1-2015 20:21:44;RaspberryPi.FakeTSC;HeatEx cold H2o outlet;Sensor3;32.2
11-1-2015 20:21:45;RaspberryPi.FakeTSC;HeatEx cold water inlet;Sensor2;22.2
11-1-2015 20:21:45;RaspberryPi.FakeTSC;HeatEx cold H2o outlet;Sensor3;33.3
11-1-2015 20:21:46;RaspberryPi.FakeTSC;Boiler;Sensor1;12.2
11-1-2015 20:21:46;RaspberryPi.FakeTSC;HeatEx cold H2o outlet;Sensor3;34.4

Does anyone know what's going on here?
I really hope I'm doing something stupid.

Best regards,
Wibo.

January 11, 2015, 11:18:15 PM
Reply #7

dani

  • *****
  • Information
  • Global Moderator
  • Posts: 535
You have made a too short Pause by default : 1 seconde.
A real sensor doesn't send so much report, only one sometimes when the difference of tempertaure is big enough. And one global report every 2 hours (Batterie,Level of reception).
For sample it's send a tempreture report every 1° difference or less. Generally it's possible to set this value in the sensor in Zwave for exemple.

January 12, 2015, 10:39:46 AM
Reply #8

dani

  • *****
  • Information
  • Global Moderator
  • Posts: 535
Hi Wibo,

Here I join a HGX program based on your, but I add Switchs virtual for change variation up or down and random variations of temperature.
For use those switchs, you can use my APP CPNTRIBUTION : A multi thermostats program with calendar and hour tables : http://www.homegenie.it/forum/index.php?topic=591.0

Cheers
Dani

January 12, 2015, 07:46:00 PM
Reply #9

Wibo

  • ***
  • Information
  • Full Member
  • Posts: 95
Hello Dani,

thanks a lot for your reply.

The advise to lower the UpdateInterval to 30 seconds will not work for me.
Let me explain...

I'm preparing software to build a heat boiler system.
That means monitoring the temperatures of a lot of pipes that can change temperature very rapidly.
I need process control, it doesn't have to be realtime as in microseconds or milliseconds.
I was planning to only send events when the temperature is really changing, but before that I had to test the worst case scenario.

My worst case scenario is between 8 and 16 sensors updating every second and I'm getting into trouble before even reaching the needed count of sensors.

The event system must be 100% reliable.

Imagine a scenario with a smoke sensor or a sensor for your security system generating an event that gets lost just because some random sensor is sending an event at the same time.

I really hoped I made a mistake, because if HomeGenie is not capable of reliably sending at least 20 events per second it can't be used for a heat boiler.
In addition to that, if HomeGenie looses events that have different values every time, I doubt if
it's suitable for the HomeAutomation that I have in mind, reliability is number one priority.

This would really be a big disappointment for me, because I like the way HomeGenie is designed and I really didn't see this one coming.

BTW: I played with Sleep(100) which makes the loss of event more balanced over the 3 sensors, but still a lot of events get lost.

Thanks for the time you invested, appreciate that.

Best regards,
Wibo.


January 12, 2015, 09:27:50 PM
Reply #10

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Hi Wibo,

the update interval can also be 1 seconds, it doesn't really affect performance.
I'm just wondering, where are you getting logs from?
I ran your script on a RPi model B and this is local log with 3 sensors:
Code: [Select]
2015-01-12T20:17:28.2259890+00:00 RaspberryPi.FakeTSC Sensor1 Virtual Module Sensor.Temperature -34.4500000000006
2015-01-12T20:17:28.2665130+00:00 RaspberryPi.FakeTSC Sensor2 Virtual Module Sensor.Temperature -34.4500000000006
2015-01-12T20:17:28.2871880+00:00 RaspberryPi.FakeTSC Sensor3 Virtual Module Sensor.Temperature -34.4500000000006
2015-01-12T20:17:29.3177850+00:00 RaspberryPi.FakeTSC Sensor1 Virtual Module Sensor.Temperature -33.3500000000006
2015-01-12T20:17:29.3321710+00:00 RaspberryPi.FakeTSC Sensor2 Virtual Module Sensor.Temperature -33.3500000000006
2015-01-12T20:17:29.3624330+00:00 RaspberryPi.FakeTSC Sensor3 Virtual Module Sensor.Temperature -33.3500000000006
2015-01-12T20:17:30.4461970+00:00 RaspberryPi.FakeTSC Sensor1 Virtual Module Sensor.Temperature -32.2500000000006
2015-01-12T20:17:30.4715430+00:00 RaspberryPi.FakeTSC Sensor2 Virtual Module Sensor.Temperature -32.2500000000006
2015-01-12T20:17:30.5099760+00:00 RaspberryPi.FakeTSC Sensor3 Virtual Module Sensor.Temperature -32.2500000000006
2015-01-12T20:17:31.5815720+00:00 RaspberryPi.FakeTSC Sensor1 Virtual Module Sensor.Temperature -31.1500000000006
2015-01-12T20:17:31.6093620+00:00 RaspberryPi.FakeTSC Sensor2 Virtual Module Sensor.Temperature -31.1500000000006
2015-01-12T20:17:31.6569370+00:00 RaspberryPi.FakeTSC Sensor3 Virtual Module Sensor.Temperature -31.1500000000006
2015-01-12T20:17:32.7092700+00:00 RaspberryPi.FakeTSC Sensor1 Virtual Module Sensor.Temperature -30.0500000000006
2015-01-12T20:17:32.7595650+00:00 RaspberryPi.FakeTSC Sensor2 Virtual Module Sensor.Temperature -30.0500000000006
2015-01-12T20:17:32.8088950+00:00 RaspberryPi.FakeTSC Sensor3 Virtual Module Sensor.Temperature -30.0500000000006
2015-01-12T20:17:33.8195680+00:00 RaspberryPi.FakeTSC Sensor1 Virtual Module Sensor.Temperature -28.9500000000006
2015-01-12T20:17:33.8608520+00:00 RaspberryPi.FakeTSC Sensor2 Virtual Module Sensor.Temperature -28.9500000000006
2015-01-12T20:17:33.8715230+00:00 RaspberryPi.FakeTSC Sensor3 Virtual Module Sensor.Temperature -28.9500000000006
2015-01-12T20:17:34.9529130+00:00 RaspberryPi.FakeTSC Sensor1 Virtual Module Sensor.Temperature -27.8500000000006
2015-01-12T20:17:34.9821370+00:00 RaspberryPi.FakeTSC Sensor2 Virtual Module Sensor.Temperature -27.8500000000006
2015-01-12T20:17:35.0203120+00:00 RaspberryPi.FakeTSC Sensor3 Virtual Module Sensor.Temperature -27.8500000000006
2015-01-12T20:17:36.0834640+00:00 RaspberryPi.FakeTSC Sensor1 Virtual Module Sensor.Temperature -26.7500000000006
2015-01-12T20:17:36.1084540+00:00 RaspberryPi.FakeTSC Sensor2 Virtual Module Sensor.Temperature -26.7500000000006
2015-01-12T20:17:36.1413100+00:00 RaspberryPi.FakeTSC Sensor3 Virtual Module Sensor.Temperature -26.7500000000006
2015-01-12T20:17:37.2018960+00:00 RaspberryPi.FakeTSC Sensor1 Virtual Module Sensor.Temperature -25.6500000000006
2015-01-12T20:17:37.2818380+00:00 RaspberryPi.FakeTSC Sensor2 Virtual Module Sensor.Temperature -25.6500000000006
2015-01-12T20:17:37.3222320+00:00 RaspberryPi.FakeTSC Sensor3 Virtual Module Sensor.Temperature -25.6500000000006
2015-01-12T20:17:38.3876050+00:00 RaspberryPi.FakeTSC Sensor1 Virtual Module Sensor.Temperature -24.5500000000006
2015-01-12T20:17:38.4022360+00:00 RaspberryPi.FakeTSC Sensor2 Virtual Module Sensor.Temperature -24.5500000000006
2015-01-12T20:17:38.4322370+00:00 RaspberryPi.FakeTSC Sensor3 Virtual Module Sensor.Temperature -24.5500000000006
2015-01-12T20:17:39.5113310+00:00 RaspberryPi.FakeTSC Sensor1 Virtual Module Sensor.Temperature -23.4500000000006
2015-01-12T20:17:39.5567520+00:00 RaspberryPi.FakeTSC Sensor2 Virtual Module Sensor.Temperature -23.4500000000006
2015-01-12T20:17:39.5631630+00:00 RaspberryPi.FakeTSC Sensor3 Virtual Module Sensor.Temperature -23.4500000000006
2015-01-12T20:17:40.6054090+00:00 RaspberryPi.FakeTSC Sensor1 Virtual Module Sensor.Temperature -22.3500000000006
2015-01-12T20:17:40.6410370+00:00 RaspberryPi.FakeTSC Sensor2 Virtual Module Sensor.Temperature -22.3500000000006
2015-01-12T20:17:40.6820690+00:00 RaspberryPi.FakeTSC Sensor3 Virtual Module Sensor.Temperature -22.3500000000006
2015-01-12T20:17:41.6927050+00:00 RaspberryPi.FakeTSC Sensor1 Virtual Module Sensor.Temperature -21.2500000000006
2015-01-12T20:17:41.7224230+00:00 RaspberryPi.FakeTSC Sensor2 Virtual Module Sensor.Temperature -21.2500000000006
2015-01-12T20:17:41.7423220+00:00 RaspberryPi.FakeTSC Sensor3 Virtual Module Sensor.Temperature -21.2500000000006
2015-01-12T20:17:42.8119150+00:00 RaspberryPi.FakeTSC Sensor1 Virtual Module Sensor.Temperature -20.1500000000006
2015-01-12T20:17:42.8335660+00:00 RaspberryPi.FakeTSC Sensor2 Virtual Module Sensor.Temperature -20.1500000000006
2015-01-12T20:17:42.8823980+00:00 RaspberryPi.FakeTSC Sensor3 Virtual Module Sensor.Temperature -20.1500000000006
No event loss here.

If you are using Interconnections and logging from another box you shouldn't be using "Forwarding" because it's based on HTTP and HG http server has a limited number of threads managed by using the Net ThreadPool... and it also has a kind of flood protection.
The proper way of handling such kind of high reliable and real time interconnection is using MQTT instead. Then you won't loose any event =)

Cheers,
g.


January 12, 2015, 09:36:54 PM
Reply #11

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
To setup MQTT, you have to install the mqtt broker on one computer in your network (can be your Win or the RPi box as well) and enable on both HomeGenie servers the MQTT client app (perhaps recompile before enabling it and also disable any "Forwarding" app).
For installing mosquitto (mqtt broker) on raspberry just do a:
sudo apt-get install mosquitto
Then you can choose what modules to publish and share on your MQTT network.
If you are curious to see how HG communicates over MQTT, you can also install the mqtt client app and see the "conversation" between the HG boxes:
sudo apt-get install mosquitto-clients
(mosquitto-clients - Mosquitto command line MQTT clients)

Cheers,
g.
« Last Edit: January 12, 2015, 09:39:06 PM by Gene »

January 12, 2015, 10:40:52 PM
Reply #12

Wibo

  • ***
  • Information
  • Full Member
  • Posts: 95
Hi Gene,

thanks for the reply.

You want to know where I get the logs from...
RPiB+ cell generates the event via an interconnect to a win7 cell which has a hgx using FileStream and TextWriter to create the file, I'm not gonna post it, because it's crappy code just to test my worst case scenario.

If anyone is interested I can cleanup the code and post it.

What you write is awesome, I had no idea about the limitations of forwarding by using an interconnect to another HG cell (It was fast and easy to setup).
Already read a few things about MQTT and the features it offers. Going to start reading all documentation you already have about MQTT and try to setup.

Appreciate your help Gene, thanks a lot!

I'll keep you updated...

Best regards,
Wibo.










January 13, 2015, 12:04:29 AM
Reply #13

Wibo

  • ***
  • Information
  • Full Member
  • Posts: 95
Can confirm that on the RPi side events don't get lost, all events are logged, still having the interconnection active, firing 3 events in a row every second, the RPi is only behind quite a bit.

Next step will be killing interconnection/forwarding and get me a MQTT broker online.

To be continued...


January 13, 2015, 12:06:45 AM
Reply #14

Wibo

  • ***
  • Information
  • Full Member
  • Posts: 95
Forgot to post the cleanup log ;(

2015-01-12T23:44:02.8495690+01:00   RaspberryPi.FakeTSC   Sensor1   Virtual Module   Sensor.Temperature   14.4
2015-01-12T23:44:02.9659140+01:00   RaspberryPi.FakeTSC   Sensor2   Virtual Module   Sensor.Temperature   25.5

2015-01-12T23:44:03.1088910+01:00   RaspberryPi.FakeTSC   Sensor3   Virtual Module   Sensor.Temperature   35.9499999999994

2015-01-12T23:44:04.2200580+01:00   RaspberryPi.FakeTSC   Sensor1   Virtual Module   Sensor.Temperature   15.5
2015-01-12T23:44:04.3468800+01:00   RaspberryPi.FakeTSC   Sensor2   Virtual Module   Sensor.Temperature   26.6
2015-01-12T23:44:04.4706420+01:00   RaspberryPi.FakeTSC   Sensor3   Virtual Module   Sensor.Temperature   37.0499999999995

2015-01-12T23:44:05.5781020+01:00   RaspberryPi.FakeTSC   Sensor1   Virtual Module   Sensor.Temperature   16.6
2015-01-12T23:44:05.7156050+01:00   RaspberryPi.FakeTSC   Sensor2   Virtual Module   Sensor.Temperature   27.7
2015-01-12T23:44:05.8265060+01:00   RaspberryPi.FakeTSC   Sensor3   Virtual Module   Sensor.Temperature   38.1499999999995

2015-01-12T23:44:06.9362400+01:00   RaspberryPi.FakeTSC   Sensor1   Virtual Module   Sensor.Temperature   17.7

2015-01-12T23:44:07.0696740+01:00   RaspberryPi.FakeTSC   Sensor2   Virtual Module   Sensor.Temperature   28.8
2015-01-12T23:44:07.1847650+01:00   RaspberryPi.FakeTSC   Sensor3   Virtual Module   Sensor.Temperature   39.2499999999995

2015-01-12T23:44:08.2958020+01:00   RaspberryPi.FakeTSC   Sensor1   Virtual Module   Sensor.Temperature   18.8
2015-01-12T23:44:08.4308740+01:00   RaspberryPi.FakeTSC   Sensor2   Virtual Module   Sensor.Temperature   29.9
2015-01-12T23:44:08.5735160+01:00   RaspberryPi.FakeTSC   Sensor3   Virtual Module   Sensor.Temperature   30