Help get this topic noticed by sharing it on Twitter, Facebook, or email.

Variable use within command strings

Is there a way to use a variable within a command? This would be incredibly useful for things like DirecTV Genies which require passing a mac address in each command. The commands are exactly identical with the exception of that one change.

For example the guide command for two Genies in a setup I am working on (mac addresses fictional):
remote/processKey?key=guide&clientAddr=08D3F422D1F3
remote/processKey?key=guide&clientAddr=08D3F2A2D1F2

If I could simply do something along these lines:
remote/processKey?key=guide&clientAddr=$GenieMacAddress$

It would save me from having to re-write all the commands for each device with the mac addresses for every Genie, that gets to be pretty annoying after a really short while.

It would work nicely for feedbacks as well.
3 people have
this question
+1
Reply
  • Josh,

    You would have to assign each command a variable and then set that variable within each command you are sending.

    We have a tutorial created on our support site which includes an xml file of the commands. You can find and replace using a text editor to add your mac address. Then upload the file into the database.

    https://irule.desk.com/customer/porta...
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned

  • Thanks for the speedy response. I can think of a few more scenarios where this would add a lot of efficiency (for example tuning to a channel, instead of having a billion of these in my DirecTV devices:
    tv/tune?major=501

    I could just have:
    tv/tune?major=$tunechannel$

    Then set the variable on each button press then tune to it. Would work for channel queries as well. I've gotten into trying to have efficiency in the number of commands I have on each device lately so it's easier to find stuff when I'm building, Directv STBs are my biggest offenders of having tons of commands right now.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned

  • One more question, any thoughts on giving users the ability to export a device? I always end up creating custom commands (favorite channels, etc.) and the ability to export the device for doing these global search and replaces would really make life a lot easier given the lack of ability to use a variable within a command string at the moment.

    Thanks!
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned

  • The above idea could work but you would need to use an input variable to send the command.

    You would assign your variable to the data field of the command and use the input variable on the button you are using to select your favorite channel. The input variable would then require you, within the app, to type in the channel that you want to watch.

    To answer the second question you could email support to ask for a device xml be exported. We cannot share our IR database with end users since many commands are not available for public use, think discrete power for certain device. If you have a device that you have created, you can email support@iruleathome.com and let us know the device you would like access to.
    • Does anyone else see the total absurdity of making a piece of AV equipment, and keeping some of the control codes secret so they cannot be used by the general public? Er, aren't they the actual customers who bought that device?

      It's this sort of secretive mentality that makes life so difficult for all of us. Why, after all these years do manufacturers still not ensure EVERY device has discrete codes for everything that needs them and make them available for all to use. It's criminal that they don't. Well it isn't, but it should be.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited sad, anxious, confused, frustrated

  • Cool thanks.

    Not sure I quite understand the need to do an input variable that required typing in the app, couldn't I simply make the macro for the buttons be something to the effect of:

    Tune to HBO
    set $tunechannel$ = 501
    delay .1
    tv/tune?major=$tunechannel$

    Tune to FOX
    set $tunechannel$ = 007
    delay .1
    tv/tune?major=$tunechannel$
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned

  • You could do that as well. You can use variable expression to have the initial part of the command in place and use the + to add in your variable value.

    The example would be: tv/tune?major + $variablevalue$
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited sad, anxious, confused, frustrated

  • Oh man this is precisely what I want to do! Awesome, I will be testing this out tonight.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited

  • I'm testing this out and not having any success... Approach is as follows:

    First I have a button press to set the value of $GenieMacAddress$ to be: 08EB74C47ADD

    Then I have another button that does this command:
    remote/processKey?key=guide&clientAddr= + $GenieMacAddress$

    No love, for testing purposes I also have a button that is set to just be:
    remote/processKey?key=guide&clientAddr=08EB74C47ADD

    the second option works fine....

    And I just figured out the problem, this seems to only work when setting a variable value, I was really hoping I could set the command using this as I mentioned in my earlier post.

    This still can potentially work, basically it puts me in the mode of a completely different approach to things than I was thinking but may make my life easier still in some ways. Basically it puts me in the mode of two variables all the time.

    $GenieMacAddress$ and $CommandtoSend$

    The button that goes to the room I want to control sets the $GenieMacAddress$ value to the Genie for that room...

    Then the button presses become structured to first set the variable $CommandtoSend$ using an expression of:
    remote/processKey?key=guide&clientAddr=$GenieMacAddress$
    (the plus was totally unnecessary and in fact broke things, not sure if that's a bug or not)

    Then it works fine... This is a lot of logic that I was hoping would be unnecessary, and in fact could be if you could evaluate a device command as an expression. So I guess I have a feature request for that.

    Am I missing something? I have the panel shared as: "DirecTV Genie Variable Testing - JIVES"

    The device is also shared as: "DirecTV Genie control with Variables test - JIVES"

    Not sure if that helps are not.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned

  • I don't have a Genie, but here is how I do it with my RS232 commands.
    Add a device code to your device and call it whatever you want, GenieCommand.
    Now in the data section of that code click the variable and assign it a name $GenieDoSomething$.
    On your button or entrance use a Set Variable to assign $GenieDoSomething$ the value remote/processKey?key=guide&clientAddr=$GenieMacAddress$
    Then when you drag the code (GenieCommand) into your builder it will execute the command that is stored in the variable $GenieDoSomething$.
    • view 4 more comments
    • Couldn't you achieve that by simply putting the set commands in an entrance that runs on every panel?
    • That would work but it's a lot to happen in every entrance. If you have 25-30 variables you may notice hesitation depending on the age of the hardware you are using. Using constants would be a methode that could also include device variables like device name(jims iphone,ect..) or type(iPhone 5s, 6,ect..) Then possibly date, time, current weather, geolocation. Many of these could have a huge influence on gui design and commands. You could have commands that are adjusted base off time. This would be great for lighting. With logic options and these you could change the background and font color base on daytime or nighttime. Or different options depending on if it's your iphone 5, or your wife's iphone 5. I believe all I devices have a name option in the iOS settings.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited sad, anxious, confused, frustrated

  • I'm back to needing to do this again, it seems every turn I find myself really just needing to create a command that is part text and part variable. I'm not working on a Kaleidescape integration and retrieving the URL for the cover art requires an ID. If I could simply pass the ID via a variable into a hard command it would save endless amounts of work. Instead, I'm back to having to do all kinds of set commands then creating commands off of those. It forces far more heavy lifting than should be necessary for this type of integration.

    For example:
    When you press the down arrow (or any arrow) on a remote, Kaleidescape returns what is highlighted in the form of an ID.

    What I really want to do is set up a feedback that receives that ID and puts it into a variable. Then simply create a command that effectively says "Get Cover Art URL for content id: $content_variable$" instead I have to create another variable that gets set with the full command string and the other variable then build commands off that variable. It just slows everything down needlessly, not to mention the extra work it requires when programming.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned

  • Came across this post as I want to concatenate variables and text for use as button/label text.

    @Josh - Did you ever get this resolved or did they abandon you?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned