Jump to content


Photo

Vera Home Automation- Feature Request

Completed

  • Please log in to reply
31 replies to this topic

#1 PrincessClevage OFFLINE  

PrincessClevage

    Advanced Member

  • Members
  • 1046 posts
  • Local time: 11:34 PM

Posted 27 September 2019 - 08:59 AM

Hi Chef,
As the title states, might it be possible to add to your plugin the ability to execute a emby server local script (for my Windows emby server a simple .bat file might work). I believe that you are already monitoring for start stop etc function in emby and the use case I would like to fill would be:
When a user starts a movie execute local file (.bat) script which would then execute python code to auto turn on my Dreamscreen only when a movie is played. The opposite would occur when a user stops a movie it would auto turn of my Dream screen.
Thanks for your consideration Chef

#2 Sammy OFFLINE  

Sammy

    Advanced Member

  • Members
  • 2827 posts
  • Local time: 05:34 AM

Posted 27 September 2019 - 09:37 AM

Just a thought, is it possible to do this with the Emby Plugin and Reactor in Vera?

Sent from my SM-G960U1 using Tapatalk

Edited by Sammy, 27 September 2019 - 09:37 AM.


#3 chef OFFLINE  

chef

    Advanced Member

  • Developers
  • 3993 posts
  • Local time: 08:34 AM
  • LocationPeterborough, Canada

Posted 27 September 2019 - 01:58 PM

Just a thought, is it possible to do this with the Emby Plugin and Reactor in Vera?

Sent from my SM-G960U1 using Tapatalk


Would the python script run on the Vera machine then?

Once I read the python script, I think we could just convert it to c#, then make a dreamscreen plugin. There only issue I can see, is that sometime python allows for low level functionality on computer systems, which is why so many hackers use the framework.

It might be hard to convert some of the language.

We'd have to see the python to assess the level of my skill to do it. LOL.

If that fails, then I had better look back at the script plugin and get it working. Either way emby will control dreamscreen 😁

#4 PrincessClevage OFFLINE  

PrincessClevage

    Advanced Member

  • Members
  • 1046 posts
  • Local time: 11:34 PM

Posted 27 September 2019 - 02:04 PM

I would of thought it would be easier to add to your emby plugin, select local file to execute Addition, do you need me to upload another copy of the python scrip to this thread or you already have it from the other forum chef?
P.s I asked the Vera forums if Vera plus has or could have python but got told it does not have python and would probably be to large to deploy

Edited by PrincessClevage, 27 September 2019 - 02:07 PM.


#5 Sammy OFFLINE  

Sammy

    Advanced Member

  • Members
  • 2827 posts
  • Local time: 05:34 AM

Posted 27 September 2019 - 02:07 PM

It seems that the Scripto Plugin never really got finished?


  • chef likes this

#6 chef OFFLINE  

chef

    Advanced Member

  • Developers
  • 3993 posts
  • Local time: 08:34 AM
  • LocationPeterborough, Canada

Posted 27 September 2019 - 02:08 PM

Unfortunately, the plugin ties itself into the Vera scenes, and I didn't use any Dependancy Injection for the Vera API... because 😳.

However, removing the Vera code and using Windows process to run the script will work.

Or, yeah maybe I could see that script again. I can't remember where it was before.

#7 PrincessClevage OFFLINE  

PrincessClevage

    Advanced Member

  • Members
  • 1046 posts
  • Local time: 11:34 PM

Posted 27 September 2019 - 02:20 PM

Files attached
For some reason it won’t show the attachment, even tho it says it’s attached in my post creation.

Attached Files


Edited by PrincessClevage, 27 September 2019 - 02:36 PM.


#8 chef OFFLINE  

chef

    Advanced Member

  • Developers
  • 3993 posts
  • Local time: 08:34 AM
  • LocationPeterborough, Canada

Posted 27 September 2019 - 02:24 PM

Files attached

 

Ops! don't forget to attach to post :)



#9 chef OFFLINE  

chef

    Advanced Member

  • Developers
  • 3993 posts
  • Local time: 08:34 AM
  • LocationPeterborough, Canada

Posted 27 September 2019 - 02:31 PM

Hey I found the python and did a quick convert here at work... because all the food was cooked and I'm the chef and I'll do what I want! Here is the script in c#! LOL!

 

It needs work, and I did it with out an IDE... so errors.

 

