Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: how to use Read Scale Script #1533

Open
jonbur opened this issue Dec 9, 2024 · 6 comments
Open

Question: how to use Read Scale Script #1533

jonbur opened this issue Dec 9, 2024 · 6 comments

Comments

@jonbur
Copy link

jonbur commented Dec 9, 2024

Hi, I hope you can help. I am having trouble with Read Scale Script and can't find any documentation.

I have several tags coming from mqtt that hves the value either 'on' or 'off', as below:

Screenshot 2024-12-09 at 15 23 54

I would like to use this to drive Actions on a shape. I understand that Actions can only be driven by numerical values and therefore I am looking to convert the text values to equivalent numerical/binary values (1/0). I have created the script below and assigned it as the Read Scale Script.

Screenshot 2024-12-09 at 15 23 25 Screenshot 2024-12-09 at 15 24 32

However, this does not appear to work. There is no error in the logs. Even if I change the script to simply just 'return 1' in all cases I don't see a change to the value of the tag.

Am I missing something?

Thank you very much.

@MatthewReed303
Copy link
Collaborator

@jonbur
Copy link
Author

jonbur commented Dec 9, 2024

Hi,

Thanks for this. I have seen this and believe I have followed the design pattern shown, but it does not look like the script is being applied / changing the output.

Just to make sure I have this correct conceptually, the 'value' that is passed into the read script is the tag value that is read from the integration connector (in this case mqtt) and then the script manipulates it and whatever is returned should then be what we see when that tag is used elsewhere?

Thank you

@henjoe
Copy link

henjoe commented Dec 15, 2024

Your script is actually correct. I dont know why it is not working.

@unocelli
Copy link
Member

Hi, try to debug with a console.log(value);

@jonbur
Copy link
Author

jonbur commented Dec 15, 2024

Thanks. If I run the script in the script editor with console logging, I get the below:

Screenshot 2024-12-15 at 11 56 57

This seems fine (although I note I don't get return '0' when I call with 'off'...

Is there a logger object I can use to log to fuxa.log from within the script so I can see whether this script is actually getting caleld by the 'read scale script' defined on the tag?

Thanks

@henjoe
Copy link

henjoe commented Dec 15, 2024

Hi @unocelli the issue might be related to #1435

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants