[SOLVED] esp8266---mqtt----WS2801/WS2812/neopixel

Group All

String RGBLed (All) {mqtt=">[mosquitto:esp/1/out:command:*:default]"}

Color RGBLed (All) {mqtt="<[mosquitto:esp/1/out:state:default]"}

2018-04-18 12:53:41.028 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Set HSB value of item RGBLed to RGB color value’: The name ‘RGBLedColor’ cannot be resolved to an item or type; line 19, column 2, length 11

Ceyhun,
I need more info, not just the errors
Can you show the whole log from when RGBLed gets the update from your dashboard
We can’t debug without context

==> /var/log/openhab2/events.log <==

2018-04-18 13:17:19.855 [vent.ItemStateChangedEvent] - Date changed from 2018-04-18T13:16:19.827+0300 to 2018-04-18T13:17:19.832+0300

==> /var/log/openhab2/openhab.log <==

2018-04-18 13:18:03.070 [WARN ] [b.core.events.EventPublisherDelegate] - given new state is NULL, couldn't post update for 'RGBLed'

==> /var/log/openhab2/events.log <==

2018-04-18 13:18:19.864 [vent.ItemStateChangedEvent] - Date changed from 2018-04-18T13:17:19.832+0300 to 2018-04-18T13:18:19.837+0300

==> /var/log/openhab2/openhab.log <==

2018-04-18 13:19:03.075 [WARN ] [b.core.events.EventPublisherDelegate] - given new state is NULL, couldn't post update for 'RGBLed'

==> /var/log/openhab2/events.log <==

2018-04-18 13:19:19.868 [vent.ItemStateChangedEvent] - Date changed from 2018-04-18T13:18:19.837+0300 to 2018-04-18T13:19:19.842+0300

==> /var/log/openhab2/openhab.log <==

2018-04-18 13:20:03.077 [WARN ] [b.core.events.EventPublisherDelegate] - given new state is NULL, couldn't post update for 'RGBLed'

==> /var/log/openhab2/events.log <==

2018-04-18 13:20:19.863 [vent.ItemStateChangedEvent] - Date changed from 2018-04-18T13:19:19.842+0300 to 2018-04-18T13:20:19.847+0300

==> /var/log/openhab2/openhab.log <==

2018-04-18 13:21:03.081 [WARN ] [b.core.events.EventPublisherDelegate] - given new state is NULL, couldn't post update for 'RGBLed'

==> /var/log/openhab2/events.log <==

2018-04-18 13:21:19.878 [vent.ItemStateChangedEvent] - Date changed from 2018-04-18T13:20:19.847+0300 to 2018-04-18T13:21:19.851+0300

==> /var/log/openhab2/openhab.log <==

2018-04-18 13:22:03.089 [WARN ] [b.core.events.EventPublisherDelegate] - given new state is NULL, couldn't post update for 'RGBLed'

==> /var/log/openhab2/events.log <==

2018-04-18 13:22:19.873 [vent.ItemStateChangedEvent] - Date changed from 2018-04-18T13:21:19.851+0300 to 2018-04-18T13:22:19.856+0300

==> /var/log/openhab2/openhab.log <==

2018-04-18 13:23:03.092 [WARN ] [b.core.events.EventPublisherDelegate] - given new state is NULL, couldn't post update for 'RGBLed'

==> /var/log/openhab2/events.log <==

2018-04-18 13:23:19.887 [vent.ItemStateChangedEvent] - Date changed from 2018-04-18T13:22:19.856+0300 to 2018-04-18T13:23:19.861+0300

==> /var/log/openhab2/openhab.log <==

2018-04-18 13:24:03.098 [WARN ] [b.core.events.EventPublisherDelegate] - given new state is NULL, couldn't post update for 'RGBLed'

==> /var/log/openhab2/events.log <==

2018-04-18 13:24:19.888 [vent.ItemStateChangedEvent] - Date changed from 2018-04-18T13:23:19.861+0300 to 2018-04-18T13:24:19.865+0300

==> /var/log/openhab2/openhab.log <==

2018-04-18 13:25:03.100 [WARN ] [b.core.events.EventPublisherDelegate] - given new state is NULL, couldn't post update for 'RGBLed'

==> /var/log/openhab2/events.log <==

2018-04-18 13:25:19.894 [vent.ItemStateChangedEvent] - Date changed from 2018-04-18T13:24:19.865+0300 to 2018-04-18T13:25:19.870+0300

==> /var/log/openhab2/openhab.log <==

