ztalbot2000 / homebridge-cmd4

CMD4 Plugin for Homebridge - Supports ~All Accessory Types & now all Characteristics too
Apache License 2.0
149 stars 13 forks source link

State.js Get BrightLight returns invalid literal #78

Closed ghost closed 3 years ago

ghost commented 3 years ago

State.js Get BrightLight returns invalid literal for int() in Python. When passing State.js return value to int() function in Python, Python reports the value is invalidas below:

ValueError: invalid literal for int() with base 10: '"0"'.

And Python reports another phenomenon. State.js returns INACTIVE string, not 0 int.

ValueError: invalid literal for int() with base 10: 'INACTIVE'

This problem is not occurred on homebridge-cmd4@2.4.2.

I hope you fix it quickly. I rollbacked homebridge-cmd4 to 2.4.2.

Environment homebridge@1.1.7 homebridge-cmd4@3.0.4 Python 3.7.3

ztalbot2000 commented 3 years ago

Wow!,

Please send me your script and config.json

On Fri, Jan 15, 2021 at 1:36 PM anatsuk1 notifications@github.com wrote:

State.js Get BrightLight returns invalid literal for int() in Python. When passing State.js return value to int() function in Python, Python reports the value is invalidas below:

ValueError: invalid literal for int() with base 10: '"0"'.

And Python reports another phenomenon. State.js returns INACTIVE string, not 0 int.

ValueError: invalid literal for int() with base 10: 'INACTIVE'

This problem is not occurred on homebridge-cmd4@2.4.2.

I hope you fix it quickly. I rollbacked homebridge-cmd4 to 2.4.2.

Environment homebridge@1.1.7 homebridge-cmd4@3.0.4 Python 3.7.3

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/78, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCX4DGOVVGCCCEZAAYBDS2CDMLANCNFSM4WEOJIYA .

ztalbot2000 commented 3 years ago

Hi I cannot reproduce this without the config.json and the script you are using, even if it is my own, but if you have modified it in any way or the config.json, this is important to know.

I've gone through the code based on what you have provided. I'm thinking that the script is returning a constants, which is being cached. The next time the cached value (constant) is returned to Homebridge it is not converted into its actual value. Since I never seen this, in my testing I think it is an upgrade issue, but am not sure as I cannot reproduce it. Please provide the information I have requested.

ttfn, John Talbot

ztalbot2000 commented 3 years ago

Nope, cannot be a cached constant as getValue only stores the transposed value. Therefore the cached value is transposed. I'm at a loss without further information.

You say, "State.js Get BrightLight returns invalid literal for int() in Python", Get commands are Get . So I cannot even tell what characteristic you are having issues with. Cmd4 has 222 possible characteristics.

ghost commented 3 years ago

Hi @ztalbot2000;

You can find config.json and the Python script here: https://github.com/anatsuk1/cmd4_adrsir cmd4_adrsir.py is the Python script of cmd_state attribute in config.json.

