Panstamp Integration

Begonnen von youngengineer, 17 September 2014, 07:37:09

Vorheriges Thema - Nächstes Thema

youngengineer

Hello, all.

I have some questions regarding panStamp and FHEM.

I have successfully added two panStamps to FHEM and can set register endpoints manually using the regSet command. However past this I am lost.

I would like like to add the individual endpoint registers to a switch on the GUI and bind them to groups as shown on the documentation however I have had little success.

Any help very much appreciated.

justme1968

you can define a swap device for a specific endpoint but the better and more flexible approach ist to use a readingsProxy dir wach endpoint you want to apear as a dedicated switch in the ui.

have a look in the forum ans the wiki for examples. most of fhem are for 1-wire of enocean devices but the concept is the same.

if you are using binout it iss best to use the version with one register per output. not the version that combined multiple outputs to a single register.

best regards
  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

youngengineer

Thanks Andre.

I am currently looking through the 10_EnOcean module in an attempt to figure out how the dimming functionality could be ported over to panStamp.

I've made some progress but not found a complete solution yet!

justme1968

ich will show you a solution based in readingsProxy. looking in other modules will probably not really be helpfull.

  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

youngengineer

Thank you! I will let you know if I make any progress on my end, but I highly doubt it. Its mostly trail and error on my end. Mostly error.

justme1968

i have just send you a complete example with on off and dim commands.

if you have it working it would be nice if you could write a complete summary.

  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

youngengineer

That's very kind of you Andre!

I will test and get back to you with the results. Once I confirm everything is working I will make a complete write-up in English of the steps to get started with FHEM. I'm sure it would be of great help to new users like myself who have no idea where to start.







youngengineer

#7
Andre. Thanks for the help. The script you sent me is working well! But as always I have more questions!

My next question is in regards to creating a macro for editing parameters directly from the GUI.

Say I have a setting which I normally define directly in the config such as defining the location, for example attr global latitude x.xxxx attr global longitude x.xxxx which is also directly editable in the Global settings tab in the GUI. Would it be possible to create a shortcut/macro to edit the specific attribute directly in the GUI, in the same way that you can use readingsProxy assign a devices endpoint register to a room/group?

My end goal is to have a settings tab in the GUI with the most commonly changed/updated settings presented a clean and organized manner to make configuration easier!


justme1968

currently attributes have to be edited in the device detail view.

actually i'm thinking of extending readingsGroup to attributes also. but i have to think some more about it.

  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

youngengineer

It would be very useful. Well for me anyway, I guess you must figure out if there is a demand for such functionality in the community, but I could certainly see it as a very desirable feature. It would provide a very customizable webGUI to users wanting to have more control over the interface.

Btw, do you know if encryption was ported over to FHEM?




justme1968

have a look in the swap thread. i have implemented a beta version for the encryption and there is some feedback that it basically works. i would have to complete it and fix some corner cases.

the main problem with the swap encryption is that it is not possible to verify i the encryption with the given key is valid. that means if you receive a message and have configured the wrong key you can end up with a 'random' message that will not do what you want.
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

youngengineer

I will have a look and let you know how it goes. I'm now having a look at graphing using SVG. I have created a log of the PWM register outputs and created a graph. The log is being populated and so is the graph however, I have noticed that the graph will always stay at 0. I know that the max PWM value is FF as it is in HEX so I think the graphing module does not know how to deal with HEX values. Do I have to convert it back to decimal for SVG to be able to handle the value?

justme1968

yes. you have to convert the values from hex to dec.

if you are using filelog you have to use something like hex($fld[2]) in the devspec line and for dblog $val=hex($val). the 2 hast probably changed to 3.
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

youngengineer

So this modification must be done on the logging side rather then the graphing side. Ok.

I am using filelog, does this look right for the definition?

define Log.PWM FileLog log/test.log SWAP_6C:16.*|hex:($fld[2])


I guess what I will need to do to get the graphing how I want it will be to convert the value to decimal, then divide the value by 2.55 to give a 0-100, then invert the value as the load at 0 would be full power and 255 would be off which otherwise would create some very strange graphing.

justme1968

no. this hast to be done in the gplot file. i.e the SVG editor. not in the filelog definition.

the other way of doing this is to add a user reading to convert the hex values to decimal. and log only this user reading.

the scaling to a 0-100 range can be done in both aproaches. also the inversion.

or you can just chance the labeling on the axes so it matches your values.
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

