Announcement

Collapse
No announcement yet.

Images not refreshing or updating properly

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

    Images not refreshing or updating properly

    Hello,
    I've looked around the messageboards for a quick solution for this problem and haven't had any luck.
    I made an asp page that displays a list of events that turn on/off rooms by clicking on the appropriate image.

    Desired Behavior:
    If a room is on, 'image1' displays. If I select the image, the 'turn off room' event is triggered and 'image2' should display.

    Actual Behavior:
    When 'image1' is selected and the page refreshes, 'image1' is still displayed. However, if I hit refresh, 'Image2' then displays.

    So that tells me either it's a caching issue, or the page is processing too fast for HS to actually go update the devices so when I hit refresh, everything is updated and I get the desired behavior.

    Band-aid:
    I added a nocache meta tag and a 4 second delay refresh tag to my code and that seemed to work about 50% of the time. This seems like a clunky workaround for this problem and it's definetly not fool proof.

    Does anyone have a good solution for this? None of the canned pages have this problem in HS so I'm sure the problem lyes in how I'm implementing this.

    Here's my code:
    roomControls.asp
    <pre class="ip-ubbcode-code-pre">&lt;%@ Language=VBScript %&gt;
    &lt;html&gt;
    &lt;head&gt;
    &lt;title&gt;Event Controls&lt;/title&gt;
    &lt;META HTTP-EQUIV="Pragma" CONTENT="no-cache"&gt;
    &lt;/head&gt;

    &lt;body&gt;
    &lt;TABLE width="225"&gt;
    &lt;TR&gt;
    &lt;TD colspan="2" align="center"&gt;Room Controls&lt;/TD&gt;
    &lt;/TR&gt;
    &lt;TR&gt;
    &lt;TD&gt;&lt;%
    If hs.isOn("C1") then
    response.write "&lt;a href='eventRoomControls.asp?event=Bedroom Off'&gt;&lt;img src='images/bedroomOn.jpg' width='160' height='58' border='0'&gt;&lt;/A&gt;"
    else
    response.write "&lt;a href='eventRoomControls.asp?event=Bedroom On'&gt;&lt;img src='images/bedroomOff.jpg' width='160' height='58' border='0'&gt;&lt;/A&gt;"
    end if %&gt;&lt;/TD&gt;
    &lt;/TR&gt;
    &lt;TR&gt;
    &lt;TD&gt;&lt;BR&gt;&lt;BR&gt;&lt;a href="index.asp"&gt;main&lt;/A&gt;&lt;/TD&gt;
    &lt;/TR&gt;
    &lt;/TABLE&gt;
    &lt;/body&gt;
    &lt;HEAD&gt;
    &lt;META HTTP-EQUIV="Pragma" CONTENT="no-cache"&gt;
    &lt;/HEAD&gt;
    &lt;/html&gt;</pre>

    eventRoomControls.asp
    <pre class="ip-ubbcode-code-pre">&lt;%@ Language=VBScript %&gt;
    &lt;html&gt;
    &lt;%
    Dim SelEvent

    '====Get the event name
    SelEvent = request.form("Event")

    '==== trigger the event
    HS.TriggerEvent(SelEvent)

    '=== Send us back From wence we came.
    'response.redirect "roomControls.asp"
    %&gt;
    making the change
    &lt;head&gt;
    &lt;META HTTP-EQUIV="Refresh" CONTENT="4;URL=roomControls.asp"&gt;
    &lt;/head&gt;
    &lt;/html&gt;</pre>

    BTW - Some of this code is hacked from examples I have found on the boards.

    #2
    Hi emooney,

    It does sound like a caching issue. I think the 'response.redirect' and
    &lt;META HTTP-EQUIV="Refresh" CONTENT="4;URL=roomControls.asp"&gt; methods may ignore the no-cache setting.

    A few things to try:

    1. Have eventRoomControls.asp check the status of the device and send a parameter to roomControls.asp (something like roomControls.asp?lamp1=on. roomControls.asp would then display a different image depending on what was passed to it.

    2. Use Dynamic HTML (DHTML). This is what I do and it works really well. Basically, you need hidden frames on your page and the code in these frames tells an image to change on the main page, once you click on something. Take a look at this thread on how I do it. It uses popup images, but you can also implement it using images that are embedded on the page. You can also see it in action on my HomeSeer site (except the image won't change for you, since as a guest, you won't be able to change the device status).

    Cheers
    Al

    http://www.sparkman.dns2go.com/
    HS 4.2.8.0: 2134 Devices 1252 Events
    Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

    Comment


      #3
      Try hs.WaitEvents after the hs.TriggerEvent to delay the script until HomeSeer has processed the event.

      You can also eliminate the need for the redirect if you put the code all in the same asp. Try this:

      roomControls.asp
      <pre class="ip-ubbcode-code-pre">
      &lt;%@ Language=VBScript %&gt;
      &lt;%
      Dim SelEvent

      '====Get the event name
      SelEvent = request.form("Event")

      '==== trigger the event
      If SelEvent &lt;&gt; "" Then
      HS.TriggerEvent(SelEvent)
      hs.WaitEvents
      End If
      %&gt;
      &lt;html&gt;
      &lt;head&gt;
      &lt;title&gt;Event Controls&lt;/title&gt;
      &lt;META HTTP-EQUIV="Pragma" CONTENT="no-cache"&gt;
      &lt;/head&gt;

      &lt;body&gt;
      &lt;TABLE width="225"&gt;
      &lt;TR&gt;
      &lt;TD colspan="2" align="center"&gt;Room Controls&lt;/TD&gt;
      &lt;/TR&gt;
      &lt;TR&gt;
      &lt;TD&gt;&lt;%
      If hs.isOn("C1") then
      response.write "&lt;a href='roomControls.asp?event=Bedroom Off'&gt;&lt;img src='images/bedroomOn.jpg' width='160' height='58' border='0'&gt;&lt;/A&gt;"
      else
      response.write "&lt;a href='roomControls.asp?event=Bedroom On'&gt;&lt;img src='images/bedroomOff.jpg' width='160' height='58' border='0'&gt;&lt;/A&gt;"
      end if %&gt;&lt;/TD&gt;
      &lt;/TR&gt;
      &lt;TR&gt;
      &lt;TD&gt;&lt;BR&gt;&lt;BR&gt;&lt;a href="index.asp"&gt;main&lt;/A&gt;&lt;/TD&gt;
      &lt;/TR&gt;
      &lt;/TABLE&gt;
      &lt;/body&gt;
      &lt;/html&gt;
      </pre>


      Paul

      Comment


        #4
        Thanks for the ideas. I tried both of these ideas (All but the idea using DHTML because this is going to be run on a pocketPC and I didn't know how that page would react) and used a combination of these ideas and it now does what I want, 100% of the time.

        Here's the code and thanks again for the ideas.
        <pre class="ip-ubbcode-code-pre"> &lt;%@ Language=VBScript %&gt;
        &lt;%
        Dim selEvent

        Dim bedroom
        Dim bedroomURL

        '====Get the event name
        selEvent = request.form("event")

        '=====if bedroom is in the url
        If selEvent &lt;&gt; "" then
        If selEvent = "Bedroom On" then
        bedroomURL = "&lt;a href='test.asp?event=Bedroom Off'&gt;&lt;img src='images/bedroomOn.jpg' width='160' height='58' border='0'&gt;&lt;/A&gt;"
        elseIf selEvent = "Bedroom Off" then
        bedroomURL = "&lt;a href='test.asp?event=Bedroom On'&gt;&lt;img src='images/bedroomOff.jpg' width='160' height='58' border='0'&gt;&lt;/A&gt;"
        End If
        '=====if not, get the status from homeseer
        else
        If hs.isOn("C1") then
        bedroomURL = "&lt;a href='test.asp?event=Bedroom Off'&gt;&lt;img src='images/bedroomOn.jpg' width='160' height='58' border='0'&gt;&lt;/A&gt;"
        else
        bedroomURL = "&lt;a href='test.asp?event=Bedroom On'&gt;&lt;img src='images/bedroomOff.jpg' width='160' height='58' border='0'&gt;&lt;/A&gt;"
        End If
        End If

        '==== trigger the event
        If SelEvent &lt;&gt; "" Then
        HS.TriggerEvent(SelEvent)
        End If
        %&gt;
        &lt;html&gt;
        &lt;head&gt;
        &lt;title&gt;Event Controls&lt;/title&gt;
        &lt;META HTTP-EQUIV="Pragma" CONTENT="no-cache"&gt;
        &lt;/head&gt;

        &lt;body&gt;
        &lt;TABLE width="225"&gt;
        &lt;TR&gt;
        &lt;TD colspan="2" align="center"&gt;Room Controls&lt;/TD&gt;
        &lt;/TR&gt;
        &lt;TR&gt;
        &lt;TD&gt;&lt;%= bedroomURL %&gt;&lt;/TD&gt;
        &lt;/TR&gt;
        &lt;TR&gt;
        &lt;TD&gt;&lt;BR&gt;&lt;BR&gt;&lt;a href="index.asp"&gt;main&lt;/A&gt;&lt;/TD&gt;
        &lt;/TR&gt;
        &lt;/TABLE&gt;
        &lt;/body&gt;
        &lt;/html&gt;
        </pre>

        Comment


          #5
          The code above works only if you have one room to edit on the page. The code attached (to save pixels) works well if you want to have multiple rooms on the page. IE bedroom, living room, etc.
          I like this interface because you can cram alot of functionality into a small space.

          Eric
          Attached Files

          Comment

          Working...
          X