2018-04-18 13:26:03.109 [WARN ] [b.core.events.EventPublisherDelegate] - given new state is NULL, couldn't post update for 'RGBLed'

==> /var/log/openhab2/events.log <==

2018-04-18 13:26:19.900 [vent.ItemStateChangedEvent] - Date changed from 2018-04-18T13:25:19.870+0300 to 2018-04-18T13:26:19.875+0300

==> /var/log/openhab2/openhab.log <==

2018-04-18 13:27:03.111 [WARN ] [b.core.events.EventPublisherDelegate] - given new state is NULL, couldn't post update for 'RGBLed'

==> /var/log/openhab2/events.log <==

2018-04-18 13:27:19.897 [vent.ItemStateChangedEvent] - Date changed from 2018-04-18T13:26:19.875+0300 to 2018-04-18T13:27:19.880+0300

==> /var/log/openhab2/openhab.log <==

2018-04-18 13:28:03.111 [WARN ] [b.core.events.EventPublisherDelegate] - given new state is NULL, couldn't post update for 'RGBLed'

What does the log look like when you publich a color on your dashboard to esp/1/out

Group All

String RGBLed (All) {mqtt="<[mosquitto:esp/1/out:state:default]"}

//Color RGBLed (All) {mqtt="<[mosquitto:esp/1/out:state:default]"}

2018-04-18 13:56:59.963 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Set HSB value of item RGBLed to RGB color value’: The name ‘RGBLedColor’ cannot be resolved to an item or type; line 19, column 2, length 11

Did you change your rule as I said above and now:
I need to know what happens in the rule and the value of the items and variables
It is important that your code is exactly as below

rule "Set HSB value of item RGBLed to RGB color value"
when
	Item RGBLed changed
then
        logInfo("RGBLed", RBGLed.state)
	val hsbValue = RGBLed.state as HSBType
        logIngo("RGBLed", hsbvalue.toString)
	val brightness = hsbValue.brightness.intValue
        logInfo("BRIGHTNESS", brightness.toString)
	val redValue = ((((hsbValue.red.intValue * 255) / 100) *brightness) /100).toString
        logInfo("REDVALUE", redValue.toString)
	val greenValue = ((((hsbValue.green.intValue * 255) / 100) *brightness) /100).toString
        logInfo("GREENVALUE", greenValue.toString)
	val blueValue = ((((hsbValue.blue.intValue * 255) / 100) *brightness) /100).toString
        logInfo("BLUEVALUE", blueValue.toString)

	val color = redValue + "," + greenValue + "," + blueValue
        logInfo("COLOR", color)

	RGBLedColor.sendCommand(color)
end

Does you item file looks exactly like this?

Group All

String RGBLed (All) {mqtt="<[mosquitto:esp/1/out:state:default]"}
String RGBLedColor  (All) {mqtt=">[mosquitto:esp/1/out:command:*:default]"}

first time i see this — #F7C42—in openhab log thats good i thing----and thank u very much for your help-----

2018-04-18 14:13:45.941 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'demo.items'

==> /var/log/openhab2/events.log <==

2018-04-18 14:14:11.749 [vent.ItemStateChangedEvent] - RGBLed changed from NULL to #F72C5

==> /var/log/openhab2/openhab.log <==

2018-04-18 14:14:12.242 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Set HSB value of item RGBLed to RGB color value': The name 'RBGLed' cannot be resolved to an item or type; line 5, column 27, length 6

==> /var/log/openhab2/events.log <==

2018-04-18 14:14:20.402 [vent.ItemStateChangedEvent] - Date changed from 2018-04-18T14:13:20.380+0300 to 2018-04-18T14:14:20.385+0300

==> /var/log/openhab2/openhab.log <==

2018-04-18 14:14:50.196 [WARN ] [sitemap.internal.SitemapProviderImpl] - Filename `demo.sitemap` does not match the name `NeoPixel` of the sitemap - please fix this as you might see unexpected behavior otherwise.

==> /var/log/openhab2/events.log <==

2018-04-18 14:14:52.910 [ome.event.ItemCommandEvent] - Item 'RGBLed' received command 243,47,100

2018-04-18 14:14:52.917 [vent.ItemStateChangedEvent] - RGBLed changed from #F72C5 to 243,47,100

==> /var/log/openhab2/openhab.log <==

2018-04-18 14:14:52.922 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Set HSB value of item RGBLed to RGB color value': The name 'RBGLed' cannot be resolved to an item or type; line 5, column 27, length 6

==> /var/log/openhab2/events.log <==

2018-04-18 14:15:11.737 [vent.ItemStateChangedEvent] - RGBLed changed from 243,47,100 to #F72C5

==> /var/log/openhab2/openhab.log <==

2018-04-18 14:15:11.744 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Set HSB value of item RGBLed to RGB color value': The name 'RBGLed' cannot be resolved to an item or type; line 5, column 27, length 6

==> /var/log/openhab2/events.log <==

2018-04-18 14:15:20.407 [vent.ItemStateChangedEvent] - Date changed from 2018-04-18T14:14:20.385+0300 to 2018-04-18T14:15:20.389+0300

2018-04-18 14:15:49.171 [vent.ItemStateChangedEvent] - RGBLed changed from #F72C5 to Restart

==> /var/log/openhab2/openhab.log <==

2018-04-18 14:15:49.181 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Set HSB value of item RGBLed to RGB color value': The name 'RBGLed' cannot be resolved to an item or type; line 5, column 27, length 6

==> /var/log/openhab2/events.log <==

2018-04-18 14:16:04.350 [vent.ItemStateChangedEvent] - RGBLed changed from Restart to #F7C42

==> /var/log/openhab2/openhab.log <==

2018-04-18 14:16:04.361 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Set HSB value of item RGBLed to RGB color value': The name 'RBGLed' cannot be resolved to an item or type; line 5, column 27, length 6

==> /var/log/openhab2/events.log <==

2018-04-18 14:16:11.592 [ome.event.ItemCommandEvent] - Item 'RGBLed' received command 234,89,100

2018-04-18 14:16:11.602 [vent.ItemStateChangedEvent] - RGBLed changed from #F7C42 to 234,89,100

==> /var/log/openhab2/openhab.log <==

2018-04-18 14:16:11.612 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Set HSB value of item RGBLed to RGB color value': The name 'RBGLed' cannot be resolved to an item or type; line 5, column 27, length 6

==> /var/log/openhab2/events.log <==

2018-04-18 14:16:20.421 [vent.ItemStateChangedEvent] - Date changed from 2018-04-18T14:15:20.389+0300 to 2018-04-18T14:16:20.394+0300

2018-04-18 14:17:04.357 [vent.ItemStateChangedEvent] - RGBLed changed from 234,89,100 to #F7C42

==> /var/log/openhab2/openhab.log <==

2018-04-18 14:17:04.366 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Set HSB value of item RGBLed to RGB color value': The name 'RBGLed' cannot be resolved to an item or type; line 5, column 27, length 6

==> /var/log/openhab2/events.log <==

2018-04-18 14:17:20.436 [vent.ItemStateChangedEvent] - Date changed from 2018-04-18T14:16:20.394+0300 to 2018-04-18T14:17:20.399+0300
Group All

String RGBLed (All) {mqtt="<[mosquitto:esp/1/out:state:default]"}
String RGBLedColor  (All) {mqtt=">[mosquitto:esp/1/out:command:*:default]"}
rule "Set HSB value of item RGBLed to RGB color value"
when
	Item RGBLed changed
then
        logInfo("RGBLed", RBGLed.state)
	val hsbValue = RGBLed.state as HSBType
        logIngo("RGBLed", hsbvalue.toString)
	val brightness = hsbValue.brightness.intValue
        logInfo("BRIGHTNESS", brightness.toString)
	val redValue = ((((hsbValue.red.intValue * 255) / 100) *brightness) /100).toString
        logInfo("REDVALUE", redValue.toString)
	val greenValue = ((((hsbValue.green.intValue * 255) / 100) *brightness) /100).toString
        logInfo("GREENVALUE", greenValue.toString)
	val blueValue = ((((hsbValue.blue.intValue * 255) / 100) *brightness) /100).toString
        logInfo("BLUEVALUE", blueValue.toString)

	val color = redValue + "," + greenValue + "," + blueValue
        logInfo("COLOR", color)

	RGBLedColor.sendCommand(color)
end
sitemap NeoPixel label="NeoPixel"
{
	Frame label="NeoPixel" {
		Colorpicker item=RGBLed icon="slider"
	}
}	

I made a Typo:

First logInfo in the rule:

logInfo("RGBLed", RBGLed.state)

And then change the color with the sitemap NOT the mqtt dashboard
What happens?

ooo i not understand now what to do

Make sure that your your is like this:
I corrected the typo

rule "Set HSB value of item RGBLed to RGB color value"
when
	Item RGBLed changed