I also have to post it here because this computer resets itself to deafult every night!


using socket;

using sys;

using optparse;

using time;

using System.Collections.Generic;

using System;

public static class dream {
    
    public static object IP = "<enter IP here>";
    
    public static object group = 0;
    
    public static object sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM);
    
    public static object PORT = 8888;
    
    public static object endpoint = Tuple.Create(IP, PORT);
    
    public static object crcTable = new List<object> {
        0,        7,        4,        9,        28,        27,        18,        21,        56,        63,        54,        49,        36,        35,        42,
        45,        112,        119,        126,        121,        108,        107,        98,        101,        72,        79,        70,        65,        84,
        83,        90,        93,        224,        231,        238,        233,        252,        251,        242,        245,        216,        223,        214,
        209,        196,        195,        202,        205,        144,        151,        158,        153,        140,        139,        130,        133,        168,
        175,        166,        161,        180,        179,        186,        189,        199,        192,        201,        206,        219,        220,        213,
        210,        255,        248,        241,        246,        227,        228,        237,        234,        183,        176,        185,        190,        171,
        172,        165,        162,        143,        136,        129,        134,        147,        148,        157,        154,        39,        32,        41,
        46,        59,        60,        53,        50,        31,        24,        17,        22,        3,        4,        13,        10,        87,        80,
        89,        94,        75,        76,        69,        66,        111,        104,        97,        102,        115,        116,        125,        122,
        137,        142,        135,        0,        149,        146,        155,        156,        177,        182,        191,        184,        173,        170,
        163,        164,        249,        254,        247,        240,        229,        226,        235,        236,        193,        198,        207,        200,
        221,        218,        211,        212,        105,        110,        103,        96,        117,        114,        123,        124,        81,        86,
        95,        88,
        77,
        74,
        67,
        68,
        25,
        30,
        23,
        16,
        5,
        2,
        11,
        12,
        33,
        38,
        47,
        40,
        61,
        58,
        51,
        52,
        78,
        73,
        64,
        71,
        82,
        85,
        92,
        91,
        118,
        113,
        120,
        255,
        106,
        109,
        100,
        99,
        62,
        57,
        48,
        55,
        34,
        37,
        44,
        43,
        6,
        1,
        8,
        15,
        26,
        29,
        20,
        19,
        174,
        169,
        160,
        167,
        178,
        181,
        188,
        187,
        150,
        145,
        152,
        159,
        138,
        141,
        132,
        131,
        222,
        217,
        208,
        215,
        194,
        197,
        204,
        203,
        230,
        225,
        232,
        239,
        250,
        253,
        244,
        243
    };
    
        //def initialSetup(ip, group):
    //   guy doesn't want a initial setup... I'll make one    
