Jump to content
PrincessClevage

Vera Home Automation- Feature Request

Recommended Posts

PrincessClevage

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

Share this post


Link to post
Share on other sites
Sammy

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

Share this post


Link to post
Share on other sites
chef

Share this post


Link to post
Share on other sites
PrincessClevage

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

Share this post


Link to post
Share on other sites
Sammy

It seems that the Scripto Plugin never really got finished?

  • Like 1

Share this post


Link to post
Share on other sites
chef

Share this post


Link to post
Share on other sites
PrincessClevage

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

DreamScreenCommander-master.zip

Edited by PrincessClevage

Share this post


Link to post
Share on other sites
chef

Files attached

 

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

Share this post


Link to post
Share on other sites
chef

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

Share this post


Link to post
Share on other sites
PrincessClevage

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

Share this post


Link to post
Share on other sites
chef

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  ;)

Share this post


Link to post
Share on other sites
PrincessClevage

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!
  • Like 1

Share this post


Link to post
Share on other sites
BillOatman

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

Share this post


Link to post
Share on other sites
chef

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

Share this post


Link to post
Share on other sites
PrincessClevage

Hello gents,

Anything I can do to help with testing?

Share this post


Link to post
Share on other sites
chef

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

Share this post


Link to post
Share on other sites
BillOatman

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?

Share this post


Link to post
Share on other sites
Luke

Beta.

Share this post


Link to post
Share on other sites
BillOatman

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

Share this post


Link to post
Share on other sites
chef

That's okay bill, I wrote the back end code for a plugin that will run processes.

 

If your busy,, no worries the UI only needs an input and a button.

 

I got it. I'll send it to princess and she can test it this weekend :)

Edited by chef
  • Like 1

Share this post


Link to post
Share on other sites
PrincessClevage

That's okay bill, I wrote the back end code for a plugin that will run processes.

 

If your busy,, no worries the UI only needs an input and a button.

 

I got it. I'll send it to princess and she can test it this weekend :)

Thanks Chef, standing by

Share this post


Link to post
Share on other sites
wbravin

Hello all

 

I have a freenas sever that runs emby server that feeds KODI media player, thanks to the folks on this forum all works very well. 

 

My next project would be to command  Alexa to alsk emby to play videos or music via vera, so i can ask alexa to play something via kodi, maybe through the emby plugin for kodi

 

I know that this is not the purpose of the vera plugin at the moment and you are only focusing on lights.

 

My question to you all would be:

 

do you expect to develop this integration and functionality in the near future? or am i dreaming poies in the sky? 

 

Thank you

Share this post


Link to post
Share on other sites
PrincessClevage

There is already a native Emby plugin for Alexa to control emby by voice commands through Alexa

Share this post


Link to post
Share on other sites
wbravin

Hello thank for the quick reply

 

Yes i do control my vera scenes via alexa at the moment.

 

How ever would this extend to running scenes to play videos and music? 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...