youngengineer

#15
I've just reinstalled FHEM after receiving a new B+ raspberry PI model.

I am using the new arduino 1.58 IDE.

There seems to be a bug where devices are not identified. CLI is always reporting SWAP unknown device. Even using the stock sketches like binups.

Sometimes however the readings will be populated, but most of the time not its random. Also for custom sketches on the GUI the info such as module name and manufacturer ID will never be shown unless readDeviceXML is manually set.

The device XML files have been uploaded as they always have before and still no luck.

Strange thing is even if I use binups sketch for example it will always miss the last PWM output number 4 but however a previously compiled panstamp on the old IDE will always show all the endpoints.


Hmm Any ideas?

youngengineer

Zitat von: youngengineer am 05 Oktober 2014, 22:11:50
I've just reinstalled FHEM after receiving a new B+ raspberry PI model.

I am using the new arduino 1.58 IDE.

There seems to be a bug where devices are not identified. CLI is always reporting SWAP unknown device. Even using the stock sketches like binups.

Sometimes however the readings will be populated, but most of the time not its random. Also for custom sketches on the GUI the info such as module name and manufacturer ID will never be shown unless readDeviceXML is manually set.

The device XML files have been uploaded as they always have before and still no luck.

Strange thing is even if I use binups sketch for example it will always miss the last PWM output number 4 but however a previously compiled panstamp on the old IDE will always show all the endpoints.

The last image is of the panStamp compiled with the old IDE which shows all 4 PWM endpoints.

I am using the latest FHEM beta install with XML::SIMPLE and all required modules.


Hmm Any ideas?

justme1968

if the old ide did work then the problem is most likely with the new ide. i know of many problems with different ide versions. not only with the panstamps but also with some other arduino based projects.

for a custom sketch you have to use the correct initialization order on startup including the sending of the product code from setup().
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

youngengineer

The custom sketch works fine with Lagarto so I am almost sure this is some incompatibility with FHEM and the new 1.5 panStamp libarys and/or 1.5 IDE! I guess I better go back convert my sketch to work with the 1.0 IDE.

justme1968

you did not say you were using the new panstamp libs.

i have not tried them till now as i'm using a modified version of an older release myself as i had to make some modifications to get the panstamp lib working together with other api devices besides the cc1101.

i'm not sure daniel sees the 1.5 libs ready for production environments. i will try to check bit this will take some time.

if there are no features of the 1.5 lib you need it would be better at the moment to stay with the older version.
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

youngengineer

Hi Andre. I actually got it working correctly after erasing the eeprom on one of my panstamps. eepromToFactoryDefaults()

I bumped into a post coincidentally about the changes to the SWAP stack and how using the new libarys could cause issues on panStamps which were previously flashed to use the older libs.

Strange how my sketch worked on Lagarto and not Fhem though, hmm, all working so far now anyway so sorry to raise the alert.

I'm at a point with Fhem now where I have allot of the functionality which I need which is fantastic. So will be making a short writing soon.

I am still very interested in getting the on-for-timer function working with panStamps, to turn on my LED modules when my PIR is triggered. Right now it will turn on the light however the timer element does not seem to be active. Is this something that must be customized in the helper module you provided me with? Or is it a general FHEM feature?


justme1968

on-for-timer should 'just work' if on and off work.

please try call on-for-timer for a short time manualy: set <device> on-for-timer 10

what happens?
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

youngengineer

#22
As you say it does " Just Work". I did try just a few days ago and could not get it to work, the lights would turn on but not off even when using a 1 second timer.

I have been getting some very strange behavior with FHEM in the past few days. I have tried multiple re-installs which have all ended up with similar errors. I am using the Raspberry PI B+ with a 2A PSU and class 10 SD card. The latest update of FHEM or the readingsProxy module seems to have issues. I have attached a few of the error messages in pictures below. The second picture is of the errors after performing a global update in fhem to the very latest update of today which seems to come from readindingsProxy.

The first picture are of errors on a previous version of FHEM updated to the latest FHEM release only a few weeks ago. There will generally be many pages of these errors that will flood the screen.

Any help appreciated!


youngengineer

#23
** Update

I fixed the issue on the first picture in relation to "SysRq : HELP : loglevel(0-9) reBoot Crash"

It was due to me re-installing XML::SAX due to a missing file error. After re-installing XML::SAX, the UART would be reassigned to the OS. The fix was to remove, console=ttyAMA0,115200 from /boot/cmdline.txt and comment out T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100 from /etc/inittab.