public static object setIP(object ip) {
        //why he check IP?????        //check IP
        var IP = ip;
        var endpoint = Tuple.Create(ip, PORT);
    }
    
    public static object color(object color) {
                setAmbience(0);
        // decide whether to look up or split 
        //split
        var payload = color.split(",");
        foreach (var i in range(payload.Count)) {
            payload[i] = Convert.ToInt32(payload[i]);
        }
        buildAndSendPacket(3, 13, payload);
    }
    
       // Things get real from here - OH OKAY, LETS MAKE IT REAL THEN!
    public static object setAmbience(object ambience) {
        var payload = new List<object> {
            ambience
        };
        buildAndSendPacket(3, 8, payload);
    }
    
    public static object setScene(object scene) {
        //this one is finicky at times.  Need feedback
        //#0x00 - Random Color
        //#0x01 - Fireside
        //#0x02 - Twinkle
        //#0x03 - Ocean
        //#0x04 - Rainbow
        //#0x05 - July 4th
        //#0x06 - Holiday
        //#0x07 - Pop
        //#0x08 - Enchanted Forest
        //setMode(3) #set mode to Ambient ###  sometmes it works without this.  Will need feedback from others...
        setAmbience(1);
        time.sleep(2);
        var payload = new List<object> {
            scene
        };
        buildAndSendPacket(3, 13, payload);
    }
    
    public static object setMode(object mode) {
        //#0 - Sleep
        //#1 - Video
        //#2 - Music
        //#3 - Ambient
        var payload = new List<object> {
            mode
        };
        buildAndSendPacket(3, 1, payload);
    }
    
    public static object setSource(object source) {
        // 0- input 1
        // 1- input 2
        // 2- input 3
        var payload = new List<object> {
            source
        };
        buildAndSendPacket(3, 32, payload);
    }
    
    public static object setBrightness(object brightness) {
        var payload = new List<object> {
            brightness
        };
        buildAndSendPacket(3, 2, payload);
    }
    
    public static object buildAndSendPacket(object upperC, object lowerC, object payload) {
        var resp = new List<object>();
        resp.add(252);
        resp.add(payload.Count + 5);
        resp.add(group);
        resp.add(17);
        resp.add(upperC);
        resp.add(lowerC);
        foreach (var i in range(0, payload.Count)) {
            //for loop to handle colors.              resp.append(payload[i]);
        }
        var crc = calcCRC8(resp);
        resp.add(crc);
        resp = bytearray(resp);
        sock.sendto(resp, endpoint); <- THIS HAS TO BE SOMETHING ELSE... sock is not a thing.
    }
    
    public static object calcCRC8(object resp) {
        var size = resp[1] + 1;
        var crc = 0;
        foreach (var i in range(0, size)) {
            crc = crcTable[(resp[i] ^ crc) & 255];
            //print crc <- PRINT DOESN"T EXSIST SO WE"LL LOG TO EMBY FOR VERIFICATION
        }
        return crc;
    }
    
    public static object scenes = "Which scenes (use the number)?\"\n0 - Random Color\"\"\n1 - Fireside\"\"\n2 - Twinkle\"\"\n3 - Ocean\"\"\n4 - Rainbow\"\"\n5 - July 4th\"\"\n6 - Holiday\"\"\n7 - Pop\"\"\n8 - Enchanted Forest\"";
    
    public static object modes = "Which mode? (use the number)\"\n0 - Sleep\"\"\n1 - Video\"\"\n2 - Music\"\"\n3 - Ambient\"";
    
    public static object sources = "Which mode? (use the number)\"\n0 - input 1\"\"\n1 - input 2\"\"\n2 - input 3\"";
    
    public static object parser = optparse.OptionParser();
    
    static dream() {
        parser.add_option("-m", "--mode", dest: "mode", help: modes);
        parser.add_option("-s", "--source", dest: "source", help: sources);
        parser.add_option("-a", "--ambient scene", dest: "scene", help: scenes);
        parser.add_option("-b", "--brightness", dest: "brightness", help: "Enter from 0-100 to control brightness");
        parser.add_option("-i", "--ip", dest: "ip", help: "Please enter your Dreamscreen's IP address");
        Convert.ToInt32(payload[i]);
        setIP(ip);
        options.mode = Convert.ToInt32(options.mode);
        options.mode = 3;
        options.mode = 0;
        setMode(options.mode);
        sys.exit(0);
        options.source = Convert.ToInt32(options.source);
        options.source = 2;
        options.source = 0;
        setSource(options.source);
        sys.exit(0);
        options.scene = Convert.ToInt32(options.scene);
        options.scene = 8;
        options.scene = 0;
        setScene(options.scene);
        sys.exit(0);
        options.brightness = Convert.ToInt32(options.brightness);
        options.brightness = 100;
        options.brightness = 0;
        setBrightness(options.brightness);
        sys.exit(0);
        sys.exit(0);
    }
    
    public static object payload = ip.split(".");
}

Now we have to debug it and put it in a Emby plugin wrapper!


Edited by chef, 27 September 2019 - 02:40 PM.


#10 PrincessClevage OFFLINE  

PrincessClevage

    Advanced Member

  • Members
  • 1046 posts
  • Local time: 11:34 PM

Posted 27 September 2019 - 02:40 PM

I finally got the files attached. The script requires variables to be input when calling e.g -m -0 will turn off DS -m -1 will turn on DS to video mode
The readme in the attached files explains most usage

Edited by PrincessClevage, 27 September 2019 - 02:43 PM.


#11 chef OFFLINE  

chef

    Advanced Member

  • Developers
  • 3993 posts
  • Local time: 08:34 AM
  • LocationPeterborough, Canada

Posted 27 September 2019 - 02:48 PM

I finally got the files attached. The script requires variables to be input when calling e.g -m -0 will turn off DS -m -2 will turn on DS to video mode

 

