-
Notifications
You must be signed in to change notification settings - Fork 20
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
fix createClient deprecated and #23 #31
base: master
Are you sure you want to change the base?
Conversation
createClient deprecated. thanks @CraigD80
inter-message gap not necessary once we fix receiving messages
have you added this line?
|
you need to add that line too before you do call |
OK,
I've downloaded your fork with all your commits and edited my setting.js and it actually loads now! I get the "all connected" message.
I've set the logging=true option and the getallonstart and I see all my c-bus devices on the console, with their true ON/OFF and brightness state.
I've configured a single light in my configuration.yaml in HA
mqtt:
light:
- name: Bstudy
state_topic: "cbus/read/254/56/36/state"
command_topic: "cbus/write/254/56/36/switch"
brightness_state_topic: "cbus/read/254/56/36/level"
brightness_command_topic: "cbus/write/254/56/36/ramp"
payload_off: "OFF"
payload_on: "ON"
on_command_type: "brightness"
unique_id: mq_study
brightness_scale: 100
I can hit the light on/off in HA and see
NOOP
Message received on cbus/write/254/56/36/switch : OFF
On the console. The light in HA stays ON (as does the physical light) The message is always OFF.
If I adjust a brightness control on the light in HA I get an exception:
NOOP
NOOP
Message received on cbus/write/254/56/36/ramp : 100
/usr/local/bin/cgateweb/index.js:164
switch(message.toUpperCase()) {
^
TypeError: message.toUpperCase is not a function
at MqttClient.<anonymous> (/usr/local/bin/cgateweb/index.js:164:26)
I'm doing an online course on JavaScript then I'll do one on Node, because I want to get a better grip on all of this, but in the meantime, do you have any suggestions? It feels like I am really close to getting this all working.
Thanks,
Brian
From: rbswift ***@***.***>
Sent: Sunday, 10 July 2022 3:06 PM
To: the1laz/cgateweb ***@***.***>
Cc: Subscribed ***@***.***>
Subject: Re: [the1laz/cgateweb] fix createClient deprecated (PR #31)
you need to add that line too before you do call mqtt.connect
-
Reply to this email directly, view it on GitHub<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fthe1laz%2Fcgateweb%2Fpull%2F31%23issuecomment-1179670545&data=05%7C01%7C%7C9a162c304bae4355d20e08da6242a03f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637930335553776496%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=e3I4biSsBSqrpldUg306rcfKYroMKNRTTNUD3BMaqWg%3D&reserved=0>, or unsubscribe<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAF5SOLIIKLHSZFNFTKYX7BLVTJY47ANCNFSM52UPLAVQ&data=05%7C01%7C%7C9a162c304bae4355d20e08da6242a03f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637930335553776496%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=rq7ruZoMFJXUu%2B2OQjb9k%2F8veIIOaJB%2Fb7Y0C%2FeC73A%3D&reserved=0>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.******@***.***>>
|
It is because the ramp value ( a number) cannot be converted to uppercase by the function.
Add “message = String(message);”
On the line immediately before the error.
It will convert the number eg 88 to a character string “88”.
I had the same problem the other day.
Cheers
Craig
Craig Duncan
CTO, Correlate Pty Ltd
… On 10 Jul 2022, at 10:20 pm, bdnstn ***@***.***> wrote:
OK,
I've downloaded your fork with all your commits and edited my setting.js and it actually loads now! I get the "all connected" message.
I've set the logging=true option and the getallonstart and I see all my c-bus devices on the console, with their true ON/OFF and brightness state.
I've configured a single light in my configuration.yaml in HA
mqtt:
light:
- name: Bstudy
state_topic: "cbus/read/254/56/36/state"
command_topic: "cbus/write/254/56/36/switch"
brightness_state_topic: "cbus/read/254/56/36/level"
brightness_command_topic: "cbus/write/254/56/36/ramp"
payload_off: "OFF"
payload_on: "ON"
on_command_type: "brightness"
unique_id: mq_study
brightness_scale: 100
I can hit the light on/off in HA and see
NOOP
Message received on cbus/write/254/56/36/switch : OFF
On the console. The light in HA stays ON (as does the physical light) The message is always OFF.
If I adjust a brightness control on the light in HA I get an exception:
NOOP
NOOP
Message received on cbus/write/254/56/36/ramp : 100
/usr/local/bin/cgateweb/index.js:164
switch(message.toUpperCase()) {
^
TypeError: message.toUpperCase is not a function
at MqttClient.<anonymous> (/usr/local/bin/cgateweb/index.js:164:26)
I'm doing an online course on JavaScript then I'll do one on Node, because I want to get a better grip on all of this, but in the meantime, do you have any suggestions? It feels like I am really close to getting this all working.
Thanks,
Brian
From: rbswift ***@***.***>
Sent: Sunday, 10 July 2022 3:06 PM
To: the1laz/cgateweb ***@***.***>
Cc: Subscribed ***@***.***>
Subject: Re: [the1laz/cgateweb] fix createClient deprecated (PR #31)
you need to add that line too before you do call mqtt.connect
-
Reply to this email directly, view it on GitHub<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fthe1laz%2Fcgateweb%2Fpull%2F31%23issuecomment-1179670545&data=05%7C01%7C%7C9a162c304bae4355d20e08da6242a03f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637930335553776496%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=e3I4biSsBSqrpldUg306rcfKYroMKNRTTNUD3BMaqWg%3D&reserved=0>, or unsubscribe<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAF5SOLIIKLHSZFNFTKYX7BLVTJY47ANCNFSM52UPLAVQ&data=05%7C01%7C%7C9a162c304bae4355d20e08da6242a03f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637930335553776496%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=rq7ruZoMFJXUu%2B2OQjb9k%2F8veIIOaJB%2Fb7Y0C%2FeC73A%3D&reserved=0>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.******@***.***>>
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
|
Thanks Craig,
That fixed the exception.
I’ve installed MQTT Explorer and I can see MQTT messages, even the little “hello world” that is embedded in index.js 😊
So my commands are getting from HA through MQTT and are being logged by index.js. It looks to me like it could be an issue with the format of the message going to cgate? I can control lights by telnetting to cgate.
Load project xxx
Use project xxx
Open net 254
Tree 254
On 254/56/36
Off 254/56/36
Turns physical light 36 on and off.
In the log (in response to HA commands) I see:
Message received on cbus/write/254/56/36/switch : ON
Does that actually get sent as “On 254/56/36”?
I wish I had a debugger I could get in with to see the actual messages.
Brian
From: CraigD80 ***@***.***>
Sent: Sunday, 10 July 2022 8:52 PM
To: the1laz/cgateweb ***@***.***>
Cc: bdnstn ***@***.***>; Comment ***@***.***>
Subject: Re: [the1laz/cgateweb] fix createClient deprecated and #23 (PR #31)
It is because the ramp value ( a number) cannot be converted to uppercase by the function.
Add “message = String(message);”
On the line immediately before the error.
It will convert the number eg 88 to a character string “88”.
I had the same problem the other day.
Cheers
Craig
Craig Duncan
CTO, Correlate Pty Ltd
On 10 Jul 2022, at 10:20 pm, bdnstn ***@***.***<mailto:***@***.***>> wrote:
OK,
I've downloaded your fork with all your commits and edited my setting.js and it actually loads now! I get the "all connected" message.
I've set the logging=true option and the getallonstart and I see all my c-bus devices on the console, with their true ON/OFF and brightness state.
I've configured a single light in my configuration.yaml in HA
mqtt:
light:
- name: Bstudy
state_topic: "cbus/read/254/56/36/state"
command_topic: "cbus/write/254/56/36/switch"
brightness_state_topic: "cbus/read/254/56/36/level"
brightness_command_topic: "cbus/write/254/56/36/ramp"
payload_off: "OFF"
payload_on: "ON"
on_command_type: "brightness"
unique_id: mq_study
brightness_scale: 100
I can hit the light on/off in HA and see
NOOP
Message received on cbus/write/254/56/36/switch : OFF
On the console. The light in HA stays ON (as does the physical light) The message is always OFF.
If I adjust a brightness control on the light in HA I get an exception:
NOOP
NOOP
Message received on cbus/write/254/56/36/ramp : 100
/usr/local/bin/cgateweb/index.js:164
switch(message.toUpperCase()) {
^
TypeError: message.toUpperCase is not a function
at MqttClient.<anonymous> (/usr/local/bin/cgateweb/index.js:164:26)
I'm doing an online course on JavaScript then I'll do one on Node, because I want to get a better grip on all of this, but in the meantime, do you have any suggestions? It feels like I am really close to getting this all working.
Thanks,
Brian
From: rbswift ***@***.***<mailto:***@***.***>>
Sent: Sunday, 10 July 2022 3:06 PM
To: the1laz/cgateweb ***@***.***<mailto:***@***.***>>
Cc: Subscribed ***@***.***<mailto:***@***.***>>
Subject: Re: [the1laz/cgateweb] fix createClient deprecated (PR #31)
you need to add that line too before you do call mqtt.connect
-
Reply to this email directly, view it on GitHub<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fthe1laz%2Fcgateweb%2Fpull%2F31%23issuecomment-1179670545&data=05%7C01%7C%7C9a162c304bae4355d20e08da6242a03f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637930335553776496%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=e3I4biSsBSqrpldUg306rcfKYroMKNRTTNUD3BMaqWg%3D&reserved=0>, or unsubscribe<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAF5SOLIIKLHSZFNFTKYX7BLVTJY47ANCNFSM52UPLAVQ&data=05%7C01%7C%7C9a162c304bae4355d20e08da6242a03f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637930335553776496%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=rq7ruZoMFJXUu%2B2OQjb9k%2F8veIIOaJB%2Fb7Y0C%2FeC73A%3D&reserved=0>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.******@***.***<mailto:***@***.******@***.***>>>
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
—
Reply to this email directly, view it on GitHub<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fthe1laz%2Fcgateweb%2Fpull%2F31%23issuecomment-1179723259&data=05%7C01%7C%7C8962592b23564083a9bc08da62730a35%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637930543506656493%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=RrxeMAkvxq90KtOTUZMJroT4otcHInrQXTrCIrGw4lg%3D&reserved=0>, or unsubscribe<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAF5SOLKHZ2U76RUPTQD6Z3TVTLBQPANCNFSM52UPLAVQ&data=05%7C01%7C%7C8962592b23564083a9bc08da62730a35%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637930543506656493%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=2dYk9VcC%2Fb6Dlv6FizgKVQx9GMp4%2FNEd5bIpe1T30y4%3D&reserved=0>.
You are receiving this because you commented.Message ID: ***@***.******@***.***>>
|
Try adding I'm only just getting started with this project, haven't installed my c-bus gear yet and so far only have relays. If anyone wants to send me a dimmer I'll happily get it working :) |
So, just to close this out, I have the system working, with some help from @the1laz . Ultimatly, the issue was that my c-bus project was not getting opened because the C-GateConfig.txt (which was generated by CGate in the first place), had an "xml" extension on the filename for my project.
(above) fails, but this (below) works:
The actual project file on disk is XXXXX.xml. |
Just for anyone looking at this what said in my previous message wasn’t really correct. Numbers don’t have the uppercase function. By converting to a string this method becomes available.
Anyway Brian what I understand is that mqtt broker side to HA is working, and cgate to cbus is working right? So the issue relates to mqtt to cgate. Have you looked at the cgate log file?
I am using HA and can switch and dim a light so the functionality is ok.
Cheers
Craig
Craig Duncan
CTO, Correlate Pty Ltd
… On 10 Jul 2022, at 11:12 pm, bdnstn ***@***.***> wrote:
Thanks Craig,
That fixed the exception.
I’ve installed MQTT Explorer and I can see MQTT messages, even the little “hello world” that is embedded in index.js 😊
So my commands are getting from HA through MQTT and are being logged by index.js. It looks to me like it could be an issue with the format of the message going to cgate? I can control lights by telnetting to cgate.
Load project xxx
Use project xxx
Open net 254
Tree 254
On 254/56/36
Off 254/56/36
Turns physical light 36 on and off.
In the log (in response to HA commands) I see:
Message received on cbus/write/254/56/36/switch : ON
Does that actually get sent as “On 254/56/36”?
I wish I had a debugger I could get in with to see the actual messages.
Brian
From: CraigD80 ***@***.***>
Sent: Sunday, 10 July 2022 8:52 PM
To: the1laz/cgateweb ***@***.***>
Cc: bdnstn ***@***.***>; Comment ***@***.***>
Subject: Re: [the1laz/cgateweb] fix createClient deprecated and #23 (PR #31)
It is because the ramp value ( a number) cannot be converted to uppercase by the function.
Add “message = String(message);”
On the line immediately before the error.
It will convert the number eg 88 to a character string “88”.
I had the same problem the other day.
Cheers
Craig
Craig Duncan
CTO, Correlate Pty Ltd
> On 10 Jul 2022, at 10:20 pm, bdnstn ***@***.***<mailto:***@***.***>> wrote:
>
>
> OK,
>
> I've downloaded your fork with all your commits and edited my setting.js and it actually loads now! I get the "all connected" message.
> I've set the logging=true option and the getallonstart and I see all my c-bus devices on the console, with their true ON/OFF and brightness state.
>
> I've configured a single light in my configuration.yaml in HA
>
> mqtt:
> light:
> - name: Bstudy
> state_topic: "cbus/read/254/56/36/state"
> command_topic: "cbus/write/254/56/36/switch"
> brightness_state_topic: "cbus/read/254/56/36/level"
> brightness_command_topic: "cbus/write/254/56/36/ramp"
> payload_off: "OFF"
> payload_on: "ON"
> on_command_type: "brightness"
> unique_id: mq_study
> brightness_scale: 100
>
> I can hit the light on/off in HA and see
> NOOP
> Message received on cbus/write/254/56/36/switch : OFF
> On the console. The light in HA stays ON (as does the physical light) The message is always OFF.
>
> If I adjust a brightness control on the light in HA I get an exception:
>
> NOOP
> NOOP
> Message received on cbus/write/254/56/36/ramp : 100
> /usr/local/bin/cgateweb/index.js:164
> switch(message.toUpperCase()) {
> ^
> TypeError: message.toUpperCase is not a function
> at MqttClient.<anonymous> (/usr/local/bin/cgateweb/index.js:164:26)
>
> I'm doing an online course on JavaScript then I'll do one on Node, because I want to get a better grip on all of this, but in the meantime, do you have any suggestions? It feels like I am really close to getting this all working.
>
> Thanks,
> Brian
>
>
> From: rbswift ***@***.***<mailto:***@***.***>>
> Sent: Sunday, 10 July 2022 3:06 PM
> To: the1laz/cgateweb ***@***.***<mailto:***@***.***>>
> Cc: Subscribed ***@***.***<mailto:***@***.***>>
> Subject: Re: [the1laz/cgateweb] fix createClient deprecated (PR #31)
>
>
> you need to add that line too before you do call mqtt.connect
>
> -
> Reply to this email directly, view it on GitHub<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fthe1laz%2Fcgateweb%2Fpull%2F31%23issuecomment-1179670545&data=05%7C01%7C%7C9a162c304bae4355d20e08da6242a03f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637930335553776496%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=e3I4biSsBSqrpldUg306rcfKYroMKNRTTNUD3BMaqWg%3D&reserved=0>, or unsubscribe<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAF5SOLIIKLHSZFNFTKYX7BLVTJY47ANCNFSM52UPLAVQ&data=05%7C01%7C%7C9a162c304bae4355d20e08da6242a03f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637930335553776496%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=rq7ruZoMFJXUu%2B2OQjb9k%2F8veIIOaJB%2Fb7Y0C%2FeC73A%3D&reserved=0>.
> You are receiving this because you are subscribed to this thread.Message ID: ***@***.******@***.***<mailto:***@***.******@***.***>>>
> —
> Reply to this email directly, view it on GitHub, or unsubscribe.
> You are receiving this because you were mentioned.
—
Reply to this email directly, view it on GitHub<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fthe1laz%2Fcgateweb%2Fpull%2F31%23issuecomment-1179723259&data=05%7C01%7C%7C8962592b23564083a9bc08da62730a35%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637930543506656493%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=RrxeMAkvxq90KtOTUZMJroT4otcHInrQXTrCIrGw4lg%3D&reserved=0>, or unsubscribe<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAF5SOLKHZ2U76RUPTQD6Z3TVTLBQPANCNFSM52UPLAVQ&data=05%7C01%7C%7C8962592b23564083a9bc08da62730a35%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637930543506656493%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=2dYk9VcC%2Fb6Dlv6FizgKVQx9GMp4%2FNEd5bIpe1T30y4%3D&reserved=0>.
You are receiving this because you commented.Message ID: ***@***.******@***.***>>
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
|
Hi Craig, yes, it's all working perfectly now. See my post from 15 July above. My issue related to cgate config file. It's working fine and I've now made a HA add-on for the whole package. Brian |
createClient deprecated. thanks @CraigD80
see #30