Please login or register.

Login with username, password and session length
Pages: 1 [2]

Author Topic: IP Camera Orientation  (Read 6304 times)

soxfan1966

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 388
Re: IP Camera Orientation
« Reply #15 on: April 26, 2019, 09:21:36 AM »

Tried another pass at this over the last few days.

Rather than a button, I was still trying to use a new field in the Program definition.

So in the Program "Generic OP Camera" I added this on the StartUp Code tab:
.AddFeature("Media.IpCamera", "Sensor", "IpCamera.Orientation", "Orientation (Blank for Landscape, 1 for Portrait)", "text")

(added under the entry for the Url)

That results in a new field on the device appearing and I have entered a value of 1 in the camera I want to rotate the image on, leaving the other two cameras with a nil in that field.

Then in the Widget "homegenie/generic/camerainput" I added this on the JavaScript tab just above the code that is setting the Url:
   // Set the Orientation
  var Orient = $$.module.prop('IpCamera.Orientation');
  if (Orient > 0) {
  $$.field('camerapicturepreview').css({'transform': 'rotate(90deg)'});}
  else {$$.field('camerapicturepreview').css({'transform': 'rotate(0deg)'});}

It does not seem to be getting / setting the value of the variable Orient as it does not conditionally apply the rotation - if I switch the  else to use 90deg in place of 0deg then it applies the rotation to all of the cameras.

So I think there is something amiss with my logic - but I am not familiar enough with JavaScript nor how the connection between the program for the widget and the widget itself is handled to be able to get it to work at this point.
Logged

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 283
  • Posts: 10509
  • I don't work for X10, I use it successfuly!
Re: IP Camera Orientation
« Reply #16 on: April 26, 2019, 01:07:46 PM »

I never had much luck using features in the IP camera program either however since your specifying text as the input you should be watching for text not a decimal value in the widget.
If I get some time I'll play a bit more with this.
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 283
  • Posts: 10509
  • I don't work for X10, I use it successfuly!
Re: IP Camera Orientation
« Reply #17 on: April 26, 2019, 03:00:49 PM »

Ok I now have this working roughly. :)% I think why I couldn't get it working correctly before is HG service required a restart for this.
here's what I have thus far:
Program "Generic OP Camera" add  this under the StartUp Code tab:
Code: [Select]
.AddFeature("Media.IpCamera", "Sensor", "IpCamera.Orientation", "Type True for  Portrait)", "text")in the widget Java script tab add just above the  line $$.field('sizetoggle').on('click', function(){
Code: [Select]
var orientate = $$.module.prop('IpCamera.Orientation').Value;
 if (orientate !='True')$$.field('camerapicturepreview').css({'transform': 'rotate(0deg)'});
  else  {$$.field('camerapicturepreview').css({'transform': 'rotate(90deg)'});
   $$._widget.css('width', '172');
     $$._widget.css('height', '286');
      $$.field('camerapicturepreview').css('height', '300');
      $$.field('camerapicturepreview').css({'transform': 'rotate(90deg)'});
      $$._widget.data('enlarged', true);
        }
this will set the orientation and size the widget However you still need to edit the sizetoggle on click code as well as refresh code to get things working smoohly.
Currently if you change the Orientation setting for the camera you need to refresh your browser You Also need to restart the HG service for the widget code to get loaded.
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

soxfan1966

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 388
Re: IP Camera Orientation
« Reply #18 on: April 26, 2019, 06:51:47 PM »

OK, I think I got it working

I changed my prior new field in the program from a text field to a slider like this:

.AddFeature("Media.IpCamera", "Sensor", "IpCamera.Orientation", "Orientation (0 for Landscape, 1 for Portrait)", "slider:0:1:0")

And in the JacaScript code for the Generic IP Camera Widget, just above the // set the camera image url line I updated my code like this:

  // Set the Orientation
  var Orient = $$.module.prop('IpCamera.Orientation').Value;
  if ($$.module.prop('IpCamera.Orientation').Value > 0) $$.field('camerapicturepreview').css({'transform': 'rotate(90deg)'});
  else $$.field('camerapicturepreview').css({'transform': 'rotate(0deg)'}); 

I believe the problem with the code I posted earlier today was that I was missing the .Value at the end of the var = Orient line (which I noticed based on your last post)

So when viewing HG on my desktop pc with Chrome, the camera I have defiend with a 1 in the Orientation field displays vertical and the others still appear landscape.

I restarted the HG service and reloaded HG in my browser to make sure it still is working as I expected (I also exported copies of the Generic IP Camera program and Widget for backup purposes).

Only think now is in the Android App (full version) they are not appearing as they do in the browser but still all landscape - not sure if I need to update the program and widget in the app somehow ?
Logged

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 283
  • Posts: 10509
  • I don't work for X10, I use it successfuly!
Re: IP Camera Orientation
« Reply #19 on: April 26, 2019, 07:02:18 PM »

Yep the slider route will work as will the checkbox option you just have to watch for correct values and refresh.

The android app is a total other ball game. It doesn't like customized widgets however a reload of the app devices will sometimes allow things. The old app is less forgiving and usually accepts custom widgets as it uses a web style viewer
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

soxfan1966

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 388
Re: IP Camera Orientation
« Reply #20 on: April 26, 2019, 07:15:53 PM »

I will play around with updating the widget on the app tomorrow.  My Weather Alerter is missing too so I think I need to toggle that after I took a HG update earlier this afternoon.
Logged

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 283
  • Posts: 10509
  • I don't work for X10, I use it successfuly!
Re: IP Camera Orientation
« Reply #21 on: April 27, 2019, 06:01:53 PM »

I uploaded my Pro IP Camera program which has the portrait option, pre-sets, and snapshot options to the scripts section.
This way you can focus maybe on some other options. ;)
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

soxfan1966

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 388
Re: IP Camera Orientation
« Reply #22 on: April 28, 2019, 08:11:44 AM »

Thanks.  Been working in the house this weekend (wallpaper removal yesterday and painting today) so will give it a whirl later this week.

How do I update the widget to use your program in place of the standard one?
Logged

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 283
  • Posts: 10509
  • I don't work for X10, I use it successfuly!
Re: IP Camera Orientation
« Reply #23 on: April 28, 2019, 08:32:05 AM »

The widget is installed same as that for Weather Alerter and Status Info widgets.
It doesn't update the current Generic Camera widget nor does it update the current Generic Camera program code.
Both those get over written on every update so all your code would be lost. Since these (Pro camera widget & program) won't get overwritten any modifications you do to them will remain with updates.  >!
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

soxfan1966

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 388
Re: IP Camera Orientation
« Reply #24 on: May 01, 2019, 07:34:25 PM »

I just installed the new program and widget - and then set up my IP cameras to use the new widget.  Works Great.  Thanks
Logged
Pages: 1 [2]
 

X10.com | About X10 | X10 Security Systems | Cameras| Package Deals
© Copyright 2014-2016 X10.com All rights reserved.