Skip to content
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

HASPmota add 'tag' attribute for free-form JSON #22698

Merged
merged 1 commit into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading