Create a hyperlink with userReadings?

Begonnen von andyclimb, 01 Oktober 2016, 15:12:44

Vorheriges Thema - Nächstes Thema

andyclimb

I've been struggling with this all day.  I'd like to create a hyperlink from userReadings..  take an IP from a reading and inject it into a URL that is then clickable from FHEM...  not joy..  can't even add a simple string...

I've done it previously with a value format for a readingsGroup like this

attr MQTT_IPs valueFormat <a href='http://$VALUE' target="_blank">$VALUE</a>



but I'd like it to appear now, in the readings list for the actual device...

I've tried


userReadings
{ ( "http://") . (ReadingsVal("mqtt_pc_power","IP",0));; }


and many other variations but i can't get it to append the readings to text... any help appreciated, as usual.

thanks

AM

CoolTux

Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

andyclimb

I tried that.  Nothing happens when it is updated.
I need to be able to insert the ReadsVal into a string containing that text.
AM

CoolTux

Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

andyclimb

Ok, so i was doing something wrong.  And i've made progress...  but it is not working.  I can inject the IP into the HTML but it is not marking it up in FHEM..  see pictures

AM

CoolTux

Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

andyclimb


attr mqtt_pc_power  userReadings URL { "<html><a href='http://".( ReadingsVal("mqtt_pc_power","IP",0))."' target='_blank'>Link</a></html>";; }
AM

rudolfkoenig

I'm afraid there is extra code (FW_htmlEscape) in 01_FHEMWEB.pm wich is converting html into text.
The <html>bla</html> trick is only used for return values of a command (e.g. get or set), which avoids converting.

I have no problems in activating the trick for this purpose (i.e. displaying readings or attributes) too, but I'd like to hear some comments on it from other developers.

andyclimb

AM

CoolTux

Hallo Rudi,

Danke Dir für Deine Antwort. Die Befürchtung mit dem only Works by return hatte ich schon fast, konnte nur nicht testen.


Grüße
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

rudolfkoenig

I've added an exception for Readings only.
Attributes and Internals are not (yet) handled.

Summary:
if the value of a reading is enclosed in <html>...</html>, then the ... is not escaped, and is sent to the Browser as HTML.

andyclimb

I've done an update but this does not seem to changed things. Does it take a while or does a release have to be made to get the changes. Thank you very much for adding this feature.

Andrew
AM

justme1968

every morning at about 8'o clock the changes from the prior day are available with the update command.
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

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

andyclimb

That works!  I'm happy.  thanks everyone!
AM