Anyway, the other errors remain however they don't seem to be causing issues with FHEM that I know of.

I do have anotherquestion however!

I am currently using a timer to turn all lights on at sunset, then another timer to dim all lights to 50% at 11pm, notify is then used with my PIR to trigger an event to turn all lights on to 100% for 20 minutes using a on-for-timer which is currently all working fine. However after the timer finishes, all lights will turn off, is there a way to return then lights to the previous state or 50% dim?

Thanks again!

justme1968

for the readingsProxy error message: i will have a look.

for the on-for-timer not working: lease connect Byte telnet to fhem ans enter

  inform timer
  on <device>
  off <device>
  on-for-timer <device> 5

ans then post the complete output.

for the timers: in the two tjmers in addition to swirching the lights you have to write the desired level to an additional reading in the device. this is done with setreading. in the pir notify you would then not use on-for-timer but just on ans deine an temporary at that will switch the lights back to the stored desired level.
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

justme1968

the line numbers from the error message don't match the current readingsProxy version.

what does versionversion readingsProxyreturn? it should be# $Id: 33_readingsProxy.pm 5750 2014-05-05 09:26:45Z justme1968 $
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

youngengineer

#26
Hi Andre. Sorry but my previous post I meant to say that on-for-timer is now working! But before it was not.

The output for readingsproxy is # $Id: 33_readingsProxy.pm 5750 2014-05-05 09:26:45Z justme1968 $


As for the timer I am not quite sure I fully understand. When you say I have to write the desired level to an additional reading using setreading, is that defined on the lights or on the timers?

Is what your saying that I should use notify to turn on the lights then turn them back to their dimmed value afterwards such as. Essentially two different timers running at the same time?

define pirTimer notify SWAP_52:0D.* set AllLights on
define pirTimer2 at +00:00:20 set AllLights dim 50

Not sure if that makes sense. But how would notify trigger the second timer?

I think I may be confused.






justme1968

ok. i was confused as on-for-timer should have worked :)

you would put the reading into each device that is swithced on.

the temporary at would be defined during the execution of the notify. something like this:define pirTimer notify SWAP_52:0D.* set AllLights on; define pirTimer2 at +00:00:20 set AllLights dim 50

if you are sure that you will always go back to 50% that would be all. and you don't even need the setreading mentioned above.

if you want to be sure to catch also vor example a pir going off 10 minutes  before the light is switched off then the code would be something like this:define pirTimer notify SWAP_52:0D.* { fhem(set AllLights on); my $desired = ReadingsVal("AllLights", "myDesired","0"); fhem( "define pirTimer2 at +00:00:20 set AllLights dim $desired");}

and the timer would set the myDesired reading to 0 and 50 respectively in addition to switching the lights on and of.
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

youngengineer

#28
I did not know you could use ; to merge commands in one definition, very nice!

The first example does work, but its inconsistent. It will always run the first part  define pirTimer notify SWAP_52:0D.* set AllLights on; turning lights on, but the second timer part define pirTimer2 at +00:00:20 set AllLights dim 50 it seems to not always work. I would say 50-50 so there is certainly some issue there. I have experimented with different time settings and dim/on/off values with similar results.


The second command I'm not sure how it works, but If used as provided it will through an error as it will look for my as a module and error unknown command my, so I am guessing I need to replace it with a device or endpoint?

To add to the confusion I have some other complexities, I need to have the pir notify enabled only at 11pm otherwise the pir will be bringing the lights up to 100% and then back to 50% before 11pm. The lights need to be at 100% until 11pm then switch to 50% throughout the night until the morning timer turns them off,  or when the PIR is triggered between that time. I think a way around this would be to have the lights revert to their last setting, so that if the pir is triggered before 11pm then they will revert back to 100% which would be their current setting. That is however a Microsoft solution, it would be better to have a setting which activates notify PIR at a certain time.

Its now 5am here so the brain is starting to slow down.

Damn, I have so many questions, I will have to send you a paypal donation at some point for all your help.

youngengineer

#29
Just another update Andre. I managed to get the first command to work consistantly.

The trick was to use a double ;; between the commands.

so  define motionSensor notify SWAP_52:0D.* set myLight3 dim 100;; define pirTimer2 at +00:00:20 set myLight3 dim 30

Seems like when only using a single ; the timer would not return the light back to a dimmed value, it would sometimes stay at the first value 100.

justme1968

about the double ;;

this is one of the reasons you should not not directly edit the them config file but use the web fronted to enter you defines via the DEF and attr text fields.

in the config file you have to do the escaping of ; and newlines by ourself. if you use the web fronted fhem will take care of this (most of the time).

you would for example enterdefine motionSensor notify SWAP_52:0D.* {}into the command box on top of the page or via telnet and then go to the device detail view and klick on DEF and then enterset myLight3 dim 100;; define pirTimer2 at +00:00:20 set myLight3 dim 30without escaping into the text field.

you can activate an editor with syntax highlighting following this steps: http://www.fhemwiki.de/wiki/Konfiguration#Syntaxhervorhebung
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

youngengineer

I've never used the command prompt at the top of the screen, and always edited the config file directly, I like having control over the structure of the config file and grouping of my modules to keep everything neat.

The link you provided is awesome and the syntax highlighting very useful.

I have had an idea for my PIR being active only at certain times of the day. What if I modified my panStamp sketch to include another binary out endpoint, I could then power on that endpoint to HIGH(3.3v) turning on a 3.3v PIR using the at timer module? Or would that be a bad idea?



justme1968

you should just forget that there is something like the config file. in the same way that you do not make the windows registry or a database neat. it really makes things easier if the config file is just that. a config file.

you can use the comment attribute of every device to make small comments and  if the code of the notify gets bigger move it to 99_myUtils.pm and add comments as much as you like.


switching the pir off during the day in a hardware level is certainly an option. you can also just set the disabled attribute of the notify.
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

youngengineer

Ah yes so I could use attr motionSensor disabledForIntervals 05:00-23:00 to disable the notify on the software side, very nice indeed. I think for some reason however I might go with a hardware powerdown as I actually quite like the idea, that way I could also have a manual on/off command too if I bind it to readingsProxy as it would be a separate endpoint. Though I will have to experiment with the PIR, I have a feeling that when it is powered on for the first time that It might push a HIGH out of the output pin as it stabilizes, but again I will have to test.

I'm really starting to enjoy FHEM, its extremely flexible but the learning curve is a little high, some of the translations also make it harder to understand, though I might be able to help at some point to rewrite some of the commandref once I understand it better, although I must say as a German your English is excellent and your support even better. I hope to learn more about perl in the future to get more creative with the modules as there are some things I wish to do which are to complex to even request help for.

















justme1968

feel free to ask whenever there is a need to...
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

youngengineer

#35
Andre, I must request your expertise once again.

I am still wandering about the functionality which we discussed previously, which is now very important to me. I almost have the GUI just as I would like it but I really would like to have a user friendly way to change key parameters without having to go through the command line or go through DEF.

For example say I have my dimming timer, SWAP_52:0D.* set myLight3 dim 100; define pirTimer2 at +00:00:20 set myLight3 dim 30

In the same way that it is possible using webcmd  on:off:dim,0,10,100 shortcuts etc which will display some form of graphical control on the GUI itself, surly it would be possible to do so with other modules.

For example say I have my dimming timer, SWAP_52:0D.* set myLight3 ($DIMVALUE); define pirTimer2 at ($TIMEVALUE) set myLight3 ($DIM2VALUE)

How difficult would it be to the the same principles to push these values to the GUI in the same way that other modules do? So for example have a simple timer:textbox value displayed for the timer or a simple dim:,0,10,20,30 etc dropdown box to select the dim value directly from the GUI for that module?

I understand this is not so easy as it will most likely require custom modification to the myutils module, but I am just wondering if you might be able to give me an example!

If not please let me pay your help in doing so!

Thanks again!



youngengineer

Andre, I understand my previous request may be a bit much to ask for. I will try to find a private developer to help instead.

A have a slightly simpler question which may not take to much of your time. What would be the easiest way to reverse the dim:slider. Currently moving the slider from the left to the right will decrease LED brightness as the PWM value will increase reducing light output. (LED PSU max output is at 0 and minimum at 255)

0 on the slider should really mean the light is at its minimum value (0xFF) and 100 its maximum (0x00) but it seems to be the other way around, this works fine for powering a LED for example but not in my case due to the PSU design.

I have made the most obvious changes in myutils such as if( $value == 0x00 ) return "on"; etc but the way the slider orders its dim values eludes me.

