Generate Readings with hyperlink

Begonnen von andyclimb, 08 April 2015, 15:39:49

Vorheriges Thema - Nächstes Thema

andyclimb

I have an MQTT Device that listens to all messages from esp/ and generates readings for them with the device name and their IP.

Is is posible to have FHEM automatically generate Readings for these that are hyperlinks.... and clickable?
AM

justme1968

you should be able to use a readingsGroup to display your data and use the valueFormat attribute to create these links.
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

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

andyclimb

AM

andyclimb

I've got it working almost perfectly!  one problem. 

How can I stop the Reading 'transmission-state' from appearing in the list. 

I've tried stopping it in the MQQT_DEVICE instance, I've tried playing with definition of the ReadingsGroup, but nothing seems to work. 

The problem is that the readings that appear can be anything.. all my mqtt devices on my network publish themselves as esp/name with IP.. this is the device that listens to that and then makes a list of them all... I want the links to make it easy to manage them.  However the MQTT_DEVICE instance also creates a transmission-state reading which i don't want, as it is added to my list of IPs...

AM

justme1968

make the regex that specifies the readings more specific or return undef from valueFormat for all readings That should be ignored.
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

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

andyclimb

Thank you for getting back to me,

the first option I can't do, as the list of devices is not known to me, so all readings should got there. 

So the second option is the best.  could you give me an example of how to return undef... for a reading called transmission-state. 

I spent a while on it but did not get anywhere!
AM

justme1968

you can create a regex that will exclude a specific reading. something like this:define rg readingsGroup TYPE= MQTT:^((?!transmission-state).)*$

for the second option you need something like this:attr rg valueFormat { return undef if( $READING eq 'transmission-state' ); ... }
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

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

andyclimb

The first one worked really well.  Thank you.

Is there an english source where I can learn more about these regexp.  I seem to struggle a lot in them to get things how i want them to be?

Thanks again

Andrew
AM

justme1968

there are lots of regex tutorials and testers out there. just search for regex or regex perl.

the online testers can be quite nice as you can type a regex and imediately see what they do. just be a little carefull they are not allways 100% correct for exceptions and the not so commin cases.

the regex above is a little special and advanced ans will not be mentioned everyehere. but will be found for example by a search for regex not containing string.

sorry for leaving out direct links. i don't have them with me auf the moment.
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

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