I guess that State.js prints "0" on stdout. Not '0' but '"0"'. '"0"' is with obstructive double quotation(").

ztalbot2000 commented 3 years ago

Hi,

I have not fully investigated the issue and I will tomorrow, but I think it is because your config.json uses the word, "Inactive" which as a constant is supposed to be: "INACTIVE".

I must have removed the code that fixed this. One of the changes in 3.0 was to correctly return the type of the returned value, as required by Homebridge. In other words, I have to look up each characteristic and convert it accordingly. I.e. if the required value was a bool, 0 or 1 was no longer acceptable.

The quickest thing to do is change it to uppercase.

If you were to turn on outputConstants:true for example, I would not send InActive.

I'll dig more tomorrow.

TTFN, John

On Fri, Jan 15, 2021 at 10:46 PM anatsuk1 notifications@github.com wrote:

Hi @ztalbot2000 https://github.com/ztalbot2000;

You can find config.json and the Python script here: https://github.com/anatsuk1/cmd4_adrsir http://url cmd4_adrsir.py is the Python script of cmd_state attribute in config.json.

I guess that State.js prints "0" on stdout. Not '0' but '"0"'. '"0"' is with obstructive double quotation(").

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/78#issuecomment-761327747, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCX3EWRSWLGVF4HN5OFDS2EDYLANCNFSM4WEOJIYA .

ztalbot2000 commented 3 years ago

Another quick note. That bad value might be cached. I'm not sure. Changing your config.json, without fixing/deleting the cache is not probably going to correct it.

Back to bed I go ...

John

On Fri, Jan 15, 2021 at 11:51 PM John Talbot ztalbot2000@gmail.com wrote:

Hi,

I have not fully investigated the issue and I will tomorrow, but I think it is because your config.json uses the word, "Inactive" which as a constant is supposed to be: "INACTIVE".

I must have removed the code that fixed this. One of the changes in 3.0 was to correctly return the type of the returned value, as required by Homebridge. In other words, I have to look up each characteristic and convert it accordingly. I.e. if the required value was a bool, 0 or 1 was no longer acceptable.

The quickest thing to do is change it to uppercase.

If you were to turn on outputConstants:true for example, I would not send InActive.

I'll dig more tomorrow.

TTFN, John

On Fri, Jan 15, 2021 at 10:46 PM anatsuk1 notifications@github.com wrote:

Hi @ztalbot2000 https://github.com/ztalbot2000;

You can find config.json and the Python script here: https://github.com/anatsuk1/cmd4_adrsir http://url cmd4_adrsir.py is the Python script of cmd_state attribute in config.json.

I guess that State.js prints "0" on stdout. Not '0' but '"0"'. '"0"' is with obstructive double quotation(").

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/78#issuecomment-761327747, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCX3EWRSWLGVF4HN5OFDS2EDYLANCNFSM4WEOJIYA .

ztalbot2000 commented 3 years ago

I can see where the comments within State.js sheared you wrong. I'll fix that too. The definition is taken from the lib/CMD4..., but it is not fair for you to have known that.

Back to bed, John

On Fri, Jan 15, 2021 at 11:57 PM John Talbot ztalbot2000@gmail.com wrote:

Another quick note. That bad value might be cached. I'm not sure. Changing your config.json, without fixing/deleting the cache is not probably going to correct it.

Back to bed I go ...

John

On Fri, Jan 15, 2021 at 11:51 PM John Talbot ztalbot2000@gmail.com wrote:

Hi,

I have not fully investigated the issue and I will tomorrow, but I think it is because your config.json uses the word, "Inactive" which as a constant is supposed to be: "INACTIVE".

I must have removed the code that fixed this. One of the changes in 3.0 was to correctly return the type of the returned value, as required by Homebridge. In other words, I have to look up each characteristic and convert it accordingly. I.e. if the required value was a bool, 0 or 1 was no longer acceptable.

The quickest thing to do is change it to uppercase.

If you were to turn on outputConstants:true for example, I would not send InActive.

I'll dig more tomorrow.

TTFN, John

On Fri, Jan 15, 2021 at 10:46 PM anatsuk1 notifications@github.com wrote:

Hi @ztalbot2000 https://github.com/ztalbot2000;

You can find config.json and the Python script here: https://github.com/anatsuk1/cmd4_adrsir http://url cmd4_adrsir.py is the Python script of cmd_state attribute in config.json.

I guess that State.js prints "0" on stdout. Not '0' but '"0"'. '"0"' is with obstructive double quotation(").

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/78#issuecomment-761327747, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCX3EWRSWLGVF4HN5OFDS2EDYLANCNFSM4WEOJIYA .

ztalbot2000 commented 3 years ago

Your fix is in GitHub. I have to update some documentation and test install before publishing.

ztalbot2000 commented 3 years ago

I just publish Homebridge 3.0.5 which should address your issue. I used your config.json and my State.js file and it never fails. I did add back the uppercase of constants. Hopefully this was your issue. I also updated all the documentation accordingly.

ghost commented 3 years ago

Hi @ztalbot2000;

My investigation of this problem.

We get the following results. Infomation: BrightLight is displayName of Lightbulb type.

On homebridge-cmd4@3.0.7:

$ node ./State.js Get BrightLight Brightness
"50"

On homebridge-cmd4@2.4.2:

$ node ./State.js Get BrightLight Brightness
50

Once again, I tell you that State.js prints "50" on stdout. Not '50' but '"50"'. '"50"' is with obstructive double quotation(").

State.js prints with obstructive double quotation(").

Where you make this problem

console.log put a characteristic value which contains obstructive double quotation(").

This problem is made by commits of

Quoted by commit-diff After those commits:

if ( c == "" ) console.log( 1 ); else console.log( "\"%s\"", c ); Before those commits: if (c == "") console.log(1); else console.log(c);

You broke backward compatible is [here].(https://github.com/ztalbot2000/homebridge-cmd4/commit/4be6a74f22a005a9133ab04a905e5e4321e2f0a6#diff-2c77eff7401bb91335337bcda7bd9cd49beff452959abe2ba699fe34fb874b9aL160)

Go to bed, anatsuk1

ztalbot2000 commented 3 years ago

Hi,

The State.js is not middleware. Yes it now puts the output in double quotes, but the new Cmd4 can interpret the result from any script that has double quotes, single quotes or only 1 word responses for any field. Thus it can now handle characteristic strings, like Name with spaces in between . There is no reason for you to parse the output of State.js.

Your own script can output fields with single or double quotes around them if you choose.

So Cmd4 is backward compatible. Cmd4 accepts both the output from the old State.js file or the new one. State.js does not have to be backward compatible because it is a script that represents an example of what your own script could be.

What you are describing is that the old Cmd4 is forward compatible with the new State.js file, of which nothing can ever be.

I hope this clears things up. I'm not at home now so cannot try anything at this time.

Ttyl, John

On Sun, Jan 17, 2021 at 10:16 AM anatsuk1 notifications@github.com wrote:

Hi @ztalbot2000 https://github.com/ztalbot2000; My investigation of this problem.

We get the following results. Infomation: BrightLight is displayName of Lightbulb type.

On homebridge-cmd4@3.0.7:

$ node ./State.js Get BrightLight Brightness "50"

On homebridge-cmd4@2.4.2:

$ node ./State.js Get BrightLight Brightness 50

Once again, I tell you that State.js prints "50" on stdout. Not '50' but '"50"'. '"50"' is with obstructive double quotation(").

State.js prints with obstructive double quotation("). Where you make this problem

console.log put a characteristic value which contains obstructive double quotation(").

This problem is made by commits of

Quoted by commit-diff After those commits:

if ( c == "" ) console.log( 1 ); else console.log( ""%s"", c ); Before those commits: if (c == "") console.log(1); else console.log(c);

You broke backward compatible is [here].(4be6a74

diff-2c77eff7401bb91335337bcda7bd9cd49beff452959abe2ba699fe34fb874b9aL160

https://github.com/ztalbot2000/homebridge-cmd4/commit/4be6a74f22a005a9133ab04a905e5e4321e2f0a6#diff-2c77eff7401bb91335337bcda7bd9cd49beff452959abe2ba699fe34fb874b9aL160 )

Go to bed, anatsuk1

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/78#issuecomment-761828547, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCX7GQ2ITCPQEVQEYOG3S2L5NFANCNFSM4WEOJIYA .

ghost commented 3 years ago

My script(cmd4_adrsir.py) is the Python script of cmd_state attribute in config.json. cmd4_adrsir.py use State.js for storing characteristic states.

You can find cmd4_adrsir.py on my GitHub page

cmd4_adrsir.py pass the characteristic value which returns from State.js to int() function in Python. Then Python reports the value is invalidas below: ValueError: invalid literal for int() with base 10: '"0"'.

Again, State.js in homebridge-cmd4@2.4.2 returns good value(without double quotation mark).

I hope you help me, anatsuk1

ztalbot2000 commented 3 years ago

Hi,

I'll have a look, but you should not be using the output of State.js. Cmd4 was never intended that way. What I will do is fix your script so things work as they are supposed to be. That way you will have your own script that would work for both the old and new versions and that will maintain compatibility too. I believe you sent me the link to your script and your config.json file. If I'm missing any of these, please attach them too. I may ask for more information, but for now, that is all I need.

ttyl, John

On Sun, Jan 17, 2021 at 11:32 AM anatsuk1 notifications@github.com wrote:

My script(cmd4_adrsir.py) is the Python script of cmd_state attribute in config.json. cmd4_adrsir.py use State.js for storing characteristic states.

You can find cmd4_adrsir.py https://github.com/anatsuk1/cmd4_adrsir/blob/main/cmd4_adrsir.py on my GitHub page https://github.com/anatsuk1/cmd4_adrsir

cmd4_adrsir.py pass the characteristic value which returns from State.js to int() function in Python. Then Python reports the value is invalidas below: ValueError: invalid literal for int() with base 10: '"0"'.

Again, State.js in homebridge-cmd4@2.4.2 returns good value(without double quotation mark).

I hope you help me, anatsuk1

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/78#issuecomment-761839970, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCX3ILP233OIHQIRWTCTS2MGJLANCNFSM4WEOJIYA .

ztalbot2000 commented 3 years ago

Hi,

You have my Cmd4 config.json calling your cmd4_adrsir.py which calls my State.js and then calls another script ircontrol. The config.json file should call your ircontrol directly or properly parse the output of CMD4 (which protocol has not changed) and use that information to call ircontrol. I don't see the script for ircontrol and I don't know if you use ircontrol for other purposes and cannot change its input. Please send me the ircontrol script, and if you did not write it, the link to its source so I can judge further on how to proceed.

Thanks, John Talbot

ztalbot2000 commented 3 years ago

Never mind, I understand your script, working on it....

ztalbot2000 commented 3 years ago

Interesting as I dig deeper. You use State.js to store the state of the IR Display that you send to IRControl and receive it back when needed because cmd4adrsir.py does not know how to handle persistence. State.js just writes the state in files based on Status so it can read them back. For cmd4_adrsir.py to do the same thing, you could use the same technique, cutting State.js out of the middle and also meaning that by reading/writing directly to the filesystem, you do not have to spawn more processes to do what cmd4_adrsir.py could do itself.
So I'm still working on the changes to your script, unless you want to do it yourself, based on what I just discovered. I'll continue unless told otherwise.

ttfn, John

ztalbot2000 commented 3 years ago

!/usr/bin/env python3

""" Cmd4 Script Interface to IRControl """

Copyright (c) 2020, anatsuk1

All rights reserved.

#

BSD 2-Clause License

import subprocess import sys import time import datetime import fcntl import os

#

Modify interpreter and script location

# DEBUG = False

DEBUG = True

LOG_FILE = "/home/pi/log.txt"

Lock for Processes

LOCK_FILE = "/var/lib/homebridge/process.lock"

adrsirlib script on python3

IRCONTROL = "/usr/local/etc/adrsirlib/ircontrol"

############################

The files created within CMD4STATESPATH contain just a value of

the accessories last state,so they are very small in size.

Please change this to wherever you want them on your filesystem

CMD4STATESPATH = ".homebridge/Cmd4Scripts/Cmd4States"

#

Implimentation of functions

#

def read_data( device, characteristic ): """ Read State information """

# This is anything you can come up with so long as it
# is unique per device % characteristic
file_name = CMD4STATESPATH + "/Status_" + device  + "_" + characteristic

data = ""

if not os.path.exists( file_name ):
    return data

with open( file_name, 'r' ) as fid:

    data = fid.read( )
       # for debug
    if DEBUG:
        with open(LOG_FILE, mode="a") as log:
            print("[{}] Stored Result {}:

{}".format(datetime.datetime.now().timetz(), file_name, data), file=log)

return data

def write_data( device, characteristic, data ): """ Write State information """

file_name = CMD4STATESPATH + "/Status_" + device  + "_" + characteristic

with open( file_name, 'w' ) as fid:

    try:
        fid.write( data )

    except:
        # for debug
        if DEBUG:
            with open(LOG_FILE, mode="a") as log:
                print("[{}] Write Data Faiked {}:

{}".format(datetime.datetime.now().timetz(), file_name, data), file=log)

def make_states_dir( ): """ Create directory to c=place State persistant files """

if not os.path.exists( CMD4STATESPATH ):
    os.makedirs( CMD4STATESPATH )

def select_light_name(on_str, bright_str, name_prefix): """ Missing Docstring """

irdata = None
bright = int(bright_str)

# On atteribute is true
if on_str == "true":

    # Bright 100% ir data
    if bright == 100:
        irdata = name_prefix + "_full"

    # off ir data
    elif bright == 0:
        irdata = name_prefix + "_off"

    # Bright xx%(prefered) ir data
    elif bright <= 20:
        irdata = name_prefix + "_night"
    else:
        irdata = name_prefix + "_preference"

# On atteribute is false
elif on_str == "false":
    irdata = name_prefix + "_off"

return irdata

def select_aircon_name(active_str, heater_cooler_str): """ Missing Docstring """

irdata = None
active = int(active_str)
heater_cooler = int(heater_cooler_str)

# INACTIVE
if active == 0:
    irdata = "aircon_off"
# ACTIVE
elif active == 1:
    # INACTIVE or AUTO
    if heater_cooler == 0:
        irdata = "aircon_off"
    # heating
    elif heater_cooler == 1:
        irdata = "aircon_warm-22-auto"
    # cooling
    elif heater_cooler == 2:
        irdata = "aircon_cool-26-auto"

return irdata

send_irdata

device -> The device to send to

action -> The characteristic

next -> The data to send

# def send_irdata(device, action, next): """ Send IR data """

irdata = None

# Note: device is "displayName". It is NOT "name".

if device == "BrightLight":

    if action == "On":
        bright = read_data( device, "Brightness" )
        irdata = select_light_name(next, bright, "brightlight")
    elif action == "Brightness":
        on_state = read_data( device, "On" )
        irdata = select_light_name(on_state, next, "brightlight")

elif device == "DimLight":

    if action == "On":
        bright = read_data( device, "Brightness" )
        irdata = select_light_name(next, bright, "dimlight")
    elif action == "Brightness":
        on_state = read_data( device, "On" )
        irdata = select_light_name(on_state, next, "dimlight")

elif device == "AirConditioner":

    if action == "Active":
        heater_cooler = read_data( device, "CurrentHeaterCoolerState" )
        irdata = select_aircon_name(next, heater_cooler)

# Run ircontrol command like as:
# "<location>/ircontrol send ceiling_fan_power".
if irdata is not None:
    if DEBUG:
        with open(LOG_FILE, mode="a") as log:
            print("[{}]IrCommand: {} {}

{}".format(datetime.datetime.now().timetz(), IRCONTROL, "send", irdata), file=log) subprocess.run([IRCONTROL, "send", irdata])

def start_process(value): """ Essentially main """

# for debug
if DEBUG:
    with open(LOG_FILE, mode="a") as log:
        print("[{}]Cmd Argv:

{}".format(datetime.datetime.now().timetz(), value), file=log)

# Depend on adrsirlib and homebridge-cmd4 state script.
# ./ircontrol script with SEND command and stored ir data.

# value[1]: "Set" | "Get"
if value[1] == "Set":
    # value[2]: is value of "displayName" attribute. It is NOT
    #           "name" attribute.
    #           "displayName" is attribute name on config.json
    #           in homebridge, defined by homebridge-cmd4.
    # value[3]: user choiced attribute with maybe upper case.
    # value[4]: only if value[1] is "Set", numeric value of
    #           value[3] attribute. overwise CANNOT BE SET Cmd!

    send_irdata(value[2], value[3], value[4])

elif value[1] == "Get":
    # for debug
    if DEBUG:
        with open(LOG_FILE, mode="a") as log:
            print("[{}]No Get/Set Argv[1]:

{}".format(datetime.datetime.now().timetz(), value[1]), file=log)

    # value[2]: is value of "displayName" attribute. It is NOT
    #   "name" attribute.
    #   "displayName" is attribute name on config.json in
    #       homebridge, defined by homebridge-cmd4.
    # value[3]: user choiced attribute with maybe upper case.
    current = read_data( value[2], value[3] )

    print(current)

else:
    print("[{}]sys.argv: {}".format(datetime.datetime.now().timetz(),
      sys.argv), file=log)

if name == "main":

# for debug
if False:
    with open(LOG_FILE, mode="a") as log:
        print("[{}]sys.argv:

{}".format(datetime.datetime.now().timetz(), sys.argv), file=log)

# Create the directory of where to store state information
# ( persistance )
make_states_dir( )

with open(LOCK_FILE, "r") as lock_file:
    fcntl.flock(lock_file.fileno(), fcntl.LOCK_EX)
    try:
        start_process(sys.argv)
    finally:
        fcntl.flock(lock_file.fileno(), fcntl.LOCK_UN)

i just linted this, as I dont have ircontrol. you can see I just changed the process to call State.js with a read/write data routine ( Same as in State.js, to store the persistant state data. the psth to the directory is up to you. i coded the Cmd4Scripts dirrctory, but it does not need to be.

i hope this gives you an idea what should be done instead of calling State.js to store persistance data.

ttfn, john

On Sun, Jan 17, 2021 at 12:28 PM John Talbot ztalbot2000@gmail.com wrote:

Hi,

I'll have a look, but you should not be using the output of State.js. Cmd4 was never intended that way. What I will do is fix your script so things work as they are supposed to be. That way you will have your own script that would work for both the old and new versions and that will maintain compatibility too. I believe you sent me the link to your script and your config.json file. If I'm missing any of these, please attach them too. I may ask for more information, but for now, that is all I need.

ttyl, John

On Sun, Jan 17, 2021 at 11:32 AM anatsuk1 notifications@github.com wrote:

My script(cmd4_adrsir.py) is the Python script of cmd_state attribute in config.json. cmd4_adrsir.py use State.js for storing characteristic states.

You can find cmd4_adrsir.py https://github.com/anatsuk1/cmd4_adrsir/blob/main/cmd4_adrsir.py on my GitHub page https://github.com/anatsuk1/cmd4_adrsir

cmd4_adrsir.py pass the characteristic value which returns from State.js to int() function in Python. Then Python reports the value is invalidas below: ValueError: invalid literal for int() with base 10: '"0"'.

Again, State.js in homebridge-cmd4@2.4.2 returns good value(without double quotation mark).

I hope you help me, anatsuk1

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/78#issuecomment-761839970, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCX3ILP233OIHQIRWTCTS2MGJLANCNFSM4WEOJIYA .

ghost commented 3 years ago

Hey John,

Your suggestion looks NOT good to me. I already know better solution my own, I can change my script, cmd4_adrsir.py, to remove obstructive double quotation(*) from a result as State.js prints.

We desire that your State.js have backward compatible. I strongly request that State.js prints a value WITHOUT obstructive double quotation(*).

Best, anatsuk1

ztalbot2000 commented 3 years ago

You need quotes around values because how could you descern the following:

Set My Red Mitsu TV BIG Characteristic Forty Five

I put spaces as an example, but if you don't use quotes, arg1 is Set, arg2 is My and arg3 is Red.

Kind of exaggerating here, but do you see?

All you are using State.js for is to store persistance because you can't get the state of an IR value yourself. The solution I gave you is better.

TTFN, John

On Sun, Jan 17, 2021 at 9:42 PM anatsuk1 notifications@github.com wrote:

Hey John,

Your suggestion looks NOT good to me. I already know better solution my own, I can change my script, cmd4_adrsir.py, to remove obstructive double quotation(*) from a result as State.js prints.

We desire that your State.js have backward compatible. I strongly request that State.js prints a value WITHOUT obstructive double quotation(*).

Best, anatsuk1

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/78#issuecomment-761942943, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCX5ABZEABAVQVG6DNFLS2ON2JANCNFSM4WEOJIYA .

ghost commented 3 years ago

John,

We escape white space with back slash mark() in shell script. I hope you would keep State.js having backward compatible.

Hope, anatsuk1

ztalbot2000 commented 3 years ago

I had thought of another solution. Just keep a copy of the old State.js file and call that one. Problem solved.

John

On Sun, Jan 17, 2021 at 11:00 PM anatsuk1 notifications@github.com wrote:

John,

We escape white space with back slash mark() in shell script. I hope you would keep State.js having backward compatible.

Hope, anatsuk1

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/78#issuecomment-761964588, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCXYOHVFF37P2JGADA23S2OW6RANCNFSM4WEOJIYA .

ghost commented 3 years ago

John,

I already know the another one too. I understand State.js prints with obstructive double quotation till the far future.

I will develop an original software of state management system. In the near future, you will be able to see on my Github page.

Thank you for your quickly responses, anatsuk1

ztalbot2000 commented 3 years ago

There are many ways to handle white space. You could escape them, quote them, CSV them, whatever you like. Cmd4 evolved from CmdSwitch2. I just wanted to see what HomeKit could do. CmdSwitch2 does not provide any scripts at all and can only handle switches. That being said, Cmd4 now that it has caching does not need a State.js file at all to do what it set out to do, demonstrate what HomeKit can do and provide a mechanism to control any type of device. The problem with State.js is that comments cannot be truthed. And is why I got in trouble with upper/lower case characters. The whole thing is duplicated again in config.min.json. Maintaining comments is a nightmare. The whole disagreement is silly because if you were to take the original State.js file, you could wipe it all out except for the readDate/writeData routines and call that as a sub shell as you do now, which is also silly, because why call a sub shell to background a process that you now have in your new shell?

I rewrote a whole section of Cmd4 just because someone was upset that Cmd4 created to many processes, creating caching causing more nightmares to which I rewrote again to uncache Cmd4 directives. I provided a better method for your own python script. Where does it end? There are just so many ways to do things. I cannot please everyone, especially if people do things as it was not intended. If I obsolète State.js as I could to save myself a lot of headaches, then what?

TTFN, John

On Sun, Jan 17, 2021 at 11:34 PM John Talbot ztalbot2000@gmail.com wrote:

I had thought of another solution. Just keep a copy of the old State.js file and call that one. Problem solved.

John

On Sun, Jan 17, 2021 at 11:00 PM anatsuk1 notifications@github.com wrote:

John,

We escape white space with back slash mark() in shell script. I hope you would keep State.js having backward compatible.

Hope, anatsuk1

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/78#issuecomment-761964588, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCXYOHVFF37P2JGADA23S2OW6RANCNFSM4WEOJIYA .

ztalbot2000 commented 3 years ago

I've started coding automated documentation pages that can be truthed and with caching, will obsolete State.js. State.js wil be incorporated into examples within the documentation. I'd rather do other things, but this will save time in the long run.

John Talbot

On Mon, Jan 18, 2021 at 12:09 AM John Talbot ztalbot2000@gmail.com wrote:

There are many ways to handle white space. You could escape them, quote them, CSV them, whatever you like. Cmd4 evolved from CmdSwitch2. I just wanted to see what HomeKit could do. CmdSwitch2 does not provide any scripts at all and can only handle switches. That being said, Cmd4 now that it has caching does not need a State.js file at all to do what it set out to do, demonstrate what HomeKit can do and provide a mechanism to control any type of device. The problem with State.js is that comments cannot be truthed. And is why I got in trouble with upper/lower case characters. The whole thing is duplicated again in config.min.json. Maintaining comments is a nightmare. The whole disagreement is silly because if you were to take the original State.js file, you could wipe it all out except for the readDate/writeData routines and call that as a sub shell as you do now, which is also silly, because why call a sub shell to background a process that you now have in your new shell?

I rewrote a whole section of Cmd4 just because someone was upset that Cmd4 created to many processes, creating caching causing more nightmares to which I rewrote again to uncache Cmd4 directives. I provided a better method for your own python script. Where does it end? There are just so many ways to do things. I cannot please everyone, especially if people do things as it was not intended. If I obsolète State.js as I could to save myself a lot of headaches, then what?

TTFN, John

On Sun, Jan 17, 2021 at 11:34 PM John Talbot ztalbot2000@gmail.com wrote:

I had thought of another solution. Just keep a copy of the old State.js file and call that one. Problem solved.

John

On Sun, Jan 17, 2021 at 11:00 PM anatsuk1 notifications@github.com wrote:

John,

We escape white space with back slash mark() in shell script. I hope you would keep State.js having backward compatible.

Hope, anatsuk1

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/78#issuecomment-761964588, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCXYOHVFF37P2JGADA23S2OW6RANCNFSM4WEOJIYA .

ghost commented 3 years ago

Hi John,

I want to send IR data which involves some states on one shot. Because almost IR devices, e.g. ceiling light, air conditioner and more, receive IR data which involves some states in one IR data. For example, on Lightbulb people need to build IR data form all attributes of "on", "brightness", "hue", "saturation" and "colorTemperature".

Cache feature in CMD4 is not support this requirement. So, people will develop their own original software of state management system.

FYI: A blog that to Investigate Ir data in Japanese is here: https://days-of-programming.blogspot.com/2017/05/blog-post.html You can google-translate the blog into English.

Your help, anatsuk1

ztalbot2000 commented 3 years ago

Your script can do whatever it wants with the characteristic data Cmd4 sends. Apples own HomeKit only asks for one characteristic at a time. I can't change that.

TTFN, John

On Tue, Jan 19, 2021 at 9:36 AM anatsuk1 notifications@github.com wrote:

Hi John,

I want to send IR data which involves some states on one shot. Because almost IR devices, e.g. ceiling light, air conditioner and more, receive IR data which involves some states in one IR data. For example, on Lightbulb people need to build IR data form all attributes of "on", "brightness", "hue", "saturation" and "colorTemperature".

Cache feature in CMD4 is not support this requirement. So, people will develop their own original software of state management system.

FYI: A blog that to Investigate Ir data in Japanese is here: https://days-of-programming.blogspot.com/2017/05/blog-post.html You can google-translate the blog into English.

Your help, anatsuk1

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/78#issuecomment-762880459, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCX3YNKWKCRLAAVYBZDTS2WKGRANCNFSM4WEOJIYA .

ghost commented 3 years ago

Hi John,

I already told you that I would develop an original software of state management system(hereinafter referred to as State Software). But other people also will develop their own State Software.

State.js will help me to develop my State Software. To make it better, I believe that you provide us a State Software to build IR data in our own script, like State.js.

Kindly, anatsuk1