Interesting you mention JSON, as that’s how I approached it in my first attempt. However, I didn’t and still don’t know/understand JSON well enough to accomplish what I was trying to achieve. Would you mind sharing an example of the construction of the JSON in openHAB? (just guessing here, but you would send, JSON - >item, state, item, state ?)
This actually leads nicely to my second topic/comment/(existential rambling) that Id like to get your thoughts on: Ohsendcommand, as a sort of robust button/toggle. I think this might be a very interesting and (what I like more) cleaner/organized way to approach a dashboard that actually isn’t in openHAB.
The way I envision it working is that Dashing handles the UI side only and all the data is sent to a single item in OpenHAB, and the sentCommand contains the item(s) and command(s) translated and posted. This should avoid all complex scripting in what could be many dashing widgets (and more importantly RUBY). For example, if I want to turn the temp up on my thermostat, i dashing would send in JSON the item and the command ‘+1’, which would be translated and posted to the item in openHAB. The items/commands could be attached to the widget in the default.erb file via data-*. Then the item is updated, and posted back to dashing (if it needs, and then data-id would be the name of the item being updated in openHAB).
In dashing, you could assign a data-class, via SASS variables create the widget, with its style. In theory, you could run a simple +/- dimmer as well, have to commands, and assign where they go in the widget.
Does this make sense? Or am I wasting my time here?
If this does make sense, as I said above, I’m quite unfamiliar with JSON, so will ramp my knowledge up on it next. If you could provide any examples, esp. for ruby/coffeescripts, that would help tremendously. I think I saw a few examples in openHAB about parsing JSON, so I should be good on that front.
Thanks in advance.
ap
Example using how its currently designed that updated a scene that is set via openHAB rules. Data-icon is set to the command I want to send, which is going directly to a rule now, but would be sent to the dummy item i proposed above.
In default.erb:
<li data-row="7" data-col="7" data-sizex="1" data-sizey="1">
<div data-id="Light_livingRoom_Scenes" data-view="Ohsendcommand" data-title="Lights Low" data-device="Light_livingRoom_Scenes" data-icon="1"></div>
</li>
And the coffeescript:
class Dashing.Ohsendcommand extends Dashing.ClickableWidget
constructor: ->
super
@accessor ‘command’,
get: -> @command ? @get(‘icon’)
set: (key, value) -> @command = value
sendCommand: ->
myCommand = @get(‘command’)
$.post ‘/openhab/dispatch’,
deviceId: @get(‘device’),
command: myCommand
ready: ->
onClick: (event) ->
@sendCommand()