As you recommended I have also now rectified the issue I was having to completely turn off my LED PSU when the PWM value is equal to or greater then 250 directly in the sketch avoiding having to send a separate command to the Binout endpoint.


Again thanks for your time.

justme1968

just a little bit patience...

to get the slider direction right just change the calculation so that (100-$VALUE) ist used. additional changing in and off to 00 and FF of course.

or you change the sketch to have 0 as off ans FF as on.

for the other questions: the best way would probably bei to introduce additional commanda like level1, level2 and time, store the values as readings in the device and use them with ReadingsVal().
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

youngengineer

Hi Andre.

About the reverse dimmer function, when you are referring to the (100-$VALUE) are you talking about this calculation here?

$value = sprintf( "%02X", $args*2.40+0.5 );

justme1968

yes. something like this:$value = sprintf( "%02X", (100-$args)*2.40+0.5 );
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

youngengineer

That's working well, thank you Andre!

I have a few more questions if you don't mind.

How can I assign devices to the main page, i.e /fhem? Or set the default room/homepage?
When SWAP devices are detected they are added to the SWAP room, how would I hide the SWAP room or have the panStamps added to the hidden room when found?
Is there an easy way to define a specified endpoint for all SWAP devices, for example SWAP_*:0D.* or  SWAP_*:0C


Oh and it seems as though I have a bug. Sometimes some SWAP device endpoints will start to duplicate themselves. No sure why this happens but I will attach a picture. I have checked my sketch and can see anything wrong..


Thanks again for you time.





justme1968

you can not assign anything to the main page currently.

you can use the hiddenroom attribute in the WEB instance where you want to hide things. it should contain a comma separated list of all rooms and interface elements that should be hidden. it is best ti create an additional fhemweb instance with its own port for this.

what exactly do you want to do with this? setting a value can be done with something like set SWAP_.* regSet 0D ...

about the random register values appearing: normaly this happens if there is some rf interference or other cause for bad reception. i should probably add an option to skip registers that are not included in the device xml file.
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

youngengineer

Thanks Andre.

I have used SWAP_.* with the notify module so that I can define a single notify attribute for all motes in the network. It seems to be working correctly so far!


youngengineer

As for the duplicate endpoints, I must be in a very noisy environment as it tends to happen quite often.
I would say at least 6-8 of my motes out of my current 12 have duplicate endpoints, I tend to manually delete them whenever they appear however I agree that It would be better to resolve the issue as you have suggested.

justme1968

please try the attaeched version.

if this helps with the wrong endpoints i will make it a configurable option.
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

youngengineer

Fantastic, Andre, once again! So far no duplicate endpoints though I will have to wait some more time before I can confirm the fix.
I will keep testing for the day and let you know the results.

I do possibly have another bug in regards to FHEM's automatic identification of the SWAP motes function. The system has worked quite well previously however as I have increased the number of motes, I have noticed two motes which have duplicate ID's, so four in total. I'm not sure if this is a limitation or a bug, would you recommend that I set the ID of each Mote manually in the sketch to avoid this issue as you would when using Lagarto? I have now soldered, potted 12 motes so it will be hard to reflash them, but If I have no choice then I will.


justme1968

you can take one of each duplicate pair offline or make it unreachable. then you can set the adress of the remaining ones to non conflicting adressen. then you can bring back the other two.
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

youngengineer

Right ok, I understand what you have said, however it does not work. What you are suggesting is that I power down one of the duplicate pairs then I change the previous device address in the fhem config? Unfortunately they always come back with the same address, hmm. Unless I miss understood and you are suggesting that I assign the address in the sketch?

justme1968

no. not changing the address in the config and not power down a pair but one from each pair and then using set <device> regSet 09 XX to set a new unique adress on each of the two still powered on nodes.

the address register is a normal register that can be written to like any other register. you only have to make sure that at this time only one of the two devices listens. otherwise both would accept the new adress.

if the mote will confirm the changed adress the fhem modul will automatically change the internal definitions to the new adress.

don't forget the 'save' in fhem to save the new device adresses.
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

youngengineer

Right, understood.

That seems to be working fine, thank you.

In the future would it be better practice to simply set the address directly in the sketch, to avoid this type of issue?


justme1968

this would make you less flexible. especialy if it is problematic to access your devices. 

the manual adress setting ahould be no problem of you  aktivate new panstamps one by one.

a fixed adress could potentialy be more reliable if it is worth the disadvantages is your decission.
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968