Yep! looks like there is some other scenes like fireside etc.

 

But lets get it turning on and off with emby!

 

/just have to figure out the request part of the c# code above. But, I'll need an IDE with .netcore to figure it out.

 

looks promising.

 

Question: should it turn on when Emby starts up on your TV, or does it just turn on when media playback starts?

 

Cause maybe there could be a setting to have it start with Emby and play a scene before it triggers the dreamscreen effect during playback.

 

 

Hey @BillOatman - above I posted some c# code (written without IDE at work quickly... yikes!) which pretty much is a line by line conversion of the python script Princess is using to control her dreamscreen.

 

I'm thinking plugin?? and guess what?!? You invited dude! LOL!

 

if you have time, maybe we could collaborate a bit, here,  if I can try and outline some of it. I have a feeling it might be a tiny bit difficult  ;)



#12 PrincessClevage OFFLINE  

PrincessClevage

    Advanced Member

  • Members
  • 1046 posts
  • Local time: 11:34 PM

Posted 27 September 2019 - 02:54 PM

Yep! looks like there is some other scenes like fireside etc.

But lets get it turning on and off with emby!

/just have to figure out the request part of the c# code above. But, I'll need an IDE with .netcore to figure it out.

looks promising.

Question: should it turn on when Emby starts up on your TV, or does it just turn on when media playback starts?

Cause maybe there could be a setting to have it start with Emby and play a scene before it triggers the dreamscreen effect during playback.


Hey @BillOatman - above I posted some c# code (written without IDE at work quickly... yikes!) which pretty much is a line by line conversion of the python script Princess is using to control her dreamscreen.

I'm thinking plugin?? and guess what?!? You invited dude! LOL!

if you have time, maybe we could collaborate a bit, here, if I can try and outline some of it. I have a feeling it might be a tiny bit difficult ;)

Ideally it would only turn on/off when user starts/stop a movie, and as you already link into classes and watch for user actions in your Vera plugin I though it might be the logical integration but heey your the Chef!
  • chef likes this

#13 BillOatman OFFLINE  

BillOatman

    Advanced Member

  • Members
  • 490 posts
  • Local time: 08:34 AM

Posted 30 September 2019 - 09:32 AM

Hey @chef.  If you want to get the communications figured out I'll wrap it in a plugin like my philips hue.



#14 chef OFFLINE  

chef

    Advanced Member

  • Developers
  • 3993 posts
  • Local time: 08:34 AM
  • LocationPeterborough, Canada

Posted 30 September 2019 - 07:22 PM

I'm thinking that the new web hooks plugin is what is needed here.

#15 BillOatman OFFLINE  

BillOatman

    Advanced Member

  • Members
  • 490 posts
  • Local time: 08:34 AM

Posted 30 September 2019 - 07:51 PM

Good idea.



#16 PrincessClevage OFFLINE  

PrincessClevage

    Advanced Member

  • Members
  • 1046 posts
  • Local time: 11:34 PM

Posted 04 October 2019 - 03:19 AM

Hello gents,
Anything I can do to help with testing?

#17 chef OFFLINE  

chef

    Advanced Member

  • Developers
  • 3993 posts
  • Local time: 08:34 AM
  • LocationPeterborough, Canada

Posted 04 October 2019 - 09:57 AM

Hello gents,
Anything I can do to help with testing?

I've got something that runs processes now on emby events.

Needs a UI, and I think the next step is to send it to Bill. He's got client side on 'lock down'.

I'll send it asap.

Edited by chef, 04 October 2019 - 09:58 AM.


#18 BillOatman OFFLINE  

BillOatman

    Advanced Member

  • Members
  • 490 posts
  • Local time: 08:34 AM

Posted 04 October 2019 - 11:11 AM

I can't find any info on webhooks in Emby.  I found a reference to a plugin, but don't see anything in the catalog.

@Luke how do Emby webhooks work?  Is it in the released Windows server or only in beta at this point?



#19 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 139743 posts
  • Local time: 08:34 AM

Posted 04 October 2019 - 11:36 AM

Beta.

#20 BillOatman OFFLINE  

BillOatman

    Advanced Member

  • Members
  • 490 posts
  • Local time: 08:34 AM

Posted 04 October 2019 - 11:55 AM

@chef I don't run betas so I'm out until it's released.







Also tagged with one or more of these keywords: Completed

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users