Skip to content

Commit

Permalink
HASPmota add 'tag' attribute for free-form JSON (#22698)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-hadinger authored Dec 21, 2024
1 parent 27e8580 commit 3b48a1c
Show file tree
Hide file tree
Showing 3 changed files with 1,115 additions and 1,018 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
- TLS disable ECDSA for MQTT to ensure we don't break fingerprints after #22649
- GPIOViewer from v1.5.6 to v1.5.8
- HASPmota use 'roboto.ttf' for automatic sizing of default font
- HASPmota add 'tag' attribute for free-form JSON

### Fixed
- Berry Zigbee fix wrong attributes (#22684)
Expand Down
21 changes: 20 additions & 1 deletion lib/libesp32_lvgl/lv_haspmota/src/embedded/lv_haspmota.be
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class lvh_root
var _parent_lvh # parent HASPmota object if 'parentid' was set, or 'nil'
var _meta # free form metadata

var _tag # free-form JSON tag

#====================================================================
# Rule engine to map value and text to rules
# hence enabling auto-updates ob objects
Expand Down Expand Up @@ -313,6 +315,16 @@ class lvh_root
return self._lv_obj
end

#====================================================================
# set_tag: create a free-form JSON tag
#====================================================================
def set_tag(t)
self._tag = t
end
def get_tag()
return self._tag
end

#====================================================================
# set_text: create a `lv_label` sub object to the current object
# (default case, may be overriden by object that directly take text)
Expand Down Expand Up @@ -667,9 +679,16 @@ class lvh_obj : lvh_root
tas_event_more += f',"text":{json.dump(text)}'
end
end
# add tag if present
if (self._tag != nil)
tas_event_more += f',"tag":{json.dump(self._tag)}'
end
var tas_event = format('{"hasp":{"p%ib%i":{"event":"%s"%s}}}', self._page._page_id, self.id, event_hasp, tas_event_more)
# print("val=",val)
tasmota.set_timer(0, /-> tasmota.publish_rule(tas_event))
tasmota.set_timer(0, def ()
tasmota.publish_rule(tas_event)
tasmota.log(f"HSP: publish {tas_event}", 4)
end)
end
end

Expand Down
Loading

0 comments on commit 3b48a1c

Please sign in to comment.