simple web output [feature request]

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
mikrom
Normal user
Posts: 13
Joined: 19 Apr 2017, 19:19

simple web output [feature request]

#1 Post by mikrom » 12 May 2017, 18:56

I've tried search, but no luck.

If there is not, I think it would be easy to implement (we have all necessary stuff in espeasy core).
idea is to make some page (probably custom defined url like <espeasyip>/mypage, or /mypage.html, mypage.xml)
and there will be some user html with variables, thats it

If I write for ex. myfile with code

Code: Select all

<html>
<head><title>%sysname%</title></head>
<body>[DHT#Value]</body>
</html>
I am sure you understand me

krikk
Normal user
Posts: 118
Joined: 28 Feb 2017, 07:57
Location: Austria
Contact:

Re: simple web output [feature request]

#2 Post by krikk » 13 May 2017, 08:43

we have already this: <espeasyip>/json

Ton_vN
Normal user
Posts: 303
Joined: 21 Oct 2016, 15:20
Location: Hengelo (Ov)/ NL
Contact:

Re: simple web output [feature request]

#3 Post by Ton_vN » 13 May 2017, 09:32

Explanation/instruction can be found in the wiki of espeasy

pmitev
New user
Posts: 4
Joined: 06 May 2017, 11:01

Re: simple web output [feature request]

#4 Post by pmitev » 13 May 2017, 14:04

Really nice!

It seems that I have discovered a bug by an accident.
I have a "AM2302" sensor. When the sensor is disconnected, the json prints nan without double quotes for the missing values:

Code: Select all

...
"Sensors":[
{
"TaskName": "AM2302",
"Temperature": nan,
"Humidity": nan
},
...

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: simple web output [feature request]

#5 Post by grovkillen » 13 May 2017, 14:51

pmitev wrote: 13 May 2017, 14:04 Really nice!

It seems that I have discovered a bug by an accident.
I have a "AM2302" sensor. When the sensor is disconnected, the json prints nan without double quotes for the missing values:

Code: Select all

...
"Sensors":[
{
"TaskName": "AM2302",
"Temperature": nan,
"Humidity": nan
},
...
nan IS a numerical value: https://en.m.wikipedia.org/wiki/NaN.

In computing, NaN, standing for not a number, is a numeric data type value representing an undefined or unrepresentable value, especially in floating-point calculations.

So I don't find it to be a bug.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

mikrom
Normal user
Posts: 13
Joined: 19 Apr 2017, 19:19

Re: simple web output [feature request]

#6 Post by mikrom » 13 May 2017, 17:07

okay, that's nice, but not really what I asked :)

I thought some kind of custom page, html, or xml.. where I can write wanted format.
I don't need it desperatelly, but some home automatization want xml output for reading like https://www.papouch.com/en/website/main ... -xml-file/

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: simple web output [feature request]

#7 Post by grovkillen » 13 May 2017, 17:39

Can't the service you pointed to accept JSON but plain HTML? Sounds weird?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

pmitev
New user
Posts: 4
Joined: 06 May 2017, 11:01

Re: simple web output [feature request]

#8 Post by pmitev » 14 May 2017, 10:38

nan IS a numerical value: https://en.m.wikipedia.org/wiki/NaN.

In computing, NaN, standing for not a number, is a numeric data type value representing an undefined or unrepresentable value, especially in floating-point calculations.

So I don't find it to be a bug.
Here is more relevant discussion:
http://stackoverflow.com/questions/1423 ... ecmascript
Finite numbers are stringified as if by calling ToString(number). NaN and Infinity regardless of sign are represented as the String null.
https://jsonlint.com/
null is just fine, but NaN - not for json ...

mikrom
Normal user
Posts: 13
Joined: 19 Apr 2017, 19:19

Re: simple web output [feature request]

#9 Post by mikrom » 15 May 2017, 23:27

it looks like JSON output will be no more hidden: https://github.com/letscontrolit/ESPEasy/pull/292
and my html output idea probably comes too: https://github.com/letscontrolit/ESPEasy/pull/290

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: simple web output [feature request]

#10 Post by grovkillen » 16 May 2017, 05:55

Ah, cool! :)
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

jimmy88
New user
Posts: 1
Joined: 08 Sep 2017, 09:22

Re: simple web output [feature request]

#11 Post by jimmy88 » 08 Sep 2017, 09:27

Try this to validate: json formatter https://jsonformatter-online.com
tool to protect javascript code, 192.168.0.1 router login

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: simple web output [feature request]

#12 Post by grovkillen » 08 Sep 2017, 11:08

Also possible to use Notepad++ (with plugin).
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

mrh_icb
Normal user
Posts: 11
Joined: 08 Oct 2020, 04:15

Re: simple web output [feature request]

#13 Post by mrh_icb » 27 Oct 2020, 02:10

Reviving this thread, does the template processing still work? I tried espeasy mega 20200829, but the {{tags}} do not get replaced,

TD-er
Core team member
Posts: 8748
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: simple web output [feature request]

#14 Post by TD-er » 27 Oct 2020, 09:12

"tags" is indeed not present in the parsing stuff.
See: https://github.com/letscontrolit/ESPEas ... r.cpp#L525

Can you give an example of how to use it and what you would expect to be replaced by {{tags}} ?

mrh_icb
Normal user
Posts: 11
Joined: 08 Oct 2020, 04:15

Re: simple web output [feature request]

#15 Post by mrh_icb » 08 Nov 2020, 01:56

I use it for a simple web page hosted on the ESP itself, so I do not need any external hubs or web server,
and I can still control lights, roller shades, etc. from my phone. The web page triggers rule events.

Basic example:

Code: Select all

<head><title>Shade Control</title></head>
<body>
  <div class="content">
    <h1>Shade Control</h1>
    <p><button onclick="fetch('/tools?cmd=event+up')" class="button">Up</button></p>
    <p><button onclick="fetch('/tools?cmd=event+stop')" class="button">Stop</button></p>
    <p><button onclick="fetch('/tools?cmd=event+down')" class="button">Down</button></p>
  </div>
</body>
It works so far, but it would be more powerful to access ESPEasy system variables via the {{template}} syntax.
e.g. IP, host name, uptime, etc.

Post Reply

Who is online

Users browsing this forum: No registered users and 56 guests