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

Closed
jonbur opened this issue Dec 9, 2024 · 16 comments
Closed

Question: how to use Read Scale Script #1533

jonbur opened this issue Dec 9, 2024 · 16 comments
Labels
bug Something isn't working fixed

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

@unocelli
Copy link
Member

unocelli commented Dec 18, 2024

Try to return a string '0'.
The Run Test have a bug but the script work as expected

@jonbur
Copy link
Author

jonbur commented Dec 18, 2024

Hi,

Sorry, this still does not appear to work.

With the script below:

Screenshot 2024-12-18 at 22 39 04

Applied as the 'Read Scale Script' on a tag as per the below:

Screenshot 2024-12-18 at 22 40 28

The value does not change (see circled in red). It also does not change in the action on the object in the editor - it is still 'on' or 'off'.

Even is I just do this:

Screenshot 2024-12-18 at 22 39 32

the value does not change.
It is like the script is not being called at all...

Thanks

@unocelli
Copy link
Member

Hi, sorry, you are right! in mqtt is missing a reference to process the script

@unocelli unocelli added bug Something isn't working and removed fixed labels Dec 19, 2024
@unocelli unocelli added the fixed label Dec 19, 2024
@jonbur
Copy link
Author

jonbur commented Dec 19, 2024

Thanks very much, I’ll test the latest version over the weekend :-)

@851666395
Copy link

Thanks very much, I’ll test the latest version over the weekend :-)

I have also encountered similar problems in webAPI。

QQ截图20241220230800

QQ截图20241220230924

@851666395
Copy link

Hi, sorry, you are right! in mqtt is missing a reference to process the script

HI,I have also encountered similar problems in webAPI。

@unocelli
Copy link
Member

@851666395 Hi, Yes should be fixed in mqtt, ethernetip and httprequest (WebApi)

@851666395
Copy link

@851666395 Hi, Yes should be fixed in mqtt, ethernetip and httprequest (WebApi)

thank you,I'll try again when it's fixed。

@jonbur
Copy link
Author

jonbur commented Dec 21, 2024

Thanks, I can confirm the latest release is working for me.
Thank you.

@unocelli
Copy link
Member

unocelli commented Jan 1, 2025

I’m going to close this as resolved. let me know if you have any issues.

@unocelli unocelli closed this as completed Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

5 participants