Skip to content

Streamlined way to make custom signals. #2

@Vendelator

Description

@Vendelator

While i've yet to figure out how to successfully send a signal to my AC-unit, i wanted to create a method of making signals based on user input or data from MQTT client or similar.

This is currently missing in your programs from what i can tell.

I'm publishing this here because i'm not sure where to post suggestions? Sorry if this bothers you.

Crude method...

  • I start off by using your GUI program and re-record until i get the correct signal length, which seems to be 210.

  • I then make a spreadsheet of all combinations that i want to use and need to see to assess the code (which i have almost no understanding of).

  • I write down each "high" value for each setting.
    This looks like this:
    temp

  • Finally i use this spreadsheet to make a simple program that creates a signal based on what functionality i call.

# The different lenghts of signals
command_lenght = {"0":(8880),"1":(4440),"2":(1665),"3":(555)}

first_tuple = (4, 6, 16, 18) # Present in all signals...
temp_dict = {"16":(32,), "17":(26, 32),"18":(28, 32)} # Different highs for different temps
swing_dict = {"on":(), "off":(20, 22, 24)} # Different highs swing on/off
second_tuple = (46, 48, 50) # Present in all signals...
mode_lst = {} # Mode seems to be dependent on temperature settings only?
fan_dict = {"auto":(78, 82), "high":(78,), "mid":(80,), "low":(78, 80)} # Different highs for different temperatures
standby_dict = {"on":(158,), "off":()} # Only high that is not present in any Off versions.

# This field will be replaced by values from NodeRed
temp = str(input("temp? int: "))
swing = str(input("Swing? on, off: "))
fan = str(input("fan speed? low, mid, high, auto: "))
standby = str(input("Unit on or off? on, off: "))

# Creates a tuple with all high's in the signal.
high_commands = first_tuple + tuple(temp_dict["16"]) + swing_dict[swing] + second_tuple + fan_dict[fan] + standby_dict[standby]

print (high_commands)

# Uses the tuple to create a full signal.
def signal_compiler():
    send_command = []
    for r in range (210): # Full range UNKNOWN
        if r == 0: # The first extra long signal
            send_command.append(command_lenght["0"])
        elif r == 1: # The second extra long signal
            send_command.append(command_lenght["1"])
        elif r+1 in high_commands: #+1 because range starts with 0.
            send_command.append(command_lenght["2"])
        else:
            send_command.append(command_lenght["3"])
    #print (send_command)
    return send_command # Returns a completed signal within a List

print(lsignal_compiler()) # Displays the full signal list
print(len(signal_compiler())) # Prints the number of signals in the list

Once i can actually send signals to my AC-unit i can clean up this code. But as of now, all signals i create using input() gives the expected output, which is nice.

EDIT

I have now been able to send some code to control my AC-unit, and my script works fine, almost...
Out of the 211 values in each signal, it seems 202, 204, 206 and 208 are unique. Meaning i have to manually store several tuples to be able to properly call the right signals.

The code looks like this now and is callable from other programs. The problem is how to best store the combinations of unique values.

T = 562 # NEC standard, Signal lenght (one T)

first_tuple = (4, 6, 16, 18) # Present in all signals...
temp_dict = {"16":(32,), "17":(26, 32),"18":(28, 32),"19":(26, 28, 32),"20":(30, 32)} # Different highs for different temps
swing_dict = {"on":(), "off":(20, 22, 24)} # Different highs swing on/off
second_tuple = (46, 48, 50) # Present in all signals
mode_dict = {} # Mode seems to be dependent on temperature settings???
fan_dict = {"auto":(78, 82), "high":(78,), "mid":(80,), "low":(78, 80)} # Different highs for different temperatures
standby_dict = {"on":(158,), "off":()} # Only high that is not present in any Off versions.
swing_dict_end = {"on":(182, 196, 200), "off":(180, 184, 196, 198, 200)}
unique_tuple = () # 202, 204, 206, 208
third_tuple = (210,) # Assuming the last bits are random....

# Uses the tuple to create a full signal.
def signal_compiler(temp, swing, fan, standby):
    send_command = (16*T, 8*T) # Start snippet of code
    high_commands = first_tuple + tuple(temp_dict[str(temp)]) + swing_dict[swing] + \
                    second_tuple + fan_dict[fan] + standby_dict[standby] + swing_dict_end[swing] + third_tuple # Bulk of the code
    for r in range (209): # Full range 211, add tuples to create one complete tuple with 211 values.
        if r+1 in high_commands: #+1 because range starts with 0.
            send_command = send_command + (3*T,)#(command_lenght["2"],)
        else:
            send_command = send_command + (T,)#(command_lenght["3"],)
    return send_command # Returns a completed signal within a tuple

# Example that prints a working signal and counts all elements within that tuple.
if __name__ == "__main__":
    print(signal_compiler("16", "on", "auto", "on")) # (temp, swing, fan, standby)
    print(len(signal_compiler("16", "on", "auto", "on")))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions