Epson RS232 interface

Any of you plugin wizards that want a semi-fun evening project?

I have tried to find out about this plugin world, i have some coding experience, but when i look at the plugin files, its obvious that you need more knowledge about the MCV system than i can find out.

This request is probably fairly simple; I have an ESPeasy RS232 to wifi (ESP8266) that transmits serial messages if you telnet to a selectable port and IP.

This is connected to a Epson TW3200, I can provide the full command structure if necessary.

For starters, what i want is a switch in Vera to turn it on and off. Next, I want the lamp hours to be readable in the device manager, and also any error indication.
There are other functions too, but is someone could get me started i can try to extrapolate on that…

The commands used are:
PWR?
PWR ON
PWR OFF
LAMP?
ERR?

Epson always replies with a colon last, or only a colon.

In terms of communication, i would think that the telnet port only needs to be open when the switch is on, and that the vera could poll for errors at a couple minutes interval maybe? Lamp time can be updated at the same time, or just at ON and OFF.

Hope someone out there can help! :slight_smile:

BTW: If I can realize this with scenes and some virtual devices, by all means, show me! :slight_smile:

Seem to be running my head to a brick wall trying to do this myself… I tried following the Somfy walkthrough (on MCV wiki), but the Vera UI does not respond as the WT says, and the device never shows up. If I try to enter the serial info, the RFXtrx stops working… :-\

Anyone who can start me off in the right direction here? All i need to do is to start a telnet, power the thing on, then leaving the telnet open until power off. Mabye even closing the telnet for each command…

In my searches on the forum i found this:

[quote=“wilme2, post:6, topic:187652”]You can use an iTach serial connector with iRule - I am sure you can do the same with Roomie. And you can send serial commands directly from Vera - you will just have to use Luup - no plug-in needed.

My QMotion shades, my Panasonic projector, and my Sony A/V receiver are all connected via a serial port to an iTach, and then I send IP commands to the iTach with the serial commands encapsulated…

Very simple example:

local socket = require("socket") host = "192.168.0.123" c = assert(socket.connect(host, 4999)) c:settimeout(5) local sres, serr = c:send(string.char(0x01,0x07,0x00,0x05,0x01,0x01,0x02,0x00,0xFF)) local data, rerr = c:receive(300) luup.log (data) c:close() [/quote]

This seems to be what i need to add to the LUA section of a scene to send a command?

Am i right in that the “string.char” converts from hex to char, and that i can replace this with a regular string like this?

local sres, serr = c:send("PWR ON")

This works! ;D

local socket = require("socket") host = "2.70.50.200" c = assert(socket.connect(host, 23)) c:settimeout(5) local sres, serr = c:send("PWR ON\r") local data, rerr = c:receive(300) luup.log (data) c:close()

I can now turn it on and off, next obstacle is to display Lamp time (mabye as battery status?) and Error status on the projector “bulb” GUI. Feel free to chime in, i’ll update here when i figure it out. :slight_smile:

string.char is standard LUA: Programming in Lua : 20

[quote=“Forzaalfa, post:4, topic:198338”]This works! ;D

local socket = require("socket") host = "2.70.50.200" c = assert(socket.connect(host, 23)) c:settimeout(5) local sres, serr = c:send("PWR ON\r") local data, rerr = c:receive(300) luup.log (data) c:close()

I can now turn it on and off, next obstacle is to display Lamp time (mabye as battery status?) and Error status on the projector “bulb” GUI. Feel free to chime in, i’ll update here when i figure it out. :)[/quote]

Always fun when you make that initial progress! BTW, since this is standard LUA (other than luup.log), I wanted to point out you want work on this code in another platform until you get it figured out. I use LUA for Windows (SciTE) to test commands to other IP based systems (IR/RS232/Closed Contact via Global Cache iTach, plus native IP devices) to make sure I have all the commands right before I try to add it to my Vera… Then I add in the Vera-specific code…

Sound advice probably, I used the code test thing in the vera, and as you probably tested the code before me i asumed the risk to be low. :slight_smile:

Du you think its possible to write to the slot on the light switch GUI that shows energy usage for the z-wave switches?
I’d like to show the error status there, and to use the battery status symbol to show remaining % of hours on the bulb…

[quote=“Forzaalfa, post:7, topic:198338”]Sound advice probably, I used the code test thing in the vera, and as you probably tested the code before me i asumed the risk to be low. :slight_smile:

Du you think its possible to write to the slot on the light switch GUI that shows energy usage for the z-wave switches?
I’d like to show the error status there, and to use the battery status symbol to show remaining % of hours on the bulb…[/quote]

You may have to create the variables. So like add urn:micasaverde-com:serviceId:HaDevice1 / BatteryLevel to a device, then try populating it.

I don’t use my projector enough to worry about bulb life. I think I had to replace a bulb once in my 720p projector. I have never had to replace one in my current 1080p…

Mine is used as the only “TV” in the house, so its beeing used. :slight_smile:

Where can i find the response in “luup.log(data)”? couldn’t find it in the LuaUPnP log?

Ok, so now i established how to retrieve the response from the projector.

One thing that is a bit difficult is to retrieve a unspecified length of characters, the projector sends “LAMP=890:” and all messages is ended by “:”. Problem is, the number will go over to 4 digits, and then my code will miss the last character. Is there any way to say “Listen until ‘:’ is recieved”? I tried “*l”, but it doesnt work… i only get the string if i have the number of bytes correct.

My plan now for the communication:

  1. Power ON scene sends “PWR ON”, and when “:” resonse is recieved, i send “LAMP?” and populate the battery variable with the precentage of lamp life.

  2. A separate scene is initiated which opens a port, and listens for an ERR=some error, if an error comes, it populates a variable and alerts me.

  3. Power OFF scene sends “LAMP?” and updates the battery variable. Then it sends a “PWR OFF”. The Error listening is ended by sensing that “PWR OFF” response is recieved.
    The ESP link handles several connections and always sends the response to any input to all connections, but is vera capable of having more than one socket to the same unit?

Any comments on this plan? Any better ways to do it on this side of making a full plugin?