Announcement

Collapse
No announcement yet.

Image change according to device status

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Image change according to device status

    Hi All,

    I'm putting together a simple web interface for my homeseer install, all is going well apart from one issue.

    I am trying to get an image to change according to the device status I have tried the following code in an ASP page:

    Code:
    <%
    dim stat
    stat=hs.devicestatus("h3")
    if stat= "2" then
       Response.ContentType = "boileron/jpeg"
    Else
       Response.ContentType = "boileroff/jpeg"
    End if
    %>
    But I think I am way off the mark, could anyone give a nudge in the right direction?

    I am learning this .ASP thing as I go so go easy on me!

    Thanks
    Last edited by supergee; December 29th, 2012, 10:26 AM.

  • #2
    Hi There,

    Anyone got any ideas below is the code I have hashed together to try out the various things I would like to achieve...

    HTML Code:
    <html>
    <table height=60% width=100%>
    <tr>
    <td><a href="lampon.asp">
    <img src="onlamp.jpg" border="0" width="200" alt="Up" />
    </a></td>
    <td><h1>
    <%dim stat
    temp=hs.devicevalue("\2")
       Response.Write "Room Temp "+cstr(temp)%>
    </td>
    <td><h1><a href="stat.asp"><%
    dim stat
    stat=hs.devicestatus("h3")
    if stat= "2" then
       Response.ContentType = "boileron/jpeg"
    Else
       Response.ContentType = "boileroff/jpeg"
    End if
    %></a></td>
    </tr>
    
    <tr>
    <td><a href="setpointup.asp">
    <img src="up.jpg" border="0" width="200" alt="Up" />
    </a></td><td>
    <h1 style="color:blue"><%
    dim stat
    stat=hs.devicevalue("h1")
    response.write "setpoint: "+cstr(stat)%>
    </h1>
    </td><td><a href="setpointdown.asp">
    <img src="down.jpg" border="0" width="200" alt="down" /></td>
    </tr>
    </table>
    </html>
    The link to lampon.asp is another hashed bit of code I have used to have one button to turn on and off a device.

    Code:
    <%
    dim light
    light=hs.devicestatus("a1")
    if light= "3" then
       hs.execX10 "a1","on",0,0 
    Else
       hs.execx10 "a1","off",0,0
    End if
    Response.Redirect("stat.asp")
    %>
    But what I would like to do is have the icon represent the status of the device as well as being the toggle control for that device/script/event?

    Not sure if that made sense?

    Thanks

    Comment


    • #3
      I never really bothered with ASP but I don't see where you are putting the image, I would of thought it was something like this

      HTML Code:
      <%
      dim stat
      stat=hs.devicestatus("h3")
      if stat= 2 then
         Response.Write("<img src='/boileron.jpeg'>")
      Else
         Response.Write("<img src='/boileroff.jpeg'>")
      End if 
      %>
      ??
      My Plugins:

      Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
      Yeelight 3P | Nanoleaf 3P

      Comment


      • #4
        That's exactly what I wanted, cheers now works a treat...

        Comment

        Working...
        X