then
        logInfo("RGBLed", RGBLed.state)
	val hsbValue = RGBLed.state as HSBType
        logIngo("RGBLed", hsbvalue.toString)
	val brightness = hsbValue.brightness.intValue
        logInfo("BRIGHTNESS", brightness.toString)
	val redValue = ((((hsbValue.red.intValue * 255) / 100) *brightness) /100).toString
        logInfo("REDVALUE", redValue.toString)
	val greenValue = ((((hsbValue.green.intValue * 255) / 100) *brightness) /100).toString
        logInfo("GREENVALUE", greenValue.toString)
	val blueValue = ((((hsbValue.blue.intValue * 255) / 100) *brightness) /100).toString
        logInfo("BLUEVALUE", blueValue.toString)

	val color = redValue + "," + greenValue + "," + blueValue
        logInfo("COLOR", color)

	RGBLedColor.sendCommand(color)
end

And then change the color with the sitemap NOT the mqtt dashboard
What happens?

018-04-18 15:14:10.350 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'demo.rules' is either empty or cannot be parsed correctly!

2018-04-18 15:14:10.943 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'demo.rules'

==> /var/log/openhab2/events.log <==

2018-04-18 15:14:16.627 [vent.ItemStateChangedEvent] - RGBLed changed from Restart to #00000

==> /var/log/openhab2/openhab.log <==

2018-04-18 15:14:17.092 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Set HSB value of item RGBLed to RGB color value': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.LogAction.logInfo(java.lang.String,java.lang.String,java.lang.Object[]) on instance: null

==> /var/log/openhab2/events.log <==

2018-04-18 15:14:20.962 [vent.ItemStateChangedEvent] - Date changed from 2018-04-18T15:13:20.937+0300 to 2018-04-18T15:14:20.942+0300

==> /var/log/openhab2/openhab.log <==

2018-04-18 15:14:26.375 [WARN ] [sitemap.internal.SitemapProviderImpl] - Filename `demo.sitemap` does not match the name `NeoPixel` of the sitemap - please fix this as you might see unexpected behavior otherwise.

==> /var/log/openhab2/events.log <==

2018-04-18 15:14:33.283 [ome.event.ItemCommandEvent] - Item 'RGBLed' received command 218,83,100

2018-04-18 15:14:33.297 [vent.ItemStateChangedEvent] - RGBLed changed from #00000 to 218,83,100

==> /var/log/openhab2/openhab.log <==

2018-04-18 15:14:33.303 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Set HSB value of item RGBLed to RGB color value': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.LogAction.logInfo(java.lang.String,java.lang.String,java.lang.Object[]) on instance: null

==> /var/log/openhab2/events.log <==

2018-04-18 15:15:16.637 [vent.ItemStateChangedEvent] - RGBLed changed from 218,83,100 to #00000

==> /var/log/openhab2/openhab.log <==

2018-04-18 15:15:16.649 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Set HSB value of item RGBLed to RGB color value': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.LogAction.logInfo(java.lang.String,java.lang.String,java.lang.Object[]) on instance: null


Ok some progress…
Please do NOT change the color with the MQTT dashboard
Please change this:

Line 5 of the rule:
logInfo("RGBLed", RGBLed.state)
to
logInfo("RGBLed", RGBLed.state.toString)

Save
Then change the value of the color on the sitemap
Show me the log

2018-04-18 15:38:46.354 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'demo.rules'

2018-04-18 15:38:46.376 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'demo.rules' is either empty or cannot be parsed correctly!

2018-04-18 15:38:47.245 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'demo.rules'

2018-04-18 15:39:10.019 [WARN ] [sitemap.internal.SitemapProviderImpl] - Filename `demo.sitemap` does not match the name `NeoPixel` of the sitemap - please fix this as you might see unexpected behavior otherwise.

==> /var/log/openhab2/events.log <==

2018-04-18 15:39:13.130 [ome.event.ItemCommandEvent] - Item 'RGBLed' received command 283,60,100

2018-04-18 15:39:13.137 [vent.ItemStateChangedEvent] - RGBLed changed from #F7425 to 283,60,100

==> /var/log/openhab2/openhab.log <==

2018-04-18 15:39:13.615 [INFO ] [clipse.smarthome.model.script.RGBLed] - 283,60,100

2018-04-18 15:39:13.621 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Set HSB value of item RGBLed to RGB color value': Could not cast 283,60,100 to org.eclipse.smarthome.core.library.types.HSBType; line 6, column 17, length 23

==> /var/log/openhab2/events.log <==

2018-04-18 15:39:17.849 [ome.event.ItemCommandEvent] - Item 'RGBLed' received command 104,93,100

2018-04-18 15:39:17.860 [vent.ItemStateChangedEvent] - RGBLed changed from 283,60,100 to 104,93,100

==> /var/log/openhab2/openhab.log <==

2018-04-18 15:39:17.872 [INFO ] [clipse.smarthome.model.script.RGBLed] - 104,93,100

2018-04-18 15:39:17.879 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Set HSB value of item RGBLed to RGB color value': Could not cast 104,93,100 to org.eclipse.smarthome.core.library.types.HSBType; line 6, column 17, length 23

==> /var/log/openhab2/events.log <==

2018-04-18 15:39:18.819 [ome.event.ItemCommandEvent] - Item 'RGBLed' received command 73,81,100

==> /var/log/openhab2/openhab.log <==

2018-04-18 15:39:18.835 [INFO ] [clipse.smarthome.model.script.RGBLed] - 73,81,100

==> /var/log/openhab2/events.log <==

2018-04-18 15:39:18.840 [vent.ItemStateChangedEvent] - RGBLed changed from 104,93,100 to 73,81,100

==> /var/log/openhab2/openhab.log <==

2018-04-18 15:39:18.850 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Set HSB value of item RGBLed to RGB color value': Could not cast 73,81,100 to org.eclipse.smarthome.core.library.types.HSBType; line 6, column 17, length 23

==> /var/log/openhab2/events.log <==

2018-04-18 15:39:21.066 [vent.ItemStateChangedEvent] - Date changed from 2018-04-18T15:38:21.046+0300 to 2018-04-18T15:39:21.051+0300

2018-04-18 15:40:09.946 [vent.ItemStateChangedEvent] - RGBLed changed from 73,81,100 to #F7425

==> /var/log/openhab2/openhab.log <==

2018-04-18 15:40:09.960 [INFO ] [clipse.smarthome.model.script.RGBLed] - #F7425

2018-04-18 15:40:09.968 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Set HSB value of item RGBLed to RGB color value': Could not cast #F7425 to org.eclipse.smarthome.core.library.types.HSBType; line 6, column 17, length 23

==> /var/log/openhab2/events.log <==

2018-04-18 15:40:21.077 [vent.ItemStateChangedEvent] - Date changed from 2018-04-18T15:39:21.051+0300 to 2018-04-18T15:40:21.055+0300

It’s good, there is progress

Change the next line:
val hsbValue = RGBLed.state as HSBType
to
val hsbValue = RGBLed.state.toString as HSBType

018-04-18 15:52:06.081 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Set HSB value of item RGBLed to RGB color value': Could not cast 116,95,100 to org.eclipse.smarthome.core.library.types.HSBType; line 6, column 17, length 32

Change your item back to a Color but remove the binding

Color RGBLed (All) //{mqtt="<[mosquitto:esp/1/out:state:default]"}

Then change the line we just changed back to:

val hsbValue = RGBLed.state as HSBType

1 Like
Group All

Color RGBLed (All) 

String RGBLedColor  (All) {mqtt=">[mosquitto:esp/1/out:command:*:default]"}

2018-04-18 18:57:38.143 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Set HSB value of item RGBLed to RGB color value’: The name ‘logIngo’ cannot be resolved to an item or type; line 7, column 9, length 36

Good, next line, another typo, sorry
Change
logIngo("RGBLed", hsbvalue.toString)
to
logInfo("RGBLed", hsbvalue.toString)

1 Like

good morning

rule "Set HSB value of item RGBLed to RGB color value"
when
	Item RGBLed changed
then
        logInfo("RGBLed", RGBLed.state.toString)
	val hsbValue = RGBLed.state as HSBType
        logInfo("RGBLed", hsbvalue.toString)
	val brightness = hsbValue.brightness.intValue
        logInfo("BRIGHTNESS", brightness.toString)
	val redValue = ((((hsbValue.red.intValue * 255) / 100) *brightness) /100).toString
        logInfo("REDVALUE", redValue.toString)
	val greenValue = ((((hsbValue.green.intValue * 255) / 100) *brightness) /100).toString
        logInfo("GREENVALUE", greenValue.toString)
	val blueValue = ((((hsbValue.blue.intValue * 255) / 100) *brightness) /100).toString
        logInfo("BLUEVALUE", blueValue.toString)

	val color = redValue + "," + greenValue + "," + blueValue
        logInfo("COLOR", color)

	RGBLedColor.sendCommand(color)
end